[Fixed] Abnormal rule when host is ip addr
This commit is contained in:
parent
a732e1a603
commit
ae5a790510
1 changed files with 12 additions and 2 deletions
|
@ -26,10 +26,20 @@ func NewInner(conn net.Conn, dst string, host string) *context.ConnContext {
|
||||||
metadata.NetWork = C.TCP
|
metadata.NetWork = C.TCP
|
||||||
metadata.Type = C.INNER
|
metadata.Type = C.INNER
|
||||||
metadata.DNSMode = C.DNSMapping
|
metadata.DNSMode = C.DNSMapping
|
||||||
metadata.AddrType = C.AtypDomainName
|
|
||||||
metadata.Host = host
|
metadata.Host = host
|
||||||
if _, port, err := parseAddr(dst); err == nil {
|
metadata.AddrType = C.AtypDomainName
|
||||||
|
|
||||||
|
if ip, port, err := parseAddr(dst); err == nil {
|
||||||
metadata.DstPort = port
|
metadata.DstPort = port
|
||||||
|
if host == "" {
|
||||||
|
metadata.DstIP = ip
|
||||||
|
if ip.To4() == nil {
|
||||||
|
metadata.AddrType = C.AtypIPv6
|
||||||
|
} else {
|
||||||
|
metadata.AddrType = C.AtypIPv4
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return context.NewConnContext(conn, metadata)
|
return context.NewConnContext(conn, metadata)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue