(tested) Refactor code

* merge 9d04e4c from https://github.com/jzelinskie/chihaya
* sanitize ip address on Scrape requests
* remove NewConnectionID and ValidConnectionID functions from production code
This commit is contained in:
Lawrence, Rendall
2022-04-21 21:57:18 +03:00
parent f9c72341c0
commit 3bc2276fb3
6 changed files with 22 additions and 18 deletions

View File

@@ -46,6 +46,11 @@ func SanitizeScrape(r *ScrapeRequest, maxScrapeInfoHashes uint32) error {
r.InfoHashes = r.InfoHashes[:maxScrapeInfoHashes]
}
r.AddrPort = netip.AddrPortFrom(r.Addr(), r.Port())
if !r.Addr().IsValid() || r.Addr().IsUnspecified() {
return ErrInvalidIP
}
log.Debug("sanitized scrape", r, log.Fields{
"maxScrapeInfoHashes": maxScrapeInfoHashes,
})