mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #4065] [MERGED] Fix xhttp xPadding settings missing from generated links (panel + subs) #5588
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#5588
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?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/4065
Author: @pwnnex
Created: 4/21/2026
Status: ✅ Merged
Merged: 4/21/2026
Merged by: @MHSanaei
Base:
main← Head:fix/xhttp-padding-obfs-in-subs📝 Commits (2)
37ac0a2Fix: propagate xhttp xPadding settings into generated subscription links0a99f19Also propagate xhttp xPadding settings into the panel's own Info/QR links📊 Changes
3 files changed (+155 additions, -2 deletions)
View changed files
📝
sub/subService.go(+71 -0)📝
web/assets/js/model/inbound.js(+58 -0)📝
web/assets/js/model/outbound.js(+26 -2)📄 Description
Summary
Admins configuring an xhttp inbound with a non-default
xPaddingBytes, or enabling obfs mode with a customxPaddingKey/xPaddingHeader/xPaddingPlacement/xPaddingMethod, end up with working server settings but a client link that doesn't mention any of them. The client keeps xray / sing-box's internal defaults, every request it sends fails the server's padding validation and the inbound log fills withWith the custom-key case, xray ends up looking for a header/cookie that the client never sets, so the key-side of the error looks like
key=""to the admin. The client-visible symptom is "no matter what I put in Padding Key, only the defaultx_padding+ Referer actually work" — user reports on OpenWRT / Podkop / sing-box.This PR closes the gap in every place where 3x-ui generates a link from an xhttp stream.
What was dropped before
All four link generators only copied
path,host,modeout ofxhttpSettingsand silently discarded:xPaddingBytesxPaddingObfsModexPaddingKeyxPaddingHeaderxPaddingPlacementxPaddingMethodThis happened both in:
sub/subService.go— the subscription service that serves/sub/<id>to external clients,web/assets/js/model/inbound.js— the panel's own "Copy URL" / QR / Info buttons in the inbound details modal.So regardless of how the admin obtained the link (fetching a subscription or copying from the panel UI), the padding settings never reached them.
Fix
Three files, three mirrored changes:
sub/subService.go(server-side)New helper
applyXhttpPaddingParams(xhttp, params)writes two encodings side-by-side:x_padding_bytes=<range>— flat query param, read by sing-box-family clients (Podkop, OpenWRT sing-box, Karing, NekoBox, …).extra=<url-encoded JSON>— full xhttp settings blob, read by xray-core-family clients (v2rayNG, Happ, Furious, Exclave, …), including the obfs-mode key / header / placement / method.Called from
genVlessLink,genTrojanLink,genShadowsocksLink.genVmessLinkcopies the same fields directly into the VMess base64 JSON body.web/assets/js/model/inbound.js(panel UI)Add two static helpers on
Inbound:Inbound.applyXhttpPaddingToParams(xhttp, params)— forvless:///trojan:///ss://URLs. Same two-encoding scheme as the Go helper.Inbound.applyXhttpPaddingToObj(xhttp, obj)— for the VMess JSON blob.Called from
genVmessLink,genVLESSLink,genTrojanLink,genSSLink.web/assets/js/model/outbound.js(latent positional-arg bug)Both the VMess-JSON path (L933) and
fromParamLink(L975) were calling:The constructor signature is
(path, host, headers, scMaxBufferedPosts, scMaxEachPostBytes, scStreamUpServerSecs, noSSEHeader, xPaddingBytes, mode, …), somodewas silently landing in theheadersslot and the realmodefield kept its"auto"default.Fixed by constructing the object with only
path/hostpositionally and settingmodeby name. While touching the VLESS URL parser, also pick upx_padding_bytesand theextraJSON blob from the imported URL so the symmetric import of a padded link works too.Zero-impact on simple inbounds
All additions guard on "is the field actually set?" — empty strings and
xPaddingObfsMode: falseare skipped. An inbound that uses the UI defaults produces the exact same URL it produced before this patch, so existing subscriptions / deep-links are unaffected.Test plan
go build ./...+go vet ./sub/...cleanxPaddingBytes="80-600"only → URL gainsx_padding_bytes=80-600andextra={"xPaddingBytes":"80-600"}; obfs-only fields not emittedxPaddingKey="remixsid"+xPaddingHeader="Cookie"+ placement/method → all set values land inextra; empty ones are omitted so xray falls back to its own defaultsgenVmessLink/genVLESSLink/genTrojanLink/genSSLink) or from/sub/<id>x_padding_bytes=...and/orextra=...into an outbound now round-trips mode and the padding settings, instead of dropping mode into the headers slot🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.