[GH-ISSUE #5446] [Bug]: Regression of #4364: Karing loses XHTTP packet-up mode when VLESS link contains extra/x_padding_bytes #3806

Closed
opened 2026-10-31 20:35:06 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @scan666github on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5446

Describe the bug

This looks like a regression of #4364.

In 3x-ui v3.3.1, VLESS + REALITY + XHTTP packet-up share/subscription links can include both:

mode=packet-up
extra={"xPaddingBytes":"100-1000"}
x_padding_bytes=100-1000

When this link is imported into Karing 1.2.19.2209 on iOS, Karing stores the server without transport.mode. The imported profile then fails its latency test with:

Head "https://www.gstatic.com/generate_204": io: read/write on closed pipe

The server receives TCP connections on port 443, but the client does not reach a successful VLESS/XHTTP request. 3x-ui counters for the client stay at 0 and there are no successful email: ... access log entries.

If the same client is imported with a "clean" A0-style link that keeps mode=packet-up as a flat parameter but removes extra and x_padding_bytes, Karing imports it correctly and the connection works immediately.

How to reproduce the problem

  1. Use 3x-ui v3.3.1.
  2. Create a VLESS inbound:
    • Security: REALITY
    • Transport: XHTTP
    • XHTTP mode: packet-up
    • Path: /assets/api/events
    • xPaddingBytes: 100-1000
  3. Generate a client share link or subscription link.
  4. Import the link into Karing 1.2.19.2209 on iOS.
  5. Run Karing latency test or try to connect.

Sanitized example of the failing link shape generated by 3x-ui v3.3.1:

vless://UUID@example.com:443?encryption=none&extra=%7B%22xPaddingBytes%22%3A%22100-1000%22%7D&fp=chrome&host=&mode=packet-up&path=%2Fassets%2Fapi%2Fevents&pbk=PUBLIC_KEY&security=reality&sid=SHORT_ID&sni=example.com&spx=%2Frandom&type=xhttp&x_padding_bytes=100-1000#TAG

Karing stores this approximately as:

{
  "type": "vless",
  "tls": {
    "enabled": true,
    "server_name": "example.com",
    "utls": {
      "enabled": true,
      "fingerprint": "chrome"
    },
    "reality": {
      "enabled": true,
      "public_key": "PUBLIC_KEY",
      "short_id": "SHORT_ID"
    }
  },
  "transport": {
    "type": "xhttp",
    "path": "/assets/api/events",
    "x_padding_bytes": "100-1000"
  },
  "latency": "Head \"https://www.gstatic.com/generate_204\": io: read/write on closed pipe"
}

Notice that transport.mode is missing.

Workaround

If the link is manually rewritten to remove extra and x_padding_bytes, while keeping mode=packet-up, Karing imports it correctly and the same server/client works:

vless://UUID@example.com:443?fp=chrome&host=&mode=packet-up&path=%2Fassets%2Fapi%2Fevents&pbk=PUBLIC_KEY&security=reality&sid=SHORT_ID&sni=example.com&spx=%2F&type=xhttp#TAG

After importing this clean link:

  • 3x-ui client counters increase.
  • last_online updates.
  • Xray access log shows normal accepted requests, e.g. inbound-443 -> outboundTag email: TAG.
  • Karing traffic works.

Why this looks like a regression

Issue #4364 described almost the same Karing symptom: after importing a newer subscription, Karing stored XHTTP transport with padding fields but without mode, causing io: read/write on closed pipe.

Commit 01a7dc807beaa8007ed83010b2c99424b5fb18f7 closed #4364 with:

fix(sub): include xhttp mode in extra JSON for karing compatibility (#4365)

However, in v3.3.1 the current frontend/src/lib/xray/inbound-link.ts has:

params.set('mode', xhttp.mode);
...
const extra = buildXhttpExtra(xhttp);
if (extra) params.set('extra', JSON.stringify(extra));

but buildXhttpExtra() does not add mode into extra.

So the generated link has flat mode=packet-up, but extra only contains padding fields. Karing appears to prefer/parse the extra payload and drops the flat mode, reproducing #4364.

Expected behavior

Karing-compatible share/subscription links should preserve XHTTP mode=packet-up after import.

Possible fixes:

  • include mode in the XHTTP extra JSON again when extra is emitted, or
  • avoid emitting extra/x_padding_bytes in share links unless needed, or
  • otherwise generate a link shape compatible with Karing's parser.

Actual behavior

Karing imports the server without transport.mode, then fails with:

Head "https://www.gstatic.com/generate_204": io: read/write on closed pipe

3x-ui version

v3.3.1

Xray-core version

26.6.1

Client

Karing 1.2.19.2209 on iOS.

Shadowrocket and a direct Xray 26.6.1 client work with the same server/client parameters.

Before submitting

  • I searched existing issues.
  • Similar closed issue found: #4364.
  • This appears to be a regression in v3.3.1/current link generation.
  • Sensitive values are redacted.
Originally created by @scan666github on GitHub (Jun 20, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5446 ### Describe the bug This looks like a regression of #4364. In 3x-ui v3.3.1, VLESS + REALITY + XHTTP `packet-up` share/subscription links can include both: ```text mode=packet-up extra={"xPaddingBytes":"100-1000"} x_padding_bytes=100-1000 ``` When this link is imported into Karing 1.2.19.2209 on iOS, Karing stores the server without `transport.mode`. The imported profile then fails its latency test with: ```text Head "https://www.gstatic.com/generate_204": io: read/write on closed pipe ``` The server receives TCP connections on port 443, but the client does not reach a successful VLESS/XHTTP request. 3x-ui counters for the client stay at 0 and there are no successful `email: ...` access log entries. If the same client is imported with a "clean" A0-style link that keeps `mode=packet-up` as a flat parameter but removes `extra` and `x_padding_bytes`, Karing imports it correctly and the connection works immediately. ### How to reproduce the problem 1. Use 3x-ui v3.3.1. 2. Create a VLESS inbound: - Security: REALITY - Transport: XHTTP - XHTTP mode: `packet-up` - Path: `/assets/api/events` - `xPaddingBytes`: `100-1000` 3. Generate a client share link or subscription link. 4. Import the link into Karing 1.2.19.2209 on iOS. 5. Run Karing latency test or try to connect. ### Generated link shape Sanitized example of the failing link shape generated by 3x-ui v3.3.1: ```text vless://UUID@example.com:443?encryption=none&extra=%7B%22xPaddingBytes%22%3A%22100-1000%22%7D&fp=chrome&host=&mode=packet-up&path=%2Fassets%2Fapi%2Fevents&pbk=PUBLIC_KEY&security=reality&sid=SHORT_ID&sni=example.com&spx=%2Frandom&type=xhttp&x_padding_bytes=100-1000#TAG ``` Karing stores this approximately as: ```json { "type": "vless", "tls": { "enabled": true, "server_name": "example.com", "utls": { "enabled": true, "fingerprint": "chrome" }, "reality": { "enabled": true, "public_key": "PUBLIC_KEY", "short_id": "SHORT_ID" } }, "transport": { "type": "xhttp", "path": "/assets/api/events", "x_padding_bytes": "100-1000" }, "latency": "Head \"https://www.gstatic.com/generate_204\": io: read/write on closed pipe" } ``` Notice that `transport.mode` is missing. ### Workaround If the link is manually rewritten to remove `extra` and `x_padding_bytes`, while keeping `mode=packet-up`, Karing imports it correctly and the same server/client works: ```text vless://UUID@example.com:443?fp=chrome&host=&mode=packet-up&path=%2Fassets%2Fapi%2Fevents&pbk=PUBLIC_KEY&security=reality&sid=SHORT_ID&sni=example.com&spx=%2F&type=xhttp#TAG ``` After importing this clean link: - 3x-ui client counters increase. - `last_online` updates. - Xray access log shows normal accepted requests, e.g. `inbound-443 -> outboundTag email: TAG`. - Karing traffic works. ### Why this looks like a regression Issue #4364 described almost the same Karing symptom: after importing a newer subscription, Karing stored XHTTP transport with padding fields but without `mode`, causing `io: read/write on closed pipe`. Commit `01a7dc807beaa8007ed83010b2c99424b5fb18f7` closed #4364 with: ```text fix(sub): include xhttp mode in extra JSON for karing compatibility (#4365) ``` However, in v3.3.1 the current `frontend/src/lib/xray/inbound-link.ts` has: ```ts params.set('mode', xhttp.mode); ... const extra = buildXhttpExtra(xhttp); if (extra) params.set('extra', JSON.stringify(extra)); ``` but `buildXhttpExtra()` does not add `mode` into `extra`. So the generated link has flat `mode=packet-up`, but `extra` only contains padding fields. Karing appears to prefer/parse the `extra` payload and drops the flat `mode`, reproducing #4364. ### Expected behavior Karing-compatible share/subscription links should preserve XHTTP `mode=packet-up` after import. Possible fixes: - include `mode` in the XHTTP `extra` JSON again when `extra` is emitted, or - avoid emitting `extra`/`x_padding_bytes` in share links unless needed, or - otherwise generate a link shape compatible with Karing's parser. ### Actual behavior Karing imports the server without `transport.mode`, then fails with: ```text Head "https://www.gstatic.com/generate_204": io: read/write on closed pipe ``` ### 3x-ui version v3.3.1 ### Xray-core version 26.6.1 ### Client Karing 1.2.19.2209 on iOS. Shadowrocket and a direct Xray 26.6.1 client work with the same server/client parameters. ### Before submitting - [x] I searched existing issues. - [x] Similar closed issue found: #4364. - [x] This appears to be a regression in v3.3.1/current link generation. - [x] Sensitive values are redacted.
bsakaguchi 2026-10-31 20:35:06 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 20, 2026):

The regression is confirmed against the current source. Here is what the investigation found.

Root cause

The fix for #4364 (commit 01a7dc807) taught both the Go subscription service and the JS frontend to include mode inside the extra JSON blob so that clients which parse extra (rather than flat URL params) would still see it. When the codebase was later refactored — sub/subService.go → internal/sub/service.go, frontend/src/models/inbound.js → frontend/src/lib/xray/inbound-link.ts — the mode field was not carried forward into the new buildXhttpExtra implementations. The flat mode=packet-up URL parameter is still set, but extra now only contains xPaddingBytes and the other bidirectional fields.

Karing 1.2.19.2209 appears to populate transport from the extra JSON when extra is present, which causes the flat mode param to be silently dropped, reproducing the exact symptom from #4364.

Confirmed locations in the current source

  • internal/sub/service.go, function buildXhttpExtra (line 1632): does not include mode in the returned map. The flat param is set on line 1767 of applyXhttpExtraParams, but buildXhttpExtra (called on line 1775) returns an extra object without mode.
  • frontend/src/lib/xray/inbound-link.ts, function buildXhttpExtra (line 46): similarly does not include mode. The flat param is written on line 274 of applyXhttpExtraToParams, but the extra JSON built on line 278 omits it.

This means that whenever xPaddingBytes or any other bidirectional field is non-empty, the generated link carries:

mode=packet-up&x_padding_bytes=100-1000&extra={"xPaddingBytes":"100-1000"}

Karing reads extra, finds xPaddingBytes, stores transport.type=xhttp and transport.x_padding_bytes, but never sees mode, leaving transport.mode absent.

Minimal fix

In both files, buildXhttpExtra needs to emit mode when it is non-empty, mirroring what commit 01a7dc807 did for the old files:

internal/sub/service.go — add inside buildXhttpExtra, alongside the other field extractions:

if mode, ok := xhttp["mode"].(string); ok && len(mode) > 0 {
    extra["mode"] = mode
}

frontend/src/lib/xray/inbound-link.ts — add inside buildXhttpExtra, before the stringFields block:

if (typeof xhttp.mode === 'string' && xhttp.mode.length > 0) {
  extra.mode = xhttp.mode;
}

Both changes are identical in intent to the original fix from commit 01a7dc807. The flat mode param should be kept as-is alongside extra.mode; removing it would break clients that read only flat params.

Scope

Affects share links (generated in the browser via inbound-link.ts) and subscription links (generated server-side in service.go) whenever XHTTP is used with any bidirectional extra field set (xPaddingBytes, uplinkHTTPMethod, xmux, downloadSettings, custom headers, etc.). Clients that read only flat URL params (v2rayNG, Shadowrocket, direct Xray) are unaffected.


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

<!-- gh-comment-id:4756912420 --> @github-actions[bot] commented on GitHub (Jun 20, 2026): The regression is confirmed against the current source. Here is what the investigation found. **Root cause** The fix for #4364 (commit `01a7dc807`) taught both the Go subscription service and the JS frontend to include `mode` inside the `extra` JSON blob so that clients which parse `extra` (rather than flat URL params) would still see it. When the codebase was later refactored — `sub/subService.go` → `internal/sub/service.go`, `frontend/src/models/inbound.js` → `frontend/src/lib/xray/inbound-link.ts` — the `mode` field was **not carried forward** into the new `buildXhttpExtra` implementations. The flat `mode=packet-up` URL parameter is still set, but `extra` now only contains `xPaddingBytes` and the other bidirectional fields. Karing 1.2.19.2209 appears to populate `transport` from the `extra` JSON when `extra` is present, which causes the flat `mode` param to be silently dropped, reproducing the exact symptom from #4364. **Confirmed locations in the current source** - `internal/sub/service.go`, function `buildXhttpExtra` (line 1632): does not include `mode` in the returned map. The flat param is set on line 1767 of `applyXhttpExtraParams`, but `buildXhttpExtra` (called on line 1775) returns an `extra` object without `mode`. - `frontend/src/lib/xray/inbound-link.ts`, function `buildXhttpExtra` (line 46): similarly does not include `mode`. The flat param is written on line 274 of `applyXhttpExtraToParams`, but the `extra` JSON built on line 278 omits it. This means that whenever `xPaddingBytes` or any other bidirectional field is non-empty, the generated link carries: ``` mode=packet-up&x_padding_bytes=100-1000&extra={"xPaddingBytes":"100-1000"} ``` Karing reads `extra`, finds `xPaddingBytes`, stores `transport.type=xhttp` and `transport.x_padding_bytes`, but never sees `mode`, leaving `transport.mode` absent. **Minimal fix** In both files, `buildXhttpExtra` needs to emit `mode` when it is non-empty, mirroring what commit `01a7dc807` did for the old files: `internal/sub/service.go` — add inside `buildXhttpExtra`, alongside the other field extractions: ```go if mode, ok := xhttp["mode"].(string); ok && len(mode) > 0 { extra["mode"] = mode } ``` `frontend/src/lib/xray/inbound-link.ts` — add inside `buildXhttpExtra`, before the `stringFields` block: ```ts if (typeof xhttp.mode === 'string' && xhttp.mode.length > 0) { extra.mode = xhttp.mode; } ``` Both changes are identical in intent to the original fix from commit `01a7dc807`. The flat `mode` param should be kept as-is alongside `extra.mode`; removing it would break clients that read only flat params. **Scope** Affects share links (generated in the browser via `inbound-link.ts`) and subscription links (generated server-side in `service.go`) whenever XHTTP is used with any bidirectional extra field set (`xPaddingBytes`, `uplinkHTTPMethod`, `xmux`, `downloadSettings`, custom headers, etc.). Clients that read only flat URL params (v2rayNG, Shadowrocket, direct Xray) are unaffected. --- *This reply was generated automatically; a maintainer may follow up.*
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#3806
No description provided.