mirror of
https://github.com/cmz0228/hysteria-dev.git
synced 2025-06-10 14:29:54 +00:00
28 lines
397 B
Go
28 lines
397 B
Go
package acl
|
|
|
|
import "net"
|
|
|
|
func parseIPZone(s string) (net.IP, string) {
|
|
s, zone := splitHostZone(s)
|
|
return net.ParseIP(s), zone
|
|
}
|
|
|
|
func splitHostZone(s string) (host, zone string) {
|
|
if i := last(s, '%'); i > 0 {
|
|
host, zone = s[:i], s[i+1:]
|
|
} else {
|
|
host = s
|
|
}
|
|
return
|
|
}
|
|
|
|
func last(s string, b byte) int {
|
|
i := len(s)
|
|
for i--; i >= 0; i-- {
|
|
if s[i] == b {
|
|
break
|
|
}
|
|
}
|
|
return i
|
|
}
|