block local ips and service worker; util function to resolve arbitrary 'host-like' string, unit testing

This commit is contained in:
Egor Aristov 2025-02-19 12:41:08 +03:00
parent cd4b160b4d
commit 48e5d7b3a2

View File

@ -251,7 +251,7 @@ func (e *PwExtractor) allowHost(rawUrl string) (bool, error) {
deny := ip.IsPrivate() || ip.IsLoopback() || ip.IsUnspecified() || ip.IsLinkLocalUnicast() || ip.IsMulticast() deny := ip.IsPrivate() || ip.IsLoopback() || ip.IsUnspecified() || ip.IsLinkLocalUnicast() || ip.IsMulticast()
deny = deny || e.proxyIP.Equal(ip) deny = deny || e.proxyIP.Equal(ip)
if deny { if deny {
log.Debugf("Banned address: %s", rawUrl) log.Warnf("Banned address: %s", rawUrl)
return false, nil return false, nil
} }
} }