feat(xray): accept the TUN WFP leak ports of xray-core 26.10.31

xray-core 26.10.31 (#7288) widened a TUN inbound's
autoSystemWfpBlockLeak: "dns" now also blocks DNS over TLS/QUIC (port
853), "windnsclient" covers only Windows' DNS Client service, and any
"tcp/<port>" or "udp/<port>" keeps that port inside the TUN. Anything
else, such as "tcp/0" or "icmp/1", stops the core at startup.

The form offers windnsclient and takes typed port values, the hint
explains them in all 14 locales, and the inbound and template save
paths run the core's own ExpandWfpBlockLeak so a value it refuses is
refused at save instead of taking every inbound down.
This commit is contained in:
MHSanaei
2026-11-01 14:56:13 +01:00
parent ba27b74be8
commit 87749c1ee4
21 changed files with 83 additions and 17 deletions
@@ -1,6 +1,7 @@
package service
import (
"strings"
"testing"
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
@@ -88,3 +89,30 @@ func TestInboundCanHostFallbacks_StaysTcpOnly(t *testing.T) {
t.Errorf("inboundCanHostFallbacks(nil) = true, want false")
}
}
// xray-core 26.10.31 (#7288) refuses an unknown autoSystemWfpBlockLeak value when the core starts.
func TestAddInboundRefusesTunWfpBlockLeakTheCoreRefuses(t *testing.T) {
tests := []struct{ name, leaks, want string }{
{"port zero", `["tcp/0"]`, "unknown autoSystemWfpBlockLeak value: tcp/0"},
{"unknown protocol", `["icmp/1"]`, "unknown autoSystemWfpBlockLeak value: icmp/1"},
{"named values and ports", `["DNS","windnsclient","misconfigtun","udp/853","tcp/7215"]`, ""},
}
for i, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
setupBulkDB(t)
_, _, err := (&InboundService{}).AddInbound(&model.Inbound{
Enable: true, Port: 18520 + i, Protocol: model.Protocol("tun"),
Settings: `{"name":"xray0","autoSystemWfpBlockLeak":` + tc.leaks + `}`,
})
if tc.want == "" {
if err != nil {
t.Fatalf("AddInbound = %v, want values the core accepts saved", err)
}
return
}
if err == nil || !strings.Contains(err.Error(), tc.want) {
t.Fatalf("AddInbound = %v, want one containing %q", err, tc.want)
}
})
}
}