mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-10-05 23:33:41 +00:00
TUN inbound: Log the outbound interface's forwarding once; Tweak messages
Windows turns forwarding on and off a few times while Mobile Hotspot starts, so the error is logged when forwarding comes up, not on every change, and turning weak host send off is logged once per IP version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6b0f06fb2b
commit
b71975abed
@@ -28,7 +28,7 @@ type outboundGuard struct {
|
||||
families []winipcfg.AddressFamily
|
||||
luid winipcfg.LUID // of the interface last checked
|
||||
turnedOff []winipcfg.AddressFamily // where weak host send was turned off on it
|
||||
reported string // the forwarding problem last logged
|
||||
reported string // the forwarding problem last seen
|
||||
stopped bool
|
||||
}
|
||||
|
||||
@@ -71,23 +71,24 @@ func (g *outboundGuard) check() string {
|
||||
}
|
||||
if !slices.Contains(g.turnedOff, family) {
|
||||
g.turnedOff = append(g.turnedOff, family)
|
||||
errors.LogInfo(context.Background(), "[tun] weak host send turned off for ", familyName(family), " on ", name, " while the TUN runs, as Windows would ignore autoOutboundsInterface")
|
||||
}
|
||||
errors.LogInfo(context.Background(), "[tun] weak host send turned off for ", familyName(family), " on ", name, " while the TUN runs, as Windows would ignore autoOutboundsInterface")
|
||||
}
|
||||
if len(forwarding) > 0 {
|
||||
return "forwarding is on for " + strings.Join(forwarding, " and ") + " on " + name + ", as Mobile Hotspot and Internet Connection Sharing turn it on, so Windows ignores autoOutboundsInterface there, and Xray's own connections go into the TUN and stall"
|
||||
return "forwarding is on for " + strings.Join(forwarding, " and ") + " on " + name + " (Mobile Hotspot and Internet Connection Sharing turn it on), so Windows ignores autoOutboundsInterface there, and Xray's own connections go into the TUN and stall"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// recheck is check for a running TUN, which logs a forwarding problem once.
|
||||
// recheck is check for a running TUN, which logs a forwarding problem when it
|
||||
// comes up. (Windows may turn forwarding on and off a few times meanwhile.)
|
||||
func (g *outboundGuard) recheck() {
|
||||
problem := g.check()
|
||||
g.Lock()
|
||||
changed := problem != g.reported
|
||||
cameUp := problem != "" && g.reported == ""
|
||||
g.reported = problem
|
||||
g.Unlock()
|
||||
if changed && problem != "" {
|
||||
if cameUp {
|
||||
errors.LogError(context.Background(), "[tun] ", problem)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user