Browse Source

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.
mrchatam 8 hours ago
parent
commit
c54c28d92d
2 changed files with 40 additions and 2 deletions
  1. 1 2
      internal/sub/default.json
  2. 39 0
      internal/sub/default_json_test.go

+ 1 - 2
internal/sub/default.json

@@ -49,7 +49,6 @@
       "tag": "direct",
       "protocol": "freedom",
       "settings": {
-        "domainStrategy": "AsIs",
         "redirect": "",
         "noises": []
       }
@@ -89,4 +88,4 @@
     ]
   },
   "stats": {}
-}
+}

+ 39 - 0
internal/sub/default_json_test.go

@@ -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")
+	}
+}