p2p/net/swrm: InterfaceListenAddrs now method

This commit is contained in:
Juan Batiz-Benet 2015-01-13 05:58:49 -08:00
parent 5de997f0b7
commit 3d3ffc45a6
3 changed files with 4 additions and 4 deletions

View File

@ -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

View File

@ -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())

View File

@ -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