[GH-ISSUE #6482] [Enhancement]: The Freedom Protocol strategy still creates the outdated freedom.domainStrategy parameter. #4374

Closed
opened 2026-10-31 20:39:12 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @jameszeroX on GitHub (Sep 12, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6482

Describe the bug

When Freedom Protocol Strategy is changed in the UI, 3x-ui generated the old Xray configuration format

How to reproduce the problem

Change the parameter in the 3x-ui settings - Xray Configs >> Basic >> Freedom Protocol Strategy

Expected behavior

"streamSettings": {
  "sockopt": {
    "domainStrategy": "UseIPv4"
  }
}

Actual behavior

{
  "protocol": "freedom",
  "settings": {
    "domainStrategy": "UseIPv4"
  }
}

Additional context

Xray-core's current configuration logic explicitly migrates freedom.domainStrategy to sockopt.domainStrategy with a warning:

WARNING - XRAY: infra/conf: The "freedom.domainStrategy" setting is deprecated and will be removed. For compatibility, its value has been automatically migrated to "sockopt.domainStrategy". Please update your config before removal

Therefore, it would be preferable for 3x-ui to write the new configuration format directly.

3x-ui version

Dev build 0a2cd789

Xray-core version

26.9.9

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 22

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @jameszeroX on GitHub (Sep 12, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6482 ### Describe the bug When **Freedom Protocol Strategy** is changed in the UI, 3x-ui generated the old Xray configuration format ### How to reproduce the problem Change the parameter in the 3x-ui settings - `Xray Configs` >> `Basic` >> `Freedom Protocol Strategy` ### Expected behavior ```json "streamSettings": { "sockopt": { "domainStrategy": "UseIPv4" } } ``` ### Actual behavior ```json { "protocol": "freedom", "settings": { "domainStrategy": "UseIPv4" } } ``` ### Additional context Xray-core's current configuration logic explicitly migrates `freedom.domainStrategy` to `sockopt.domainStrategy` with a warning: > WARNING - XRAY: infra/conf: The "freedom.domainStrategy" setting is deprecated and will be removed. For compatibility, its value has been automatically migrated to "sockopt.domainStrategy". Please update your config before removal Therefore, it would be preferable for 3x-ui to write the new configuration format directly. ### 3x-ui version Dev build 0a2cd789 ### Xray-core version 26.9.9 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 22 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:39:12 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Sep 12, 2026):

Your observation is correct — the panel does write the settings-level domainStrategy, and it does so deliberately for backward compatibility, so nothing is malfunctioning today. I'm treating this as a forward-compatibility cleanup (the key is deprecated and will eventually be removed) rather than a defect, and leaving it open.

What the code actually does

The Xray Configs → Basic → Freedom Protocol Strategy select reads and writes only the direct freedom outbound's settings.domainStrategy:

// frontend/src/pages/xray/basics/BasicsTab.tsx:196-204
tt.outbounds.push({
  protocol: 'freedom',
  tag: 'direct',
  settings: { domainStrategy: next },
});
// …
(ob.settings as Record<string, unknown>).domainStrategy = next;

and reads it back the same way (BasicsTab.tsx:112-116, defaulting to 'AsIs'). The shipped default template already carries it in that position, so the key is there before anyone touches the select:

// internal/web/service/config.json:31-41
"outbounds": [{
    "protocol": "freedom",
    "settings": {
      "domainStrategy": "AsIs",

Why it is written that way

This placement is an explicit compatibility decision, documented in the outbound adapter:

// frontend/src/lib/xray/outbound-form-adapter.ts:720-721
// The strategy is emitted under the legacy domainStrategy key: new cores
// fall back to it when targetStrategy is absent, old cores only know it.

That comment arrived with 258d8b73 "feat(frontend): add targetStrategy field to the outbound editor", whose body states it plainly: "Freedom settings additionally read the new settings-level targetStrategy with domainStrategy as fallback, mirroring the core, while still emitting the legacy domainStrategy key so configs keep working on older cores." The panel therefore reads either key (outbound-form-adapter.ts:309-310: asString(raw.targetStrategy) || asString(raw.domainStrategy)) but always writes the legacy one.

One thing to pin down before changing it

Your report and that commit name two different replacements. You quote the core migrating freedom.domainStrategy → sockopt.domainStrategy; 258d8b73 describes the core's replacement as a settings-level targetStrategy. I could not re-derive either from the Xray-core source in this environment (the dependency source is not available here and I cannot fetch it), so the warning text and its migration target are your evidence, not something I confirmed. Which of the two keys the core at v26.9.9 actually prefers decides the whole change, and reading infra/conf/freedom.go at that tag is the single check that settles it. For what it's worth, your Xray version matches exactly what the panel bundles — DockerInit.sh:35 pins .../releases/download/v26.9.9/Xray-linux-${ARCH}.zip — so the warning you quote would come from the bundled core.

Scope, for whoever picks this up

The deprecated key is written in five places, not one — including the template handed to clients:

frontend/src/pages/xray/basics/BasicsTab.tsx:199,204   Basics tab select (this report)
frontend/src/pages/xray/basics/constants.ts:67         ipv4Settings, used by RoutingBasic.tsx:188
frontend/src/lib/xray/outbound-form-adapter.ts:731     freedomToWire, Outbounds editor
internal/web/service/config.json:34                    shipped default xray template
internal/sub/default.json:52                           JSON-subscription template sent to clients

internal/database/db.go would also need a seeder to move the key in templates already saved in users' databases — normalizeFreedomFinalRules / hardenFreedomFinalRules (db.go:1829, db.go:1932) are the existing pattern for rewriting exactly this outbound. Note that internal/database/freedom_finalrules_migration_test.go:126-127 currently asserts settings["domainStrategy"] == "AsIs" survives that migration untouched; that is an untouched-neighbour assertion, not a statement of intent about the key's position, but it would need updating.

Two smaller notes from the same code path: BasicsTab.tsx:112-116 ignores a top-level targetStrategy, so the Basics select displays AsIs even when one is set via the Outbounds editor; and if the core does migrate into sockopt, it is worth checking what happens when sockopt.domainStrategy is already set explicitly there — the Basics tab writes into the same streamSettings.sockopt object for the Happy Eyeballs switch (BasicsTab.tsx:141-152).

I relabelled this from bug to enhancement; the title states your observation accurately, so I left it as is.

Verdict: Feature request

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5644444808 --> @github-actions[bot] commented on GitHub (Sep 12, 2026): Your observation is correct — the panel does write the settings-level `domainStrategy`, and it does so deliberately for backward compatibility, so nothing is malfunctioning today. I'm treating this as a forward-compatibility cleanup (the key is deprecated and will eventually be removed) rather than a defect, and leaving it open. ### What the code actually does The `Xray Configs` → `Basic` → `Freedom Protocol Strategy` select reads and writes only the `direct` freedom outbound's `settings.domainStrategy`: ```ts // frontend/src/pages/xray/basics/BasicsTab.tsx:196-204 tt.outbounds.push({ protocol: 'freedom', tag: 'direct', settings: { domainStrategy: next }, }); // … (ob.settings as Record<string, unknown>).domainStrategy = next; ``` and reads it back the same way (`BasicsTab.tsx:112-116`, defaulting to `'AsIs'`). The shipped default template already carries it in that position, so the key is there before anyone touches the select: ```json // internal/web/service/config.json:31-41 "outbounds": [{ "protocol": "freedom", "settings": { "domainStrategy": "AsIs", ``` ### Why it is written that way This placement is an explicit compatibility decision, documented in the outbound adapter: ```ts // frontend/src/lib/xray/outbound-form-adapter.ts:720-721 // The strategy is emitted under the legacy domainStrategy key: new cores // fall back to it when targetStrategy is absent, old cores only know it. ``` That comment arrived with `258d8b73` *"feat(frontend): add targetStrategy field to the outbound editor"*, whose body states it plainly: *"Freedom settings additionally read the new settings-level targetStrategy with domainStrategy as fallback, mirroring the core, while still emitting the legacy domainStrategy key so configs keep working on older cores."* The panel therefore **reads** either key (`outbound-form-adapter.ts:309-310`: `asString(raw.targetStrategy) || asString(raw.domainStrategy)`) but always **writes** the legacy one. ### One thing to pin down before changing it Your report and that commit name two different replacements. You quote the core migrating `freedom.domainStrategy` → `sockopt.domainStrategy`; `258d8b73` describes the core's replacement as a settings-level `targetStrategy`. I could not re-derive either from the Xray-core source in this environment (the dependency source is not available here and I cannot fetch it), so the warning text and its migration target are your evidence, not something I confirmed. Which of the two keys the core at v26.9.9 actually prefers decides the whole change, and reading `infra/conf/freedom.go` at that tag is the single check that settles it. For what it's worth, your Xray version matches exactly what the panel bundles — `DockerInit.sh:35` pins `.../releases/download/v26.9.9/Xray-linux-${ARCH}.zip` — so the warning you quote would come from the bundled core. ### Scope, for whoever picks this up The deprecated key is written in five places, not one — including the template handed to clients: ``` frontend/src/pages/xray/basics/BasicsTab.tsx:199,204 Basics tab select (this report) frontend/src/pages/xray/basics/constants.ts:67 ipv4Settings, used by RoutingBasic.tsx:188 frontend/src/lib/xray/outbound-form-adapter.ts:731 freedomToWire, Outbounds editor internal/web/service/config.json:34 shipped default xray template internal/sub/default.json:52 JSON-subscription template sent to clients ``` `internal/database/db.go` would also need a seeder to move the key in templates already saved in users' databases — `normalizeFreedomFinalRules` / `hardenFreedomFinalRules` (`db.go:1829`, `db.go:1932`) are the existing pattern for rewriting exactly this outbound. Note that `internal/database/freedom_finalrules_migration_test.go:126-127` currently asserts `settings["domainStrategy"] == "AsIs"` survives that migration untouched; that is an untouched-neighbour assertion, not a statement of intent about the key's position, but it would need updating. Two smaller notes from the same code path: `BasicsTab.tsx:112-116` ignores a top-level `targetStrategy`, so the Basics select displays `AsIs` even when one is set via the Outbounds editor; and if the core does migrate into `sockopt`, it is worth checking what happens when `sockopt.domainStrategy` is already set explicitly there — the Basics tab writes into the same `streamSettings.sockopt` object for the Happy Eyeballs switch (`BasicsTab.tsx:141-152`). I relabelled this from `bug` to `enhancement`; the title states your observation accurately, so I left it as is. Verdict: Feature request *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@BlindMaster24 commented on GitHub (Sep 14, 2026):

The open question in the analysis above — whether the replacement key is sockopt.domainStrategy or a settings-level targetStrategy — can be settled from the core the panel is actually pinned to, github.com/xtls/xray-core v1.260327.1-0.20260908222543-52a412d9e2f5 (go.mod:28):

  • infra/conf/freedom.go:19-30 — the freedom settings struct declares both targetStrategy and domainStrategy.
  • infra/conf/xray.go:340-368 — this is the deciding part. The loader checks, in order: senderSettings.TargetStrategy (an outbound-level key, a sibling of settings, not a key inside it) and then the freedom config's own DomainStrategy. The latter is what produces The "freedom.domainStrategy" setting is deprecated and will be removed…. Whichever value it resolves is then written to senderSettings.StreamSettings.SocketSettings.DomainStrategy, i.e. streamSettings.sockopt.domainStrategy.
  • proxy/freedom/freedom.go:57 — h.resolveStrategy = streamSettings.SocketSettings.DomainStrategy. Freedom takes its resolve strategy from the socket layer, not from its own settings, so the settings-level key has no other consumer: that migration is the only thing that reads it.

So the reporter's expectation is right, and the target is sockopt.domainStrategy; settings.targetStrategy is not the new home — the core's own targetStrategy lives one level up.

Where the panel writes the legacy key today, for whoever picks this up: the Basics tab's "Freedom Protocol Strategy" select (frontend/src/pages/xray/basics/BasicsTab.tsx, both the read at ~L112 and the write at ~L193), the outbound defaults in frontend/src/pages/xray/basics/constants.ts (ipv4Settings), and freedomToWire in frontend/src/lib/xray/outbound-form-adapter.ts. One detail that matters for a fix: on write the legacy key has to be removed, not merely superseded — leaving a non-AsIs freedom.domainStrategy in place keeps the loader on the warning path regardless of what sockopt says.

Impact today is log noise rather than breakage, since the automatic migration works; it turns into a silently dead setting once the key is dropped upstream.

<!-- gh-comment-id:5659562623 --> @BlindMaster24 commented on GitHub (Sep 14, 2026): The open question in the analysis above — whether the replacement key is `sockopt.domainStrategy` or a settings-level `targetStrategy` — can be settled from the core the panel is actually pinned to, `github.com/xtls/xray-core v1.260327.1-0.20260908222543-52a412d9e2f5` (`go.mod:28`): - `infra/conf/freedom.go:19-30` — the freedom settings struct declares **both** `targetStrategy` and `domainStrategy`. - `infra/conf/xray.go:340-368` — this is the deciding part. The loader checks, in order: `senderSettings.TargetStrategy` (an **outbound-level** key, a sibling of `settings`, not a key inside it) and then the freedom config's own `DomainStrategy`. The latter is what produces `The "freedom.domainStrategy" setting is deprecated and will be removed…`. Whichever value it resolves is then written to `senderSettings.StreamSettings.SocketSettings.DomainStrategy`, i.e. `streamSettings.sockopt.domainStrategy`. - `proxy/freedom/freedom.go:57` — `h.resolveStrategy = streamSettings.SocketSettings.DomainStrategy`. Freedom takes its resolve strategy from the **socket layer**, not from its own `settings`, so the settings-level key has no other consumer: that migration is the only thing that reads it. So the reporter's expectation is right, and the target is `sockopt.domainStrategy`; `settings.targetStrategy` is not the new home — the core's own `targetStrategy` lives one level up. Where the panel writes the legacy key today, for whoever picks this up: the Basics tab's "Freedom Protocol Strategy" select (`frontend/src/pages/xray/basics/BasicsTab.tsx`, both the read at ~L112 and the write at ~L193), the outbound defaults in `frontend/src/pages/xray/basics/constants.ts` (`ipv4Settings`), and `freedomToWire` in `frontend/src/lib/xray/outbound-form-adapter.ts`. One detail that matters for a fix: on write the legacy key has to be **removed**, not merely superseded — leaving a non-`AsIs` `freedom.domainStrategy` in place keeps the loader on the warning path regardless of what `sockopt` says. Impact today is log noise rather than breakage, since the automatic migration works; it turns into a silently dead setting once the key is dropped upstream.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4374
No description provided.