From 091038d2c7e14ab6bb893b5af0fa1ab64db30c40 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Sat, 31 Aug 2024 14:48:53 -0400 Subject: [PATCH] up --- tunnel/addr.go | 3 ++- tunnel/tcp.go | 4 ++-- tunnel/udp.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tunnel/addr.go b/tunnel/addr.go index 802bd6d4..1f5ec5d0 100644 --- a/tunnel/addr.go +++ b/tunnel/addr.go @@ -32,7 +32,8 @@ func parseAddrString(s string) (netip.Addr, uint16) { return ap.Addr(), ap.Port() } -func parseAddr(addr tcpip.Address) netip.Addr { +// parseTCPIPAddress parses tcpip.Address to netip.Addr. +func parseTCPIPAddress(addr tcpip.Address) netip.Addr { ip, _ := netip.AddrFromSlice(addr.AsSlice()) return ip } diff --git a/tunnel/tcp.go b/tunnel/tcp.go index c8135c33..45af37cb 100644 --- a/tunnel/tcp.go +++ b/tunnel/tcp.go @@ -20,9 +20,9 @@ func (t *Tunnel) handleTCPConn(originConn adapter.TCPConn) { id := originConn.ID() metadata := &M.Metadata{ Network: M.TCP, - SrcIP: parseAddr(id.RemoteAddress), + SrcIP: parseTCPIPAddress(id.RemoteAddress), SrcPort: id.RemotePort, - DstIP: parseAddr(id.LocalAddress), + DstIP: parseTCPIPAddress(id.LocalAddress), DstPort: id.LocalPort, } diff --git a/tunnel/udp.go b/tunnel/udp.go index e4f0acfe..667a92bf 100644 --- a/tunnel/udp.go +++ b/tunnel/udp.go @@ -20,9 +20,9 @@ func (t *Tunnel) handleUDPConn(uc adapter.UDPConn) { id := uc.ID() metadata := &M.Metadata{ Network: M.UDP, - SrcIP: parseAddr(id.RemoteAddress), + SrcIP: parseTCPIPAddress(id.RemoteAddress), SrcPort: id.RemotePort, - DstIP: parseAddr(id.LocalAddress), + DstIP: parseTCPIPAddress(id.LocalAddress), DstPort: id.LocalPort, }