fix(sub): drop legacy freedom.domainStrategy from JSON sub template (#6609)

The JSON-subscription template still set settings.domainStrategy on its freedom outbound, the placement #6515 moved off everywhere else, so xray-core migrated it to sockopt with a deprecation warning on every load. AsIs is the core default when the key is absent, so dropping it changes nothing else.

Fixes #6482.
This commit is contained in:
mrchatam
2026-09-26 22:43:39 +03:30
committed by GitHub
parent 5d41e65a3c
commit c54c28d92d
2 changed files with 40 additions and 2 deletions
+1 -2
View File
@@ -49,7 +49,6 @@
"tag": "direct",
"protocol": "freedom",
"settings": {
"domainStrategy": "AsIs",
"redirect": "",
"noises": []
}
@@ -89,4 +88,4 @@
]
},
"stats": {}
}
}
+39
View File
@@ -0,0 +1,39 @@
package sub
import (
"encoding/json"
"strings"
"testing"
)
// xray-core moves freedom settings.domainStrategy to sockopt with a warning on
// every load (#6482); the embed omits it and gets the AsIs default.
func TestDefaultJSON_FreedomOutboundHasNoLegacyDomainStrategy(t *testing.T) {
var cfg map[string]any
if err := json.Unmarshal([]byte(defaultJson), &cfg); err != nil {
t.Fatalf("unmarshal embedded default.json: %v", err)
}
outbounds, _ := cfg["outbounds"].([]any)
var sawFreedom bool
for _, raw := range outbounds {
ob, _ := raw.(map[string]any)
proto, _ := ob["protocol"].(string)
if !strings.EqualFold(proto, "freedom") {
continue
}
sawFreedom = true
settings, _ := ob["settings"].(map[string]any)
if _, ok := settings["domainStrategy"]; ok {
t.Fatalf("freedom outbound %q still has settings.domainStrategy=%v; use sockopt or omit (AsIs default)", ob["tag"], settings["domainStrategy"])
}
if _, ok := settings["targetStrategy"]; ok {
t.Fatalf("freedom outbound %q still has settings.targetStrategy", ob["tag"])
}
if _, ok := ob["targetStrategy"]; ok {
t.Fatalf("freedom outbound %q still has root targetStrategy", ob["tag"])
}
}
if !sawFreedom {
t.Fatal("embedded default.json has no freedom outbound to check")
}
}