feat: introduce a new robust approach to handle tproxy udp. (#389)
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/netip"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/Dreamacro/clash/component/dialer"
|
||||
@ -216,6 +217,10 @@ type UDPPacket interface {
|
||||
|
||||
// LocalAddr returns the source IP/Port of packet
|
||||
LocalAddr() net.Addr
|
||||
|
||||
SetNatTable(natTable NatTable)
|
||||
|
||||
SetUdpInChan(in chan<- PacketAdapter)
|
||||
}
|
||||
|
||||
type UDPPacketInAddr interface {
|
||||
@ -227,3 +232,23 @@ type PacketAdapter interface {
|
||||
UDPPacket
|
||||
Metadata() *Metadata
|
||||
}
|
||||
|
||||
type NatTable interface {
|
||||
Set(key string, e PacketConn)
|
||||
|
||||
Get(key string) PacketConn
|
||||
|
||||
GetOrCreateLock(key string) (*sync.Cond, bool)
|
||||
|
||||
Delete(key string)
|
||||
|
||||
GetLocalConn(lAddr, rAddr string) *net.UDPConn
|
||||
|
||||
AddLocalConn(lAddr, rAddr string, conn *net.UDPConn) bool
|
||||
|
||||
RangeLocalConn(lAddr string, f func(key, value any) bool)
|
||||
|
||||
GetOrCreateLockForLocalConn(lAddr, key string) (*sync.Cond, bool)
|
||||
|
||||
DeleteLocalConnMap(lAddr, key string)
|
||||
}
|
||||
|
Reference in New Issue
Block a user