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 <noreply@anthropic.com>
This commit is contained in:
patterniha
2026-10-05 18:20:31 +03:30
co-authored by Claude Opus 5.5
parent 30a78f1563
commit 14f4bcaf29
+9 -6
View File
@@ -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