Skip to content

Commit

Permalink
Fix: should check originDst is nil (#2797)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kr328 authored Jun 18, 2023
1 parent 31fe77e commit 295b0da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions adapter/inbound/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ func NewHTTP(target socks5.Addr, source net.Addr, originTarget net.Addr, conn ne
metadata.SrcIP = ip
metadata.SrcPort = port
}
if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil {
metadata.OriginDst = addrPort
if originTarget != nil {
if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil {
metadata.OriginDst = addrPort
}
}
return context.NewConnContext(conn, metadata)
}
6 changes: 4 additions & 2 deletions adapter/inbound/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ func NewPacket(target socks5.Addr, originTarget net.Addr, packet C.UDPPacket, so
metadata.SrcIP = ip
metadata.SrcPort = port
}
if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil {
metadata.OriginDst = addrPort
if originTarget != nil {
if addrPort, err := netip.ParseAddrPort(originTarget.String()); err == nil {
metadata.OriginDst = addrPort
}
}
return &PacketAdapter{
UDPPacket: packet,
Expand Down

0 comments on commit 295b0da

Please sign in to comment.