From 203248425a752e8f893c0580cfd5534e9bb6c358 Mon Sep 17 00:00:00 2001 From: Leo Balduf Date: Wed, 28 Sep 2016 03:10:52 -0400 Subject: [PATCH] http: fix IPv4 addresses not 4 bytes long Fixes #230 --- frontend/http/parser.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/http/parser.go b/frontend/http/parser.go index d873f40..33a499d 100644 --- a/frontend/http/parser.go +++ b/frontend/http/parser.go @@ -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 }