mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-06-28 00:24:19 +00:00
1a4aef3353
* feat(sub): add full XHTTP field mapping for Clash subscriptions The Clash subscription generator only emitted path, host, mode in xhttp-opts. Mihomo supports all XHTTP parameters including padding, xmux (reuse-settings), session/seq placement, and more. Add buildXhttpClashOpts() that maps all client-relevant XHTTP fields from 3x-ui's camelCase JSON storage to Mihomo's kebab-case YAML format using an explicit allowlist approach. Field mapping (source-verified against Mihomo adapter/outbound/vless.go): - String fields: xPaddingBytes→x-padding-bytes, sessionPlacement→ session-placement, etc. (10 fields with DPI default filtering) - Bool fields: noGRPCHeader→no-grpc-header, xPaddingObfsMode→ x-padding-obfs-mode (with gated sub-fields) - Nested: xmux→reuse-settings (6 sub-fields with kebab-case) - Headers: pass through with Host key dropped - Server-only fields automatically excluded (not in allowlist) DPI defaults filtered: scMaxEachPostBytes="1000000", scMinPostsIntervalMs="30" (known DPI fingerprint) * test(sub): add comprehensive tests for buildXhttpClashOpts 9 test functions covering all field mapping categories: - FullFieldMapping: every kebab-case key verified - DPIDefaultsFiltered: scMaxEachPostBytes=1000000 and scMinPostsIntervalMs=30 - PaddingObfsGate: false/absent/true-with-no-gated-fields - XmuxMapsToReuseSettings: full mapping, empty, int/float64/zero hKeepAlivePeriod - ServerOnlyFieldsExcluded: noSSEHeader, scMaxBufferedPosts, etc. - NilInput and EmptyInput: return nil - HostFallbackFromHeaders: headers.Host, only-Host, case-insensitive drop - NoGRPCHeaderFalsey: false and absent both produce no key * fix(sub): clean up redundant skipValue check and add missing xhttp no-settings test - In buildXhttpClashOpts, change string-field loop condition so that skipValue == "" means "no filter" rather than redundantly comparing v against "" twice (xPaddingBytes was the affected entry) - Add TestApplyTransport_XHTTP_NoSettings to pin the behaviour when xhttpSettings is absent: applyTransport returns true, network is set to "xhttp", and xhttp-opts is not emitted