(tested) fix redis to pass tests

* delete info hash count key from redis (replaced with SCARD on infohash set)
* add GC test
* add peer.Addr() functio to always return unwrapped address if 4to6 appear
This commit is contained in:
Lawrence, Rendall
2022-04-15 01:29:57 +03:00
parent 5c2471ca9b
commit 397e106396
17 changed files with 287 additions and 261 deletions
+1 -1
View File
@@ -297,7 +297,7 @@ func (f *Frontend) announceRoute(w http.ResponseWriter, r *http.Request, ps http
WriteError(w, err)
return
}
addr = req.AddrPort.Addr()
addr = req.Addr()
ctx := injectRouteParamsToContext(context.Background(), ps)
ctx, resp, err := f.logic.HandleAnnounce(ctx, req)
+1 -1
View File
@@ -178,5 +178,5 @@ func requestedIP(r *http.Request, p bittorrent.Params, opts ParseOptions) (netip
}
addrPort, err := netip.ParseAddrPort(r.RemoteAddr)
return addrPort.Addr(), false, err
return addrPort.Addr().Unmap(), false, err
}
+4 -4
View File
@@ -98,17 +98,17 @@ func WriteScrapeResponse(w http.ResponseWriter, resp *bittorrent.ScrapeResponse)
}
func compact4(peer bittorrent.Peer) (buf []byte) {
ip := peer.AddrPort.Addr().As4()
ip := peer.Addr().As4()
buf = append(buf, ip[:]...)
port := peer.AddrPort.Port()
port := peer.Port()
buf = append(buf, byte(port>>8), byte(port&0xff))
return
}
func compact6(peer bittorrent.Peer) (buf []byte) {
ip := peer.AddrPort.Addr().As16()
ip := peer.Addr().As16()
buf = append(buf, ip[:]...)
port := peer.AddrPort.Port()
port := peer.Port()
buf = append(buf, byte(port>>8), byte(port&0xff))
return
}