fix: handle metadata when dst is ip:port
This commit is contained in:
parent
22c1e05e1c
commit
c7bc67e44c
1 changed files with 8 additions and 1 deletions
|
@ -2,6 +2,7 @@ package inbound
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"net/netip"
|
||||||
|
|
||||||
C "github.com/Dreamacro/clash/constant"
|
C "github.com/Dreamacro/clash/constant"
|
||||||
"github.com/Dreamacro/clash/context"
|
"github.com/Dreamacro/clash/context"
|
||||||
|
@ -36,7 +37,13 @@ func NewInner(conn net.Conn, dst string, host string) *context.ConnContext {
|
||||||
if h, port, err := net.SplitHostPort(dst); err == nil {
|
if h, port, err := net.SplitHostPort(dst); err == nil {
|
||||||
metadata.DstPort = port
|
metadata.DstPort = port
|
||||||
if host == "" {
|
if host == "" {
|
||||||
metadata.Host = h
|
if ip, err := netip.ParseAddr(h); err == nil {
|
||||||
|
metadata.DstIP = ip
|
||||||
|
metadata.AddrType = C.AtypIPv4
|
||||||
|
if ip.Is6() {
|
||||||
|
metadata.AddrType = C.AtypIPv6
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue