fix: expose streamSettings for Tunnel inbounds to support TProxy (#5171)

* fix: expose streamSettings for Tunnel inbounds to support TProxy

* fix(ui): hide security tab for tunnel inbounds when stream is enabled

tunnel (dokodemo-door) does not support TLS or Reality, so showing the
security tab only results in a fully-disabled radio group. Exclude tunnel
alongside wireguard from the security tab.

* fix(tunnel): restrict stream tab to sockopt-only and fix transportless schema

Tunnel (dokodemo-door) only needs sockopt.tproxy for TProxy mode — no
user-selectable transport. Add hasSelectableTransport flag to hide the
network picker, per-network sub-forms, ExternalProxy, and FinalMask for
both tunnel and wireguard, matching the pattern already used for Hysteria.

Fix a pre-existing Zod schema bug where NetworkSettingsSchema was a bare
discriminatedUnion requiring `network` to be present. Wireguard and
tunnel submit streamSettings without a `network` key, causing
"Invalid discriminator value. Expected 'tcp' | ..." on every save. Fix
by adding a transportless union branch (z.never().optional()) alongside
the transport DU; also add ?? 'tcp' fallback in inbound-link.ts where
stream.network is now string | undefined. Three regression tests added.

---------

Co-authored-by: rqzbeh <rqzbeh@users.noreply.github.com>
Co-authored-by: MHSanaei <ho3ein.sanaei@gmail.com>
This commit is contained in:
Rouzbeh†
2026-06-11 11:05:42 +02:00
committed by GitHub
parent 57e9661758
commit 1ad483ede6
6 changed files with 125 additions and 43 deletions
+3 -3
View File
@@ -317,7 +317,7 @@ export function genVlessLink(input: GenVlessLinkInput): string {
const security = forceTls === 'same' ? stream.security : forceTls;
const params = new URLSearchParams();
params.set('type', stream.network);
params.set('type', stream.network ?? 'tcp');
params.set('encryption', inbound.settings.encryption);
if (stream.network === 'tcp') {
@@ -501,7 +501,7 @@ export function genTrojanLink(input: GenTrojanLinkInput): string {
const security = forceTls === 'same' ? stream.security : forceTls;
const params = new URLSearchParams();
params.set('type', stream.network);
params.set('type', stream.network ?? 'tcp');
writeNetworkParams(stream, params);
applyFinalMaskToParams(stream.finalmask, params);
@@ -558,7 +558,7 @@ export function genShadowsocksLink(input: GenShadowsocksLinkInput): string {
const security = forceTls === 'same' ? stream.security : forceTls;
const params = new URLSearchParams();
params.set('type', stream.network);
params.set('type', stream.network ?? 'tcp');
writeNetworkParams(stream, params);
applyFinalMaskToParams(stream.finalmask, params);
@@ -9,7 +9,7 @@ const TLS_ELIGIBLE_PROTOCOLS = ['vmess', 'vless', 'trojan', 'shadowsocks'];
const TLS_NETWORKS = ['tcp', 'ws', 'http', 'grpc', 'httpupgrade', 'xhttp'];
const REALITY_ELIGIBLE_PROTOCOLS = ['vless', 'trojan'];
const REALITY_NETWORKS = ['tcp', 'http', 'grpc', 'xhttp'];
const STREAM_PROTOCOLS = ['vmess', 'vless', 'trojan', 'shadowsocks', 'hysteria', 'wireguard'];
const STREAM_PROTOCOLS = ['vmess', 'vless', 'trojan', 'shadowsocks', 'hysteria', 'wireguard', 'tunnel'];
const VISION_FLOW = 'xtls-rprx-vision';
const SS_2022_PREFIX = '2022';
const SS_BLAKE3_CHACHA20 = '2022-blake3-chacha20-poly1305';