This commit is contained in:
leicheng6563 2018-07-12 04:06:01 +00:00 committed by GitHub
commit c544716c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
rule.go
View File

@ -70,7 +70,18 @@ func (rd *RuleDialer) NextDialer(dstAddr string) proxy.Dialer {
}
// find ip
if ip := net.ParseIP(host); ip != nil {
ip := net.ParseIP(host)
if ip == nil {
ns, err := net.LookupHost(host)
if err == nil {
if (len(ns) > 0) {
ip = net.ParseIP(ns[0])
}
} else {
log.F("[rule] Invalid host: %s", host)
}
}
if ip != nil {
// check ip
if dialer, ok := rd.ipMap.Load(ip.String()); ok {
return dialer.(proxy.Dialer)