mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-22 23:32:19 +07:00
3ba43bd86db556e58575411273284c0eecdba86d
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ae9bbdf267 |
fix(web): serve panel SPA routes from NoRoute (#5536)
* fix(web): serve panel SPA routes from NoRoute Return the React shell for authenticated panel document routes that are not explicitly registered in Gin, such as /panel/hosts. Keep API, CSRF, static-file, method, and Accept exclusions so API misses remain 404 and auth semantics stay unchanged. * fix(web): remove unreachable panel path guard The panel path is always built by appending /panel, so it can never be empty. Remove the redundant fallback branch without changing SPA routing behavior. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(web): allowlist static-asset extensions in SPA fallback The blanket path.Ext check rejected any panel route whose last segment contained a dot, which would reintroduce the refresh 404 for a future client route carrying a dotted parameter (version, domain, or email-like value). Restrict the static-asset exclusion to a known, case-insensitive extension allowlist and add predicate regression cases. |
||
|
|
1a4aef3353 |
feat(sub): full XHTTP field mapping for Clash/Mihomo subscriptions (#5417)
* 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 |
||
|
|
d01d9867e4 |
fix(sub): preserve non-default scMinPostsIntervalMs and use per-inbound xmux in JSON subscriptions (#5393)
* fix(sub): preserve non-default scMinPostsIntervalMs in inbound wire payload
The frontend wire normalizer unconditionally deleted scMinPostsIntervalMs
from inbound configs before persisting to the database, so JSON
subscriptions could never include it — even when the admin set a
non-default value like "50-150".
Only strip the xray-core default ("30") or empty values. The literal
"30" is a known DPI fingerprint (#5141) and must still be removed, but
custom tuning knobs must survive the round-trip so that buildXhttpExtra
and the JSON subscription generator can propagate them to clients.
Add tests for non-default preservation and empty-value stripping.
* fix(sub): use per-inbound xmux instead of global subJsonMux in JSON subscriptions
The JSON subscription generator always used the global subJsonMux panel
setting for outbound.Mux, even when the inbound carried per-inbound xmux
inside xhttpSettings. This meant XHTTP outbounds that configured their own
multiplexing via xmux still got the legacy mux.cool block injected — and
the inbound's own xmux was silently ignored.
Now getConfig() checks whether xmux is present in the inbound's
xhttpSettings. When it is, the per-inbound xmux handles multiplexing
and the legacy outbound.Mux is suppressed. When xmux is absent, the
global subJsonMux is used as before.
The mux selection is threaded through genVless, genVnext, genServer,
and genHy as an explicit parameter so each protocol handler can decide
independently.
Add tests:
- xmux present → outbound.Mux suppressed, xmux survives streamData()
- no xmux → global subJsonMux used as outbound.Mux
* feat(ui): add scMinPostsIntervalMs to inbound XHTTP form
The inbound XHTTP form was missing scMinPostsIntervalMs, making it impossible
for admins to configure this client-only tuning knob through the panel. The
field already existed in the Zod schema and outbound form, and the wire
normalizer (PR #5393) now preserves non-default values for subscription
propagation.
Add Form.Item for scMinPostsIntervalMs in the packet-up section of the
inbound XHTTP form, after scMaxEachPostBytes. Use the existing translation
key and a placeholder that shows the range format without endorsing the
DPI-fingerprinted default (30).
Update the Zod schema comment to clarify that scMinPostsIntervalMs is now
preserved on inbound for subscriptions, while uplinkChunkSize and
noGRPCHeader remain outbound-only.
Add two integration tests:
- Non-default value (50-150) preserved through formValuesToWirePayload
- Default value (30) stripped through the full pipeline
* fix(ui): show packet-up fields for auto mode in inbound XHTTP form
When mode is 'auto', the server accepts all three XHTTP modes including
packet-up. The packet-up-specific fields (scMaxBufferedPosts,
scMaxEachPostBytes, scMinPostsIntervalMs) are therefore relevant and
should be configurable.
Change the conditional from 'packet-up' only to
'packet-up || auto' so admins using the default 'auto' mode can
configure these fields.
* fix(outbound): show scMinPostsIntervalMs for auto mode, update placeholder
- Show scMinPostsIntervalMs field when mode is 'auto' in addition
to 'packet-up', since auto+TLS resolves to packet-up client-side
- Change placeholder from '30' (DPI fingerprint) to 'e.g. 50-150'
for consistency with inbound form
* fix(inbound): show scMaxEachPostBytes for all modes, gate scMaxBufferedPosts behind packet-up/auto
scMaxEachPostBytes is used by xray-core in every mode (both handlePacketUp
and handleStreamUp validate it) and must be visible regardless of mode.
scMaxBufferedPosts is only used by handlePacketUp, so it remains gated
behind the packet-up/auto conditional.
Also show scMinPostsIntervalMs for auto mode in outbound form and change
placeholder from '30' (DPI fingerprint) to 'e.g. 50-150'.
Update snapshot to reflect the new field order.
* fix(inbound): correct XHTTP field visibility per xray-core source verification
- scMaxEachPostBytes: move behind packet-up/auto gate (server only checks
it in handlePacketUp, not handleStreamUp)
- scMaxBufferedPosts: show for packet-up, stream-up, and auto (server
uses uploadQueue in both handlePacketUp and handleStreamUp)
- scStreamUpServerSecs: already correct (stream-up only)
Verified against xray-core hub.go and dialer.go source code.
---------
Co-authored-by: w3struk <w3struk@gmail.com>
Co-authored-by: MHSanaei <ho3ein.sanaei@gmail.com>
|
||
|
|
ec45d3491a |
fix: derive JSON/Clash subscription URLs from configured subURI (#5203)
* fix: derive JSON/Clash subscription URLs from configured subURI When subURI is explicitly configured (reverse-proxy setup) but subJsonURI or subClashURI are not, BuildSubURIBase generates URLs with the raw sub- server port (2096) and the wrong scheme (http), producing broken links on the subscription page (e.g. http://domain:2096/json/SUB_ID). Fix: in BuildURLs, when subURI is set, extract its scheme+host and use that as the base for all unconfigured sibling URLs instead of calling BuildSubURIBase. This ensures JSON and Clash Copy URLs match the reverse- proxy endpoint. Fixes: JSON/Clash subscription URLs shown on the subscription info page now correctly inherit the configured subURI's scheme and host. * fix(sub): fall back to request base when configured subURI is unparseable Harden the JSON/Clash URL derivation added for the reverse-proxy fix: extractBaseFromURI now returns "" when the configured subURI has no scheme/host, and BuildURLs falls back to the request-derived base in that case instead of emitting a broken value (e.g. ":///json/ABC"). Add a regression test covering a scheme-less subURI. --------- Co-authored-by: w3struk <w3struk@gmail.com> Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com> |