p2p/net/swrm: InterfaceListenAddrs now method
This commit is contained in:
parent
5de997f0b7
commit
3d3ffc45a6
|
@ -22,14 +22,14 @@ func (s *Swarm) ListenAddresses() []ma.Multiaddr {
|
|||
// InterfaceListenAddresses returns a list of addresses at which this swarm
|
||||
// listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to
|
||||
// use the known local interfaces.
|
||||
func InterfaceListenAddresses(s *Swarm) ([]ma.Multiaddr, error) {
|
||||
func (s *Swarm) InterfaceListenAddresses() ([]ma.Multiaddr, error) {
|
||||
return addrutil.ResolveUnspecifiedAddresses(s.ListenAddresses(), nil)
|
||||
}
|
||||
|
||||
// checkNATWarning checks if our observed addresses differ. if so,
|
||||
// informs the user that certain things might not work yet
|
||||
func checkNATWarning(s *Swarm, observed ma.Multiaddr, expected ma.Multiaddr) {
|
||||
listen, err := InterfaceListenAddresses(s)
|
||||
listen, err := s.InterfaceListenAddresses()
|
||||
if err != nil {
|
||||
log.Errorf("Error retrieving swarm.InterfaceListenAddresses: %s", err)
|
||||
return
|
||||
|
|
|
@ -252,7 +252,7 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
|
|||
remoteAddrs = addrutil.FilterUsableAddrs(remoteAddrs)
|
||||
// drop out any addrs that would just dial ourselves. use ListenAddresses
|
||||
// as that is a more authoritative view than localAddrs.
|
||||
ila, _ := InterfaceListenAddresses(s)
|
||||
ila, _ := s.InterfaceListenAddresses()
|
||||
remoteAddrs = addrutil.Subtract(remoteAddrs, ila)
|
||||
remoteAddrs = addrutil.Subtract(remoteAddrs, s.peers.Addresses(s.local))
|
||||
log.Debugf("%s swarm dialing %s -- remote:%s local:%s", s.local, p, remoteAddrs, s.ListenAddresses())
|
||||
|
|
|
@ -111,7 +111,7 @@ func (n *Network) ListenAddresses() []ma.Multiaddr {
|
|||
// listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to
|
||||
// use the known local interfaces.
|
||||
func (n *Network) InterfaceListenAddresses() ([]ma.Multiaddr, error) {
|
||||
return InterfaceListenAddresses(n.Swarm())
|
||||
return n.Swarm().InterfaceListenAddresses()
|
||||
}
|
||||
|
||||
// Connectedness returns a state signaling connection capabilities
|
||||
|
|
Loading…
Reference in New Issue