func addrInAddrs(a ma.Multiaddr, as []ma.Multiaddr) bool { for _, b := range as { if a.Equal(b) { return true } } return false }
// AddrInList returns whether or not an address is part of a list. // this is useful to check if NAT is happening (or other bugs?) func AddrInList(addr ma.Multiaddr, list []ma.Multiaddr) bool { for _, addr2 := range list { if addr.Equal(addr2) { return true } } return false }
// CheckNATWarning checks if our observed addresses differ. if so, // informs the user that certain things might not work yet func CheckNATWarning(observed, expected ma.Multiaddr, listen []ma.Multiaddr) { if observed.Equal(expected) { return } if !AddrInList(observed, listen) { // probably a nat log.Warningf(natWarning, observed, listen) } }