diff --git a/zcash/address_book.go b/zcash/address_book.go index d78c740..794c2b1 100644 --- a/zcash/address_book.go +++ b/zcash/address_book.go @@ -224,7 +224,7 @@ func (bk *AddressBook) waitForAddresses(n int, done chan struct{}) { // GetAddressList returns a slice of n valid addresses in random order. // If there aren't enough known addresses, it returns as many as we have. -func (bk *AddressBook) shuffleAddressList(n int, v6 bool) []net.IP { +func (bk *AddressBook) shuffleAddressList(n int, v6 bool, defaultPort string) []net.IP { bk.addrState.RLock() defer bk.addrState.RUnlock() @@ -246,6 +246,13 @@ func (bk *AddressBook) shuffleAddressList(n int, v6 bool) []net.IP { continue } + if strconv.Itoa(int(v.netaddr.Port)) != defaultPort { + // The DNS seeder is only able to return IP addresses, and it can't report + // ports. For this reason, we can only return addresses that are using + // the standard port. + continue + } + resp = append(resp, v.netaddr.IP) } diff --git a/zcash/client.go b/zcash/client.go index 718e665..a5db624 100644 --- a/zcash/client.go +++ b/zcash/client.go @@ -543,12 +543,12 @@ func (s *Seeder) Ready() bool { // Addresses returns a slice of n IPv4 addresses or as many as we have if it's less than that. func (s *Seeder) Addresses(n int) []net.IP { - return s.addrBook.shuffleAddressList(n, false) + return s.addrBook.shuffleAddressList(n, false, s.GetNetworkDefaultPort()) } // AddressesV6 returns a slice of n IPv6 addresses or as many as we have if it's less than that. func (s *Seeder) AddressesV6(n int) []net.IP { - return s.addrBook.shuffleAddressList(n, true) + return s.addrBook.shuffleAddressList(n, true, s.GetNetworkDefaultPort()) } // GetPeerCount returns how many valid peers we know about.