Skip to content

Commit

Permalink
skip locally held addresses
Browse files Browse the repository at this point in the history
fix #44
  • Loading branch information
willscott committed Feb 27, 2020
1 parent 370d2ef commit 3a21c6d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions p2p/host/autonat/svc.go
Expand Up @@ -32,6 +32,7 @@ var (
// AutoNATService provides NAT autodetection services to other peers
type AutoNATService struct {
ctx context.Context
h host.Host
dialer host.Host

// rate limiter
Expand All @@ -49,6 +50,7 @@ func NewAutoNATService(ctx context.Context, h host.Host, forceEnabled bool, opts

as := &AutoNATService{
ctx: ctx,
h: h,
dialer: dialer,
reqs: make(map[peer.ID]int),
}
Expand Down Expand Up @@ -178,6 +180,13 @@ func (as *AutoNATService) skipDial(addr ma.Multiaddr) bool {
return true
}

// Skip dialing addresses we believe are the local node's
for _, localAddr := range as.h.Addrs() {
if localAddr.Equal(addr) {
return true
}
}

return false
}

Expand Down

0 comments on commit 3a21c6d

Please sign in to comment.