mirror of
https://github.com/sot-tech/mochi.git
synced 2026-07-27 01:48:09 -07:00
(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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user