Files
.github
cmd
docs
pkg
acl
engine.go
engine_test.go
entry.go
entry_test.go
ip.go
auth
congestion
core
http
obfs
relay
socks5
tproxy
transport
tun
utils
.gitignore
ACL.md
ACL.zh.md
CHANGELOG.md
Docker.md
Docker.zh.md
Dockerfile
LICENSE.md
README.md
README.zh.md
docker-compose.yaml
go.mod
go.sum
hysteria-dev/pkg/acl/ip.go
2021-04-19 00:20:39 -07:00

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
}