feat(xray): update xray-core to v26.10.21 and adapt panel

Bump xtls/xray-core to 1b1647cd9ddf (v26.10.21) and move the three
binary pins (DockerInit.sh, both release.yml fetches) in lockstep. The
v26.10.10 release was pulled upstream, so the old pins already 404.

XDRIVE (#7182): the core now runs XDRIVE only for VLESS inside VLESS
encryption, with no flow, and an outbound only over Mux; it refuses the
whole config otherwise. The panel offers XDRIVE only for VLESS, refuses
to save an inbound without decryption, never emits a client flow on an
XDRIVE stream (config, JSON subscription, forms), and turns Mux on when
an outbound picks XDRIVE. An inbound or template outbound stored before
the upgrade that the core would refuse is left out of the generated
config with a warning, so it no longer stops every other inbound. The
service "Google Drive" is now "google-drive" (old name read as a
deprecated alias); saves, the schema and both form adapters store the
new name. XDRIVE and MASQUE gain a client xmux; both schemas keep it
instead of stripping it on an inbound save.

Lua scripts (#7124, #7136): the core refuses a routing script beside
rules or domainStrategy, and a dns script beside the fallback/parallel
switches or a domain-scoped server. The panel always keeps its api
routing rule, so a template save now refuses any routing script and a
dns script in a refused combination, and a stored one is dropped from
the generated config so the core still starts. Noise masks gain a Lua
script that the loader compiles inside Build: the in-process build
(template save check, hot add) now resolves a relative script the way
the xray child does, beside the xray binary, instead of failing it. The
mask editor gets a Script field that replaces the noise list.

XDNS (#7140): a resolver takes https:// DoH addresses with worker,
tlsConfig and quicConfig. The mask editor registered only addrs, so a
save dropped the rest; it now edits all four.

Finalmask filter (#7206): a new TCP/UDP mask screens an inbound's source
IPs. The inbound mask editor offers it with its allow and block lists;
it is a no-op on a dialer and an older client core refuses the type, so
the share link and JSON subscription drop it like the Go link already
does.
This commit is contained in:
MHSanaei
2026-10-22 17:10:11 +02:00
parent a8d0700bf2
commit 61b129d5b3
43 changed files with 1055 additions and 95 deletions
+101
View File
@@ -184,6 +184,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
// pre-26.9.9 quicParams.udpHop, which the core ignores, or a udphop not last, which it cannot dial.
xrayConfig.OutboundConfigs = healOutboundStreams(xrayConfig.OutboundConfigs,
liftXhttpSessionIDKeys, upgradeStreamLegacyXdns, upgradeStreamLegacyUDPHop, normalizeStreamUDPHop)
xrayConfig.OutboundConfigs = dropXDriveOutboundsRefusedByCore(xrayConfig.OutboundConfigs)
// Bridge amneziawg outbounds before anything else reads OutboundConfigs;
// the core has no amneziawg proxy and would reject the raw entry.
if err := transformAmneziaWGOutbounds(xrayConfig); err != nil {
@@ -410,6 +411,7 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
inboundConfig := inbound.GenXrayInboundConfig()
xrayConfig.InboundConfigs = append(xrayConfig.InboundConfigs, *inboundConfig)
}
xrayConfig.InboundConfigs = dropInboundsRefusedByXDrive(xrayConfig.InboundConfigs)
// Merge subscription-derived outbounds (if any) into the final outbounds array.
// These are additive: each subscription is placed before or after the template
@@ -471,6 +473,8 @@ func (s *XrayService) GetXrayConfig() (*xray.Config, error) {
injectNodeEgresses(xrayConfig, nodes)
}
xrayConfig.RouterConfig = dropRefusedScript(xrayConfig.RouterConfig, "routing", routingScriptRefused)
xrayConfig.DNSConfig = dropRefusedScript(xrayConfig.DNSConfig, "dns", dnsScriptRefused)
return xrayConfig, nil
}
@@ -1708,6 +1712,103 @@ func healOutboundStreams(raw json_util.RawMessage, heals ...func(stream map[stri
return raw
}
// dropInboundsRefusedByXDrive keeps out an XDRIVE inbound stored before xray-core 26.10.17 made it
// VLESS-encryption only (#7182); the core would refuse the whole config and stop every inbound.
func dropInboundsRefusedByXDrive(inbounds []xray.InboundConfig) []xray.InboundConfig {
return slices.DeleteFunc(inbounds, func(ib xray.InboundConfig) bool {
err := validateXDriveInbound(ib.Protocol, string(ib.Settings), string(ib.StreamSettings))
if err != nil {
logger.Warningf("Inbound %q: not started, %v", ib.Tag, err)
}
return err != nil
})
}
// dropXDriveOutboundsRefusedByCore keeps out an XDRIVE outbound stored before xray-core 26.10.17
// required VLESS encryption and mux on it (#7182), which would stop the whole core at startup.
func dropXDriveOutboundsRefusedByCore(raw json_util.RawMessage) json_util.RawMessage {
var outbounds []json.RawMessage
if len(raw) == 0 || json.Unmarshal(raw, &outbounds) != nil {
return raw
}
kept := make([]json.RawMessage, 0, len(outbounds))
for _, ob := range outbounds {
var probe struct {
Tag string `json:"tag"`
StreamSettings struct {
Network string `json:"network"`
} `json:"streamSettings"`
}
if json.Unmarshal(ob, &probe) == nil && probe.StreamSettings.Network == "xdrive" {
if err := xray.ValidateOutboundConfig(ob); err != nil {
logger.Warningf("Outbound %q: not started, xray-core refuses it: %v", probe.Tag, err)
continue
}
}
kept = append(kept, ob)
}
if len(kept) == len(outbounds) {
return raw
}
if rewritten, err := json.Marshal(kept); err == nil {
return rewritten
}
return raw
}
// routingScriptRefused mirrors xray-core 26.10.17's RouterConfig.Build (#7136): a routing
// "script" replaces rules and domainStrategy, so the core refuses a config holding both.
func routingScriptRefused(routing map[string]any) bool {
script, _ := routing["script"].(string)
rules, _ := routing["rules"].([]any)
return script != "" && (routing["domainStrategy"] != nil || len(rules) > 0)
}
// dnsScriptRefused mirrors xray-core 26.10.17's DNSConfig.Build (#7136): a dns "script" refuses the
// fallback and parallel switches, and any server scoped by domains, skipFallback or finalQuery.
func dnsScriptRefused(dns map[string]any) bool {
if script, _ := dns["script"].(string); script == "" {
return false
}
for _, key := range []string{"disableFallback", "disableFallbackIfMatch", "enableParallelQuery"} {
if on, _ := dns[key].(bool); on {
return true
}
}
servers, _ := dns["servers"].([]any)
return slices.ContainsFunc(servers, func(entry any) bool {
server, _ := entry.(map[string]any)
skipFallback, _ := server["skipFallback"].(bool)
finalQuery, _ := server["finalQuery"].(bool)
return hasDNSDomains(server["domains"]) || skipFallback || finalQuery
})
}
func hasDNSDomains(domains any) bool {
switch v := domains.(type) {
case []any:
return len(v) > 0
case string:
return v != ""
}
return false
}
// dropRefusedScript drops a section's Lua "script" the core would refuse, logging why: the
// panel's own rules and DNS settings stay, since its stats path depends on the api rule.
func dropRefusedScript(raw json_util.RawMessage, section string, refused func(map[string]any) bool) json_util.RawMessage {
var parsed map[string]any
if len(raw) == 0 || json.Unmarshal(raw, &parsed) != nil || !refused(parsed) {
return raw
}
logger.Warningf("%s: ignoring \"script\" %v, xray-core refuses it beside this %s section's other settings", section, parsed["script"], section)
delete(parsed, "script")
if rewritten, err := json.Marshal(parsed); err == nil {
return rewritten
}
return raw
}
func upgradeStreamLegacyXdns(stream map[string]any) bool {
return maskcompat.UpgradeLegacyXdns(stream["finalmask"])
}