Fixed General.php

This commit is contained in:
NekoCareLab 2025-01-16 14:58:05 +08:00
parent 7cf839488b
commit e0e76a22ea
No known key found for this signature in database

View File

@ -92,14 +92,15 @@ class General implements ProtocolInterface
break; break;
case 'ws': case 'ws':
$config['type'] = 'ws'; $config['type'] = 'ws';
$config['path'] = data_get($protocol_settings, 'network_settings.path'); if ($path = data_get($protocol_settings, 'network_settings.path'))
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) { $config['path'] = $path;
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
$config['host'] = $host; $config['host'] = $host;
}
break; break;
case 'grpc': case 'grpc':
$config['type'] = 'grpc'; $config['type'] = 'grpc';
$config['path'] = data_get($protocol_settings, 'network_settings.serviceName'); if ($path = data_get($protocol_settings, 'network_settings.serviceName'))
$config['path'] = $path;
break; break;
default: default:
break; break;
@ -144,20 +145,23 @@ class General implements ProtocolInterface
// 处理传输协议 // 处理传输协议
switch ($server['protocol_settings']['network']) { switch ($server['protocol_settings']['network']) {
case 'ws': case 'ws':
$config['path'] = data_get($protocol_settings, 'network_settings.path'); if ($path = data_get($protocol_settings, 'network_settings.path'))
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) { $config['path'] = $path;
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
$config['host'] = $host; $config['host'] = $host;
}
break; break;
case 'grpc': case 'grpc':
$config['serviceName'] = data_get($protocol_settings, 'network_settings.serviceName'); if ($path = data_get($protocol_settings, 'network_settings.serviceName'))
$config['path'] = $path;
break; break;
case 'kcp': case 'kcp':
$config['path'] = data_get($protocol_settings, 'network_settings.seed'); if ($path = data_get($protocol_settings, 'network_settings.seed'))
$config['path'] = $path;
$config['type'] = data_get($protocol_settings, 'network_settings.header.type', 'none'); $config['type'] = data_get($protocol_settings, 'network_settings.header.type', 'none');
break; break;
case 'httpupgrade': case 'httpupgrade':
$config['path'] = data_get($protocol_settings, 'network_settings.path'); if ($path = data_get($protocol_settings, 'network_settings.path'))
$config['path'] = $path;
$config['host'] = data_get($protocol_settings, 'network_settings.host', $server['host']); $config['host'] = data_get($protocol_settings, 'network_settings.host', $server['host']);
break; break;
case 'xhttp': case 'xhttp':
@ -209,7 +213,7 @@ class General implements ProtocolInterface
$params['obfs'] = 'salamander'; $params['obfs'] = 'salamander';
$params['obfs-password'] = data_get($protocol_settings, 'obfs.password'); $params['obfs-password'] = data_get($protocol_settings, 'obfs.password');
} }
if(isset($server['ports'])){ if (isset($server['ports'])) {
$params['mport'] = $server['ports']; $params['mport'] = $server['ports'];
} }