mirror of
https://github.com/LBRYFoundation/tracker.git
synced 2025-08-23 17:47:29 +00:00
parent
404e7f5821
commit
5866d96cb0
2 changed files with 8 additions and 2 deletions
|
@ -128,10 +128,15 @@ func (t *Frontend) ListenAndServe() error {
|
||||||
defer t.wg.Done()
|
defer t.wg.Done()
|
||||||
defer pool.Put(buffer)
|
defer pool.Put(buffer)
|
||||||
|
|
||||||
|
if ip := addr.IP.To4(); ip != nil {
|
||||||
|
addr.IP = ip
|
||||||
|
}
|
||||||
|
|
||||||
// Handle the request.
|
// Handle the request.
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
action, err := t.handleRequest(
|
action, err := t.handleRequest(
|
||||||
Request{buffer[:n], addr.IP},
|
// Make sure the IP is copied, not referenced.
|
||||||
|
Request{buffer[:n], append([]byte{}, addr.IP...)},
|
||||||
ResponseWriter{t.socket, addr},
|
ResponseWriter{t.socket, addr},
|
||||||
)
|
)
|
||||||
recordResponseDuration(action, err, time.Since(start))
|
recordResponseDuration(action, err, time.Since(start))
|
||||||
|
|
|
@ -80,7 +80,8 @@ func ParseAnnounce(r Request, allowIPSpoofing, v6 bool) (*bittorrent.AnnounceReq
|
||||||
ip := r.IP
|
ip := r.IP
|
||||||
ipbytes := r.Packet[84:ipEnd]
|
ipbytes := r.Packet[84:ipEnd]
|
||||||
if allowIPSpoofing {
|
if allowIPSpoofing {
|
||||||
ip = net.IP(ipbytes)
|
// Make sure the bytes are copied to a new slice.
|
||||||
|
copy(ip, net.IP(ipbytes))
|
||||||
}
|
}
|
||||||
if !allowIPSpoofing && r.IP == nil {
|
if !allowIPSpoofing && r.IP == nil {
|
||||||
// We have no IP address to fallback on.
|
// We have no IP address to fallback on.
|
||||||
|
|
Loading…
Add table
Reference in a new issue