filter peers using non-std ports (#17)
This commit is contained in:
parent
e9a2d22878
commit
88fc106ef3
|
@ -224,7 +224,7 @@ func (bk *AddressBook) waitForAddresses(n int, done chan struct{}) {
|
||||||
|
|
||||||
// GetAddressList returns a slice of n valid addresses in random order.
|
// 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.
|
// 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()
|
bk.addrState.RLock()
|
||||||
defer bk.addrState.RUnlock()
|
defer bk.addrState.RUnlock()
|
||||||
|
|
||||||
|
@ -246,6 +246,13 @@ func (bk *AddressBook) shuffleAddressList(n int, v6 bool) []net.IP {
|
||||||
continue
|
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)
|
resp = append(resp, v.netaddr.IP)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
// 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 {
|
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.
|
// 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 {
|
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.
|
// GetPeerCount returns how many valid peers we know about.
|
||||||
|
|
Loading…
Reference in New Issue