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