Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu committed Aug 31, 2024
1 parent 31cb082 commit 091038d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tunnel/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions tunnel/tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down
4 changes: 2 additions & 2 deletions tunnel/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down

0 comments on commit 091038d

Please sign in to comment.