1
0

Fix: should check originDst is nil (#2797)

This commit is contained in:
Kr328 2023-06-18 11:16:40 +08:00 committed by GitHub
parent 31fe77ee69
commit 295b0da0e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -18,8 +18,10 @@ func NewHTTP(target socks5.Addr, source net.Addr, originTarget net.Addr, conn ne
metadata.SrcIP = ip metadata.SrcIP = ip
metadata.SrcPort = port metadata.SrcPort = port
} }
if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { if originTarget != nil {
metadata.OriginDst = addrPort if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil {
metadata.OriginDst = addrPort
}
} }
return context.NewConnContext(conn, metadata) return context.NewConnContext(conn, metadata)
} }

View File

@ -28,8 +28,10 @@ func NewPacket(target socks5.Addr, originTarget net.Addr, packet C.UDPPacket, so
metadata.SrcIP = ip metadata.SrcIP = ip
metadata.SrcPort = port metadata.SrcPort = port
} }
if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil { if originTarget != nil {
metadata.OriginDst = addrPort if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil {
metadata.OriginDst = addrPort
}
} }
return &PacketAdapter{ return &PacketAdapter{
UDPPacket: packet, UDPPacket: packet,