Merge pull request #612 from xcxnig/patch-1

fix(stash): fix Flow network and SNI issues
This commit is contained in:
Xboard
2025-08-08 02:44:58 +08:00
committed by GitHub
+12 -2
View File
@@ -253,6 +253,9 @@ class Stash extends AbstractProtocol
case 'tcp': case 'tcp':
$array['network'] = data_get($protocol_settings, 'network_settings.header.type', 'http'); $array['network'] = data_get($protocol_settings, 'network_settings.header.type', 'http');
$array['http-opts']['path'] = data_get($protocol_settings, 'network_settings.header.request.path', ['/']); $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':
$array['network'] = 'ws'; $array['network'] = 'ws';
@@ -295,16 +298,24 @@ class Stash extends AbstractProtocol
break; break;
case 2: case 2:
$array['tls'] = true; $array['tls'] = true;
if ($serverName = data_get($protocol_settings, 'reality_settings.server_name')) {
$array['servername'] = $serverName;
$array['sni'] = $serverName;
}
$array['flow'] = data_get($protocol_settings, 'flow');
$array['reality-opts'] = [ $array['reality-opts'] = [
'public-key' => data_get($protocol_settings, 'reality_settings.public_key'), 'public-key' => data_get($protocol_settings, 'reality_settings.public_key'),
'short-id' => data_get($protocol_settings, 'reality_settings.short_id') 'short-id' => data_get($protocol_settings, 'reality_settings.short_id')
]; ];
break;
} }
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'); if ($headerType = data_get($protocol_settings, 'network_settings.header.type', 'tcp') != 'tcp') {
$array['network'] = $headerType;
$array['http-opts']['path'] = data_get($protocol_settings, 'network_settings.header.request.path', ['/']); $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';
@@ -384,7 +395,6 @@ class Stash extends AbstractProtocol
break; break;
} }
return $array; return $array;
} }
public static function buildTuic($password, $server) public static function buildTuic($password, $server)