mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6421] Bug: Advanced Configuration duplicates v6only and V6Only #4347
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4347
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @lin-finegold on GitHub (Sep 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6421
Duplicate
v6only/V6Onlyfields appear in Advanced ConfigurationSummary
When an inbound is loaded from the database and the Advanced Configuration view is opened, the generated JSON can contain both:
The two fields represent the same Xray sockopt option but use different casing/naming. This makes the displayed configuration ambiguous and may cause parser-dependent behavior if it is passed through without normalization.
Reproduction
streamSettings.sockoptcontains the Xray-core field:v6only: trueandV6Only: false.Observed implementation path
In the frontend:
frontend/src/schemas/protocols/stream/sockopt.ts:70definesV6Onlywith a default offalse.frontend/src/pages/inbounds/form/transport/sockopt.tsx:192binds the form field toV6Only.frontend/src/lib/xray/inbound-form-adapter.ts:190-195preserves the raw object and merges the parsed Zod result:Because the schema does not recognize lowercase
v6only, it preserves the raw lowercase key and adds the default uppercaseV6Only: false.The Advanced Configuration editor then serializes the merged form state.
Expected behavior
The panel should normalize the field at the database/form boundary and emit only one canonical representation. For example:
V6Onlyv6onlyLoading an existing
v6onlyvalue should populate theV6Onlyform field rather than preserve both keys. Saving should remove the alternate casing before serialization.The same naming issue appears to affect
tcpcongestionversus the Xray-core canonical spellingtcpCongestion.Environment
No credentials or private configuration data are included in this report.
@github-actions[bot] commented on GitHub (Sep 5, 2026):
Confirmed — the duplicate is real and still present on the default branch, and your trace of the code path is correct. One part of the report is not:
tcpcongestionis not a second instance of this problem (details at the end).What the code does
rawInboundToFormValuesre-parses a storedsockoptthrough the Zod schema and then merges the raw object with the parsed one:SockoptStreamSettingsSchemais a plainz.object, so it strips the unrecognised lowercasev6onlyfromparsed.datawhile the spread ofsokeeps it, andV6Only: z.boolean().default(false)(frontend/src/schemas/protocols/stream/sockopt.ts:70) adds the second key. The panel's canonical spelling is the capitalised one throughout: the switch binds to['streamSettings', 'sockopt', 'V6Only'](frontend/src/pages/inbounds/form/transport/sockopt.tsx:192) and the wire normalizer lists it asV6Only(frontend/src/lib/xray/stream-wire-normalize.ts:293). That has been the panel's key since before the React rewrite — the legacy model usedV6Onlytoo (web/assets/js/model/inbound.js:1008atbc00d37a^), so a lowercasev6onlyin the database can only have come from outside the inbound form (REST API, an imported config, or the Advanced JSON editor).The merge itself was introduced by
892c06c8(Bug-label issue sweep: 16 fixes (#6083)), sub-fix "fix(frontend): default sockopt fields when editing a stored inbound (#5956)" — preserving unknown keys is deliberate there; folding alternate casings is what is missing.What is displayed vs. what is saved
The Advanced tab is display-only pruning —
AdvancedAllEditorappliespruneEmpty/normalizeSniffingbut notnormalizeSockoptForWire(frontend/src/pages/inbounds/form/advanced-editors.tsx:119-121), andAdvancedSliceEditorserialises the raw form slice verbatim (:40-43). So both keys are shown, exactly as you saw.On save the two diverge:
normalizeSockoptForWiredeletesV6Onlybecause it isfalse(stream-wire-normalize.ts:293viadropFalseFlags,:181-185), whilev6onlysurvives the{ ...raw }copy at:282untouched. The stored config keeps onlyv6only: true, so nothing duplicated reaches Xray in this case.v6onlyandV6Only, andinternal/database/model/model.go:387handsStreamSettingsto Xray verbatim as ajson_util.RawMessage, duplicate key and all.The behavioural consequence is worse than the cosmetic one: for a stored
"v6only": true, the switch renders off (it readsV6Only, which the schema defaulted tofalse), and toggling it off writes nothing, because thefalseis dropped and the lowercasetrueremains. The option cannot be turned off from the sockopt form at all.Workaround
Open the inbound → Advanced → Stream tab, delete the lowercase
"v6only"line by hand, set"V6Only"to the value you want, and save. From then on the switch tracks it correctly.Verdict: Confirmed bug
Severity: Medium
Confidence: High (panel side; see Not determined for the Xray-side spelling)
Root cause:
rawInboundToFormValuesinfrontend/src/lib/xray/inbound-form-adapter.ts:194merges the raw sockopt object over the Zod-parsed one, so an unrecognised alternate-case key (v6only) is preserved alongside the schema default it should have populated (V6Only). Triggered only by a sockopt written outside the inbound form. Introduced by892c06c8(#6083, sub-fix #5956).Already fixed: Still present on the default branch (
ed6bc1d8); v3.7.0 is the current release, so you are on the tip.Duplicate of: None
Evidence:
inbound-form-adapter.ts:190-196(raw ∪ parsed merge);schemas/protocols/stream/sockopt.ts:70V6Only: z.boolean().default(false);pages/inbounds/form/transport/sockopt.tsx:192switch binding;lib/xray/stream-wire-normalize.ts:282{ ...raw }and:293dropFalseFlags(out, [... 'V6Only'])with:181-185;pages/inbounds/form/advanced-editors.tsx:40-43and:119-121(no sockopt normalizer in the displayed JSON);internal/database/model/model.go:387StreamSettings: json_util.RawMessage(streamSettings);web/assets/js/model/inbound.js:1008atbc00d37a^(panel always emittedV6Only); golden fixturefrontend/src/test/golden/fixtures/sockopt/full.json:15.Not determined: Which spelling Xray-core declares in its
SocketConfigstruct tag — I have no network access and no module cache in this environment, so I could not readinfra/conf/transport_internet.goand will not guess. It changes the preferred canonical output, not the defect: Go'sencoding/jsonfalls back to case-insensitive field matching, so both spellings bind to the same field and the last occurrence in the object wins (that is stdlib behaviour, not a line I read here). Onegrep -n 'V6only' infra/conf/transport_internet.goin an Xray-core checkout settles it.Suggested fix: fold the alternate casing at the load boundary in
rawInboundToFormValues— move a lowercasev6onlyintoV6Onlyand delete the raw key before the merge atinbound-form-adapter.ts:194, so the form owns exactly one key.normalizeSockoptForWirethen emits whichever single spelling is chosen as canonical.On
tcpcongestionThis one is not a defect.
tcpcongestion(all lowercase) is the wire key the panel uses everywhere — schemasockopt.ts:69, form bindingsockopt.tsx:199, normalizerstream-wire-normalize.ts:320, and the documented sockopt table atdocs/content/docs/en/config/transports.mdx:146. The camelCasetcpCongestionyou saw exists only as an i18n label key (internal/web/translation/en-US.json:564, referenced ast('pages.inbounds.form.tcpCongestion')); it never reaches a config. So there is no second duplicated field.This reply was generated automatically; a maintainer may follow up.
@lin-finegold commented on GitHub (Sep 6, 2026):
Additional reproduction: separate IPv4 and IPv6 listeners on port 443 cannot be saved
The issue is not limited to the duplicate fields shown in Advanced Configuration. There is also a practical failure when configuring separate IPv4 and IPv6 listeners on the same port.
Intended configuration
The host has an internal IPv4 address
10.0.0.50. The intended listener layout is:The IPv6 inbound is configured with:
The purpose of
v6only: trueis to make the IPv6 socket IPv6-only, so that an independent IPv4 service can bind10.0.0.50:443without the IPv6 wildcard socket occupying the IPv4 port space.Observed behavior in 3x-ui
When the inbound is edited/saved through the 3x-ui UI, the panel rejects the configuration or reports a port/listener conflict. The configuration cannot be saved even though the two sockets are intended to be independent:
10.0.0.50, not0.0.0.0;::;v6onlyis explicitly enabled.This appears to be a frontend validation/normalization problem rather than an Xray-core socket limitation.
Why this is related to #6421
The Advanced Configuration path and the normal sockopt form use different casing:
The UI may therefore:
v6onlyvalue;V6Only: falsefield;V6Only/v6only=true;Expected behavior
3x-ui should allow the following valid layout when the operating system and Xray accept it:
The panel should:
v6onlyandV6Onlyinto one canonical field at the load boundary;v6only/V6Only=truevalue during port-conflict validation;If the panel intentionally does not support this layout, the validation error should state the precise restriction and distinguish it from a genuine same-address/same-family port conflict.
Related observed layout
A similar working design has been used with separate IPv4 and IPv6 listeners on port 443, where the IPv4 listener is bound to a specific private address and the IPv6 listener uses
::with IPv6-only enabled. This is why the current unconditional conflict behavior is misleading for this configuration.Please consider extending this issue to cover the save-time listener validation path, not only the duplicate Advanced Configuration fields.
@lin-finegold commented on GitHub (Sep 6, 2026):
Important clarification: this is a multi-address host
The affected host is not a single-address IPv4/IPv6 host. It has multiple IPv4 addresses and multiple IPv6 addresses configured on the same machine (a multi-homed / multi-address host).
The relevant example is:
The requested listener layout uses a specific IPv4 address:
with:
This is important because the panel's conflict check must not treat every existing listener on port 443 as a conflict. It needs to evaluate at least:
0.0.0.0;v6onlyvalue after normalizingv6onlyandV6Only;On a host with multiple IPv4 and multiple IPv6 addresses, it must remain possible to bind services to different specific addresses on the same numeric port where the OS allows it. A generic
443 is already usedvalidation is therefore insufficient and prevents legitimate multi-address deployments.Please consider testing this case with a host containing multiple IPv4 and IPv6 addresses, not only with a single dual-stack address pair.
@lin-finegold commented on GitHub (Sep 6, 2026):
@MHSanaei Friendly follow-up: could a maintainer please review the additional multi-address-host case above?
This affects hosts with multiple IPv4 and multiple IPv6 addresses, where
10.0.0.50:443and[::]:443are intended to coexist withv6only: true. The 3x-ui UI currently cannot save the configuration or reports a generic port conflict.Please confirm whether this save-time validation case can be investigated/fixed, or whether the layout is intentionally unsupported. Thank you.