fix: can enable autorelay without content routing as long as there are static relays configured
@@ -207,6 +207,17 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
return nil, fmt.Errorf("cannot enable autorelay; relay is not enabled")
}
+ hop := false
+ for _, opt := range cfg.RelayOpts {
+ if opt == circuit.OptHop {
+ hop = true
+ break
+ }
+ }
+
+ if !hop && len(cfg.StaticRelays) > 0 {
+ _ = relay.NewAutoRelay(swrm.Context(), h, nil, router, cfg.StaticRelays)
+ } else {
if router == nil {
h.Close()
return nil, fmt.Errorf("cannot enable autorelay; no routing for discovery")
@@ -220,14 +231,6 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
discovery := discovery.NewRoutingDiscovery(crouter)
- hop := false
- for _, opt := range cfg.RelayOpts {
- if opt == circuit.OptHop {
- hop = true
- break
- }
- }
-
if hop {
// advertise ourselves
relay.Advertise(ctx, discovery)
@@ -235,6 +238,7 @@ func (cfg *Config) NewNode(ctx context.Context) (host.Host, error) {
_ = relay.NewAutoRelay(swrm.Context(), h, discovery, router, cfg.StaticRelays)
}
}
+ }
// start the host background tasks
h.Start()
