mihomo/adapter/inbound/auth.go

28 lines
476 B
Go
Raw Normal View History

2023-10-10 19:43:26 +08:00
package inbound
import (
"net"
"net/netip"
)
var skipAuthPrefixes []netip.Prefix
func SetSkipAuthPrefixes(prefixes []netip.Prefix) {
skipAuthPrefixes = prefixes
}
func SkipAuthPrefixes() []netip.Prefix {
return skipAuthPrefixes
}
func SkipAuthRemoteAddr(addr net.Addr) bool {
2023-10-11 18:17:39 +08:00
if addrPort := parseAddr(addr); addrPort.IsValid() {
2023-10-10 19:43:26 +08:00
for _, prefix := range skipAuthPrefixes {
2023-10-11 18:17:39 +08:00
if prefix.Contains(addrPort.Addr().Unmap()) {
2023-10-10 19:43:26 +08:00
return true
}
}
}
return false
}