[GH-ISSUE #5956] [Bug]: The existing TProxy configuration is not displayed correctly. #4128

Closed
opened 2026-10-31 20:37:22 +07:00 by bsakaguchi · 3 comments
Owner

Originally created by @Ramazik on GitHub (Jul 14, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5956

Describe the bug

The issue is identical to the one I described earlier in https://github.com/MHSanaei/3x-ui/issues/5621
This issue arose at the same time, but I didn't mention it because I assumed that the solution to the described issues would also include fixing this bug.

In an existing, previously created inbound configuration with the Sockopt option enabled, the TProxy field is displayed incorrectly—it's empty in the interface. Selecting a value and saving the inbound configuration does not correct the display issue.

How to reproduce the problem

Described above

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

Image

3x-ui version

3.5.0

Xray-core version

26.7.11

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

Frontend (UI / panel pages)

Browser (only if it is a UI bug)

Chrome 150

Is the panel behind a reverse proxy or CDN?

No response

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 @Ramazik on GitHub (Jul 14, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5956 ### Describe the bug The issue is identical to the one I described earlier in https://github.com/MHSanaei/3x-ui/issues/5621 This issue arose at the same time, but I didn't mention it because I assumed that the solution to the described issues would also include fixing this bug. In an existing, previously created inbound configuration with the Sockopt option enabled, the TProxy field is displayed incorrectly—it's empty in the interface. Selecting a value and saving the inbound configuration does not correct the display issue. ### How to reproduce the problem Described above ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots <img width="744" height="933" alt="Image" src="https://github.com/user-attachments/assets/40421003-d1b9-4560-b013-cc2d6b78c10c" /> ### 3x-ui version 3.5.0 ### Xray-core version 26.7.11 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? Frontend (UI / panel pages) ### Browser (only if it is a UI bug) Chrome 150 ### Is the panel behind a reverse proxy or CDN? _No response_ ### 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:37:22 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jul 14, 2026):

Confirmed as a real bug, distinct from #5621 but in the same family (the edit modal skipping schema-based defaulting when it loads a stored inbound into the form). Verified against both the reporter's v3.5.0 tag and the current main (129f50d) — not yet fixed on either.

Title: sockopt.tproxy is left unpopulated when editing a stored inbound, and saving "Off" strips the key again, so the field can never display correctly

Severity: Medium

Category: Correctness

Why this matters:
When the edit modal opens an existing inbound, InboundFormModal.tsx:359-360 calls rawInboundToFormValues(dbInbound) directly on the raw DB row. Inside that function (frontend/src/lib/xray/inbound-form-adapter.ts:159-205), streamSettings is copied through essentially unchanged — the only sub-object re-parsed through its Zod schema (to fill in defaults/migrate renamed keys) is xhttpSettings (lines 166-181, added by commit 539bcc8 specifically to fix #5621). sockopt gets no equivalent treatment.

The TProxy control (frontend/src/pages/inbounds/form/transport/sockopt.tsx:196-205) is a Select bound straight to streamSettings.sockopt.tproxy via the shared FormField (frontend/src/components/form/rhf/FormField.tsx:61-67), which forwards field.value to the value prop with no fallback. So if the stored sockopt object has no tproxy key — true for any inbound whose sockopt config predates the TProxy UI (added when #5166 was fixed, 2026-06-11) — the Select renders with nothing selected, i.e. blank, exactly as shown in the screenshot. This only affects inbounds loaded from storage: a brand-new inbound toggling Sockopt on calls SockoptStreamSettingsSchema.parse({}) (InboundFormModal.tsx:294), which always fills tproxy: 'off', so newly-created configs never hit this.

This also explains why resaving doesn't help. normalizeSockoptForWire() (frontend/src/lib/xray/stream-wire-normalize.ts:251) contains if (out.tproxy === 'off') delete out.tproxy; — "Off" is treated as the default and dropped from the payload before it's persisted. "Off" is the value most users would pick when they just want the blank field to show something sensible, but doing so strips the key again, reproducing the identical missing-key state on the next edit. Only picking "Redirect" or "TProxy" (a non-default value) actually survives a save and would redisplay correctly afterward.

The same unguarded FormField pattern is used for other sockopt sub-fields in that form (e.g. tcpcongestion at sockopt.tsx:188-195), so any older stored sockopt object missing that key would show the same kind of blank Select; TProxy is simply the field the reporter noticed. Runtime traffic handling is presumably unaffected either way, since the panel's own schema default for an absent tproxy is 'off' (frontend/src/schemas/protocols/stream/sockopt.ts:56) — this looks like a pure display/round-trip defect, not a config-correctness one.

Recommendation: In rawInboundToFormValues, run the raw streamSettings.sockopt object through SockoptStreamSettingsSchema.safeParse() (mirroring the existing xhttpSettings handling at inbound-form-adapter.ts:170-180) before it reaches the form store, so missing keys are filled with their schema defaults on every load rather than only when a user manually toggles Sockopt on. No pull request has been opened; a maintainer can request an implementation by mentioning @claude.

Example:

// frontend/src/lib/xray/inbound-form-adapter.ts:166-181, rawInboundToFormValues()
if (streamSettings) {
  healStreamNetworkKey(streamSettings as unknown as Record<string, unknown>);
  synthesizeTlsCertUseFile(streamSettings as unknown as Record<string, unknown>);
  const streamRecord = streamSettings as unknown as Record<string, unknown>;
  const xh = streamRecord.xhttpSettings;
  if (xh && typeof xh === 'object' && !Array.isArray(xh)) {
    const parsed = XHttpStreamSettingsSchema.safeParse(xh); // <- sockopt has no equivalent
    ...
  }
}

// frontend/src/lib/xray/stream-wire-normalize.ts:251, normalizeSockoptForWire()
if (out.tproxy === 'off') delete out.tproxy; // strips the key again on every save

Confidence: high — traced end to end from the edit-open call site through the form binding to the save-time normalizer, and confirmed the same code exists in the v3.5.0 tag and current main.

@MHSanaei for awareness / triage.

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

<!-- gh-comment-id:4969005534 --> @github-actions[bot] commented on GitHub (Jul 14, 2026): Confirmed as a real bug, distinct from #5621 but in the same family (the edit modal skipping schema-based defaulting when it loads a stored inbound into the form). Verified against both the reporter's v3.5.0 tag and the current `main` (129f50d) — not yet fixed on either. **Title:** `sockopt.tproxy` is left unpopulated when editing a stored inbound, and saving "Off" strips the key again, so the field can never display correctly **Severity:** Medium **Category:** Correctness **Why this matters:** When the edit modal opens an existing inbound, `InboundFormModal.tsx:359-360` calls `rawInboundToFormValues(dbInbound)` directly on the raw DB row. Inside that function (`frontend/src/lib/xray/inbound-form-adapter.ts:159-205`), `streamSettings` is copied through essentially unchanged — the only sub-object re-parsed through its Zod schema (to fill in defaults/migrate renamed keys) is `xhttpSettings` (lines 166-181, added by commit `539bcc8` specifically to fix #5621). `sockopt` gets no equivalent treatment. The TProxy control (`frontend/src/pages/inbounds/form/transport/sockopt.tsx:196-205`) is a `Select` bound straight to `streamSettings.sockopt.tproxy` via the shared `FormField` (`frontend/src/components/form/rhf/FormField.tsx:61-67`), which forwards `field.value` to the `value` prop with no fallback. So if the stored `sockopt` object has no `tproxy` key — true for any inbound whose sockopt config predates the TProxy UI (added when #5166 was fixed, 2026-06-11) — the Select renders with nothing selected, i.e. blank, exactly as shown in the screenshot. This only affects inbounds loaded from storage: a brand-new inbound toggling Sockopt on calls `SockoptStreamSettingsSchema.parse({})` (`InboundFormModal.tsx:294`), which always fills `tproxy: 'off'`, so newly-created configs never hit this. This also explains why resaving doesn't help. `normalizeSockoptForWire()` (`frontend/src/lib/xray/stream-wire-normalize.ts:251`) contains `if (out.tproxy === 'off') delete out.tproxy;` — "Off" is treated as the default and dropped from the payload before it's persisted. "Off" is the value most users would pick when they just want the blank field to show something sensible, but doing so strips the key again, reproducing the identical missing-key state on the next edit. Only picking "Redirect" or "TProxy" (a non-default value) actually survives a save and would redisplay correctly afterward. The same unguarded `FormField` pattern is used for other `sockopt` sub-fields in that form (e.g. `tcpcongestion` at `sockopt.tsx:188-195`), so any older stored `sockopt` object missing that key would show the same kind of blank `Select`; TProxy is simply the field the reporter noticed. Runtime traffic handling is presumably unaffected either way, since the panel's own schema default for an absent `tproxy` is `'off'` (`frontend/src/schemas/protocols/stream/sockopt.ts:56`) — this looks like a pure display/round-trip defect, not a config-correctness one. **Recommendation:** In `rawInboundToFormValues`, run the raw `streamSettings.sockopt` object through `SockoptStreamSettingsSchema.safeParse()` (mirroring the existing `xhttpSettings` handling at `inbound-form-adapter.ts:170-180`) before it reaches the form store, so missing keys are filled with their schema defaults on every load rather than only when a user manually toggles Sockopt on. No pull request has been opened; a maintainer can request an implementation by mentioning @claude. **Example:** ```ts // frontend/src/lib/xray/inbound-form-adapter.ts:166-181, rawInboundToFormValues() if (streamSettings) { healStreamNetworkKey(streamSettings as unknown as Record<string, unknown>); synthesizeTlsCertUseFile(streamSettings as unknown as Record<string, unknown>); const streamRecord = streamSettings as unknown as Record<string, unknown>; const xh = streamRecord.xhttpSettings; if (xh && typeof xh === 'object' && !Array.isArray(xh)) { const parsed = XHttpStreamSettingsSchema.safeParse(xh); // <- sockopt has no equivalent ... } } // frontend/src/lib/xray/stream-wire-normalize.ts:251, normalizeSockoptForWire() if (out.tproxy === 'off') delete out.tproxy; // strips the key again on every save ``` Confidence: high — traced end to end from the edit-open call site through the form binding to the save-time normalizer, and confirmed the same code exists in the v3.5.0 tag and current `main`. @MHSanaei for awareness / triage. *This reply was generated automatically; a maintainer may follow up.*
Author
Owner

@Ramazik commented on GitHub (Jul 15, 2026):

Also (as seen in the screenshot), the Route Mark and TCP Keep Alive Interval fields display empty values ​​when opening a previously saved configuration in which these fields were set to zero. I'm not sure if this is normal behavior.

<!-- gh-comment-id:4982208713 --> @Ramazik commented on GitHub (Jul 15, 2026): Also (as seen in the screenshot), the Route Mark and TCP Keep Alive Interval fields display empty values ​​when opening a previously saved configuration in which these fields were set to zero. I'm not sure if this is normal behavior.
Author
Owner

@MHSanaei commented on GitHub (Jul 23, 2026):

Fixed in #6083. streamSettings.sockopt is now re-parsed through its schema on load, so TProxy (and other sockopt fields) display correctly for inbounds saved before the control existed.

<!-- gh-comment-id:5059097628 --> @MHSanaei commented on GitHub (Jul 23, 2026): Fixed in #6083. streamSettings.sockopt is now re-parsed through its schema on load, so TProxy (and other sockopt fields) display correctly for inbounds saved before the control existed.
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#4128
No description provided.