Browse Source

Fix: deprecate metadata.Valid method

pull/76/head
xjasonlyu 4 years ago
parent
commit
c28690bfc9
  1. 4
      constant/metadata.go
  2. 4
      tunnel/tcp.go
  3. 6
      tunnel/udp.go

4
constant/metadata.go

@ -87,7 +87,3 @@ func (m *Metadata) Network() string {
func (m *Metadata) String() string { func (m *Metadata) String() string {
return m.DestinationAddress() return m.DestinationAddress()
} }
func (m *Metadata) Valid() bool {
return m.SrcIP != nil && m.DstIP != nil
}

4
tunnel/tcp.go

@ -34,10 +34,6 @@ func handleTCP(localConn core.TCPConn) {
DstIP: net.IP(id.LocalAddress), DstIP: net.IP(id.LocalAddress),
DstPort: id.LocalPort, DstPort: id.LocalPort,
} }
if !metadata.Valid() {
log.Warnf("[Metadata] not valid: %#v", metadata)
return
}
targetConn, err := proxy.Dial(metadata) targetConn, err := proxy.Dial(metadata)
if err != nil { if err != nil {

6
tunnel/udp.go

@ -39,13 +39,9 @@ func handleUDP(packet core.UDPPacket) {
DstIP: net.IP(id.LocalAddress), DstIP: net.IP(id.LocalAddress),
DstPort: id.LocalPort, DstPort: id.LocalPort,
} }
if !metadata.Valid() {
log.Warnf("[Metadata] not valid: %#v", metadata)
return
}
generateNATKey := func(m *M.Metadata) string { generateNATKey := func(m *M.Metadata) string {
return m.SourceAddress() /* Full Cone NAT Key */ return m.SourceAddress() /* as Full Cone NAT Key */
} }
key := generateNATKey(metadata) key := generateNATKey(metadata)

Loading…
Cancel
Save