From 14f4bcaf29f3f7c60d341ca50bc9d3490d96e918 Mon Sep 17 00:00:00 2001 From: patterniha <71074308+patterniha@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:20:31 +0330 Subject: [PATCH] TUN inbound: Warn about forwarding on a new outbound interface too; Log failed restores of weak host send As asked in review: switching between two interfaces with forwarding on now warns about the new one, and an IPInterface failure while restoring weak host send is logged, with the interface's name, instead of ignored. Co-Authored-By: Claude Opus 5.5 --- proxy/tun/tun_windows_outbound.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/proxy/tun/tun_windows_outbound.go b/proxy/tun/tun_windows_outbound.go index 3bc347da9..e5418dbc7 100644 --- a/proxy/tun/tun_windows_outbound.go +++ b/proxy/tun/tun_windows_outbound.go @@ -27,6 +27,7 @@ type outboundGuard struct { sync.Mutex families []winipcfg.AddressFamily luid winipcfg.LUID // of the interface last checked + name string // of that interface turnedOff []winipcfg.AddressFamily // where weak host send was turned off on it forwarding bool // whether forwarding was on there stopped bool @@ -48,10 +49,10 @@ func (g *outboundGuard) check() { } if luid != g.luid { g.restoreLocked() - g.luid = luid + g.luid, g.name = luid, name + g.forwarding = false // to warn about the new interface as well } if luid == 0 { - g.forwarding = false return } var forwarding []string @@ -92,10 +93,12 @@ func (g *outboundGuard) restore() { func (g *outboundGuard) restoreLocked() { for _, family := range g.turnedOff { - if row, err := g.luid.IPInterface(family); err == nil { - if err := setWeakHostSend(row, true); err != nil { - errors.LogWarningInner(context.Background(), err, "[tun] unable to turn weak host send on again for ", familyName(family)) - } + row, err := g.luid.IPInterface(family) + if err == nil { + err = setWeakHostSend(row, true) + } + if err != nil { + errors.LogWarningInner(context.Background(), err, "[tun] unable to turn weak host send on again for ", familyName(family), " on ", g.name) } } g.turnedOff = nil