From c28690bfc9281eb97c7d341fbfe60a948cb5ffe1 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Thu, 11 Feb 2021 13:55:53 +0800 Subject: [PATCH] Fix: deprecate metadata.Valid method --- constant/metadata.go | 4 ---- tunnel/tcp.go | 4 ---- tunnel/udp.go | 6 +----- 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/constant/metadata.go b/constant/metadata.go index c0fe485..6399a41 100755 --- a/constant/metadata.go +++ b/constant/metadata.go @@ -87,7 +87,3 @@ func (m *Metadata) Network() string { func (m *Metadata) String() string { return m.DestinationAddress() } - -func (m *Metadata) Valid() bool { - return m.SrcIP != nil && m.DstIP != nil -} diff --git a/tunnel/tcp.go b/tunnel/tcp.go index 80e9499..a1f7aff 100755 --- a/tunnel/tcp.go +++ b/tunnel/tcp.go @@ -34,10 +34,6 @@ func handleTCP(localConn core.TCPConn) { DstIP: net.IP(id.LocalAddress), DstPort: id.LocalPort, } - if !metadata.Valid() { - log.Warnf("[Metadata] not valid: %#v", metadata) - return - } targetConn, err := proxy.Dial(metadata) if err != nil { diff --git a/tunnel/udp.go b/tunnel/udp.go index f54458b..d73a2f5 100755 --- a/tunnel/udp.go +++ b/tunnel/udp.go @@ -39,13 +39,9 @@ func handleUDP(packet core.UDPPacket) { DstIP: net.IP(id.LocalAddress), DstPort: id.LocalPort, } - if !metadata.Valid() { - log.Warnf("[Metadata] not valid: %#v", metadata) - return - } generateNATKey := func(m *M.Metadata) string { - return m.SourceAddress() /* Full Cone NAT Key */ + return m.SourceAddress() /* as Full Cone NAT Key */ } key := generateNATKey(metadata)