fix(stash): correct TCP/HTTP network type handling in node generation

This commit is contained in:
xboard
2026-03-09 05:35:54 +08:00
parent a90c5c41ea
commit 96cb398315
+15 -8
View File
@@ -251,10 +251,13 @@ class Stash extends AbstractProtocol
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'tcp': case 'tcp':
$array['network'] = data_get($protocol_settings, 'network_settings.header.type', 'http'); $headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp');
$array['http-opts']['path'] = data_get($protocol_settings, 'network_settings.header.request.path', ['/']); $array['network'] = ($headerType === 'http') ? 'http' : 'tcp';
if ($host = data_get($protocol_settings, 'network_settings.header.request.headers.Host')) { if ($headerType === 'http') {
$array['http-opts']['headers']['Host'] = $host; $array['http-opts']['path'] = data_get($protocol_settings, 'network_settings.header.request.path', ['/']);
if ($host = data_get($protocol_settings, 'network_settings.header.request.headers.Host')) {
$array['http-opts']['headers']['Host'] = $host;
}
} }
break; break;
case 'ws': case 'ws':
@@ -312,8 +315,9 @@ class Stash extends AbstractProtocol
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'tcp': case 'tcp':
if ($headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp') != 'tcp') { $headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp');
$array['network'] = $headerType; $array['network'] = ($headerType === 'http') ? 'http' : 'tcp';
if ($headerType === 'http') {
if ($httpOpts = array_filter([ if ($httpOpts = array_filter([
'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'), 'headers' => data_get($protocol_settings, 'network_settings.header.request.headers'),
'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/']) 'path' => data_get($protocol_settings, 'network_settings.header.request.path', ['/'])
@@ -355,8 +359,11 @@ class Stash extends AbstractProtocol
$array['udp'] = true; $array['udp'] = true;
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'tcp': case 'tcp':
$array['network'] = data_get($protocol_settings, 'network_settings.header.type'); $headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp');
$array['http-opts']['path'] = data_get($protocol_settings, 'network_settings.header.request.path', ['/']); $array['network'] = ($headerType === 'http') ? 'http' : 'tcp';
if ($headerType === 'http') {
$array['http-opts']['path'] = data_get($protocol_settings, 'network_settings.header.request.path', ['/']);
}
break; break;
case 'ws': case 'ws':
$array['network'] = 'ws'; $array['network'] = 'ws';