(tested) Refactor code

* merge 9d04e4c from https://github.com/jzelinskie/chihaya
* sanitize ip address on Scrape requests
* remove NewConnectionID and ValidConnectionID functions from production code
This commit is contained in:
Lawrence, Rendall
2022-04-21 21:57:18 +03:00
parent f9c72341c0
commit 3bc2276fb3
6 changed files with 22 additions and 18 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ func (ps *peerStore) shardIndex(infoHash bittorrent.InfoHash, addr netip.Addr) u
// half is dedicated to IPv4 swarms and the second half is dedicated to
// IPv6 swarms.
idx := binary.BigEndian.Uint32([]byte(infoHash[:4])) % (uint32(len(ps.shards)) / 2)
if addr.Is6() && !addr.Is4In6() {
if addr.Is6() {
idx += uint32(len(ps.shards) / 2)
}
return idx