mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #5416] [CLOSED] feat(sub): full XHTTP field mapping for Clash/Mihomo subscriptions #5876
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#5876
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/5416
Author: @w3struk
Created: 6/17/2026
Status: ❌ Closed
Base:
main← Head:fix/clash-xhttp-opts📝 Commits (6)
5ddb05afix(sub): preserve non-default scMinPostsIntervalMs in inbound wire payload4a31f92fix(sub): use per-inbound xmux instead of global subJsonMux in JSON subscriptionsd1fd93efeat(ui): add scMinPostsIntervalMs to inbound XHTTP form2ae9efffix(ui): show packet-up fields for auto mode in inbound XHTTP formbf7c4c3feat(sub): add full XHTTP field mapping for Clash subscriptions321549ctest(sub): add comprehensive tests for buildXhttpClashOpts📊 Changes
9 files changed (+832 additions, -50 deletions)
View changed files
📝
frontend/src/lib/xray/stream-wire-normalize.ts(+6 -1)📝
frontend/src/pages/inbounds/form/transport/xhttp.tsx(+7 -1)📝
frontend/src/schemas/protocols/stream/xhttp.ts(+6 -3)📝
frontend/src/test/stream-wire-normalize.test.ts(+118 -0)📝
internal/sub/clash_service.go(+124 -19)📝
internal/sub/clash_service_test.go(+454 -0)📝
internal/sub/json_service.go(+26 -16)📝
internal/sub/json_service_test.go(+85 -4)📝
internal/sub/mutation_audit_test.go(+6 -6)📄 Description
Summary
The Clash subscription generator (
clash_service.go) only emittedpath,host,modeinxhttp-opts. Mihomo supports ALL XHTTP parameters including padding, xmux (asreuse-settings), session/seq placement, and more.This PR adds
buildXhttpClashOpts()— an allowlist-based function that maps all client-relevant XHTTP fields from 3x-ui's camelCase JSON storage to Mihomo's kebab-case YAML format.Changes
internal/sub/clash_service.gobuildXhttpClashOpts()(lines 363-473): ConvertsxhttpSettingsmap to Mihomo-compatiblexhttp-optsmapscMaxEachPostBytes="1000000",scMinPostsIntervalMs="30")noGRPCHeader,xPaddingObfsModexPaddingObfsMode=truexmux→reuse-settingswith kebab-case sub-field mappingnilfor empty opts (consistent withbuildXhttpExtra)applyTransportxhttp case (lines 547-554): Delegates tobuildXhttpClashOptsinternal/sub/clash_service_test.goTestBuildXhttpClashOpts_FullFieldMapping— every kebab-case key verifiedTestBuildXhttpClashOpts_DPIDefaultsFiltered— DPI fingerprint defaults filteredTestBuildXhttpClashOpts_PaddingObfsGate— false/absent/true-with-no-gated-fieldsTestBuildXhttpClashOpts_XmuxMapsToReuseSettings— full mapping, empty, int/float64/zero hKeepAlivePeriodTestBuildXhttpClashOpts_ServerOnlyFieldsExcluded— noSSEHeader, scMaxBufferedPosts, etc.TestBuildXhttpClashOpts_NilInput/_EmptyInput— return nilTestBuildXhttpClashOpts_HostFallbackFromHeaders— headers.Host, only-Host, case-insensitive dropTestBuildXhttpClashOpts_NoGRPCHeaderFalsey— false and absent both produce no keyField Mapping (source-verified against Mihomo
adapter/outbound/vless.go)pathpathhosthostmodemodeheadersheadersnoGRPCHeaderno-grpc-headerxPaddingBytesx-padding-bytesxPaddingObfsModex-padding-obfs-modexPaddingKeyx-padding-keyxPaddingHeaderx-padding-headerxPaddingPlacementx-padding-placementxPaddingMethodx-padding-methoduplinkHTTPMethoduplink-http-methodsessionPlacementsession-placementsessionKeysession-keyseqPlacementseq-placementseqKeyseq-keyuplinkDataPlacementuplink-data-placementuplinkDataKeyuplink-data-keyuplinkChunkSizeuplink-chunk-sizescMaxEachPostBytessc-max-each-post-bytesscMinPostsIntervalMssc-min-posts-interval-msxmuxreuse-settingsXMUX → reuse-settings sub-fields
|
maxConcurrency|max-concurrency| string | non-empty ||
maxConnections|max-connections| string | non-empty ||
cMaxReuseTimes|c-max-reuse-times| string | non-empty ||
hMaxRequestTimes|h-max-request-times| string | non-empty ||
hMaxReusableSecs|h-max-reusable-secs| string | non-empty ||
hKeepAlivePeriod|h-keep-alive-period| int | non-zero |Server-only fields (EXCLUDED — not in allowlist)
noSSEHeader,scMaxBufferedPosts,scStreamUpServerSecs,serverMaxHeaderBytesDeferred to follow-up PR
downloadSettings→download-settings(complex nested structure)Testing
TestApplyTransport_XHTTPandTestApplyTransport_XHTTP_HostFromHeadersstill passRelated
adapter/outbound/vless.gostruct tags)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.