mirror of
https://github.com/sot-tech/mochi.git
synced 2026-06-15 17:11:55 -07:00
Merge pull request #236 from mrd0ll4r/sanitation-hook
http: fix IPv4 addresses not 4 bytes long
This commit is contained in:
@@ -79,6 +79,11 @@ func ParseAnnounce(r *http.Request, realIPHeader string, allowIPSpoofing bool) (
|
||||
return nil, bittorrent.ClientError("failed to parse peer IP address")
|
||||
}
|
||||
|
||||
// Sanitize IPv4 addresses to 4 bytes.
|
||||
if ip := request.Peer.IP.To4(); ip != nil {
|
||||
request.Peer.IP = ip
|
||||
}
|
||||
|
||||
return request, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user