Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Announce relay addresses by default #4830

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -869,17 +869,8 @@ func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr
hostOpts = append(hostOpts, opts.ConnectionManager)
}

addrsFactory := opts.AddrsFactory
if !opts.DisableRelay {
if addrsFactory != nil {
addrsFactory = composeAddrsFactory(addrsFactory, filterRelayAddrs)
} else {
addrsFactory = filterRelayAddrs
}
}

if addrsFactory != nil {
hostOpts = append(hostOpts, addrsFactory)
if opts.AddrsFactory != nil {
hostOpts = append(hostOpts, opts.AddrsFactory)
}

host := p2pbhost.New(network, hostOpts...)
Expand All @@ -900,24 +891,6 @@ func constructPeerHost(ctx context.Context, id peer.ID, ps pstore.Peerstore, bwr
return host, nil
}

func filterRelayAddrs(addrs []ma.Multiaddr) []ma.Multiaddr {
var raddrs []ma.Multiaddr
for _, addr := range addrs {
_, err := addr.ValueForProtocol(circuit.P_CIRCUIT)
if err == nil {
continue
}
raddrs = append(raddrs, addr)
}
return raddrs
}

func composeAddrsFactory(f, g p2pbhost.AddrsFactory) p2pbhost.AddrsFactory {
return func(addrs []ma.Multiaddr) []ma.Multiaddr {
return f(g(addrs))
}
}

// startListening on the network addresses
func startListening(ctx context.Context, host p2phost.Host, cfg *config.Config) error {
listenAddrs, err := listenAddresses(cfg)
Expand Down