refactor: New tun udpnat

This commit is contained in:
世界
2026-08-30 17:41:43 +08:00
parent a072f21978
commit 1f7d571017
25 changed files with 422 additions and 96 deletions
+9
View File
@@ -42,6 +42,9 @@ type Inbound struct {
logger log.ContextLogger
tunOptions tun.Options
udpTimeout time.Duration
udpMapping tun.NATMapping
udpFiltering tun.NATFiltering
udpNATMax uint32
dnsHijackAddress []netip.Addr
stack string
tunIf tun.Tun
@@ -230,6 +233,9 @@ func NewInbound(ctx context.Context, router adapter.Router, logger log.ContextLo
EXP_MultiPendingPackets: multiPendingPackets,
},
udpTimeout: udpTimeout,
udpMapping: tun.NATMapping(options.UDPMapping),
udpFiltering: tun.NATFiltering(options.UDPFiltering),
udpNATMax: options.UDPNATMax,
stack: options.Stack,
platformInterface: platformInterface,
platformOptions: common.PtrValueOrDefault(options.Platform),
@@ -448,6 +454,9 @@ func (t *Inbound) Start(stage adapter.StartStage) error {
TunOptions: t.tunOptions,
UDPTimeout: t.udpTimeout,
ICMPTimeout: C.ICMPTimeout,
UDPMapping: t.udpMapping,
UDPFiltering: t.udpFiltering,
UDPNATMax: t.udpNATMax,
Handler: t,
Logger: t.logger,
ForwarderBindInterface: C.IsDarwin,