chore: cleanup natTable's api

This commit is contained in:
wwqgtxx
2023-02-18 13:16:07 +08:00
parent 59cd89a9c9
commit fc50392ec7
24 changed files with 47 additions and 85 deletions

View File

@ -2,7 +2,6 @@ package tunnel
import (
"errors"
"github.com/Dreamacro/clash/log"
"net"
"net/netip"
"time"
@ -10,6 +9,7 @@ import (
N "github.com/Dreamacro/clash/common/net"
"github.com/Dreamacro/clash/common/pool"
C "github.com/Dreamacro/clash/constant"
"github.com/Dreamacro/clash/log"
)
func handleUDPToRemote(packet C.UDPPacket, pc C.PacketConn, metadata *C.Metadata) error {

View File

@ -82,6 +82,11 @@ func UDPIn() chan<- C.PacketAdapter {
return udpQueue
}
// NatTable return nat table
func NatTable() C.NatTable {
return natTable
}
// Rules return all rules
func Rules() []C.Rule {
return rules
@ -338,8 +343,6 @@ func handleUDPConn(packet C.PacketAdapter) {
oAddr := metadata.DstIP
natTable.Set(key, pc)
packet.SetNatTable(natTable)
packet.SetUdpInChan(udpQueue)
go handleUDPToLocal(packet, pc, key, oAddr, fAddr)