From 2047451fc4a4bb1f5af88129076382b314e541a6 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Fri, 23 Jun 2023 11:03:24 +0100 Subject: [PATCH] Fix inconsistent annoucne addr config for HTTP publisher kind http publisher announce addrs are not passed to the publisher when its kind is HTTP. See inline comment. --- engine/engine.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/engine/engine.go b/engine/engine.go index 094b15c7..00e17832 100644 --- a/engine/engine.go +++ b/engine/engine.go @@ -238,7 +238,19 @@ func (e *Engine) Publish(ctx context.Context, adv schema.Advertisement) (cid.Cid log.Info("Announcing advertisement in pubsub channel and via http") } - err = e.publisher.UpdateRoot(ctx, c) + // The publishers have their own senders of announcements. Further, there is a bespoke sender in the engine + // to allow explicit announcements via HTTP. The catch is that their behaviour is inconsistent: + // * engine takes pubHttpAnnounceAddrs option to allow configuring which addrs should be announced. + // But those addrs are only used by the bespoke sender, _not_ the HTTP sender inside publishers. + // + // To work around this issue, check if announce addrs are set, and publisher kind is HTTP, and + // if so announce with explicit addresses configured. + if len(e.pubHttpAnnounceAddrs) > 0 && e.pubKind == HttpPublisher { + err = e.publisher.UpdateRootWithAddrs(ctx, c, e.pubHttpAnnounceAddrs) + } else { + err = e.publisher.UpdateRoot(ctx, c) + } + if err != nil { log.Errorw("Failed to announce advertisement", "err", err) return cid.Undef, err