Commit 89aef893 authored by vyzo's avatar vyzo
Browse files

don't adveretise unspecific relay addrs in RelayHost

parent dcb8fd28
......@@ -3,21 +3,34 @@ package relay
import (
"context"
basic "github.com/libp2p/go-libp2p/p2p/host/basic"
discovery "github.com/libp2p/go-libp2p-discovery"
host "github.com/libp2p/go-libp2p-host"
ma "github.com/multiformats/go-multiaddr"
)
// RelayHost is a Host that provides Relay services.
type RelayHost struct {
host.Host
*basic.BasicHost
advertise discovery.Advertiser
addrsF basic.AddrsFactory
}
// New constructs a new RelayHost
func NewRelayHost(ctx context.Context, host host.Host, advertise discovery.Advertiser) *RelayHost {
h := &RelayHost{Host: host, advertise: advertise}
func NewRelayHost(ctx context.Context, bhost *basic.BasicHost, advertise discovery.Advertiser) *RelayHost {
h := &RelayHost{
BasicHost: bhost,
addrsF: bhost.AddrsFactory,
advertise: advertise,
}
bhost.AddrsFactory = h.hostAddrs
discovery.Advertise(ctx, advertise, "/libp2p/relay")
return h
}
func (h *RelayHost) hostAddrs(addrs []ma.Multiaddr) []ma.Multiaddr {
return filterUnspecificRelay(h.addrsF(addrs))
}
var _ host.Host = (*RelayHost)(nil)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment