fix: correct know file issues
Some checks are pending
Docker Build and Publish / build (push) Waiting to run

This commit is contained in:
xboard 2025-01-12 23:57:24 +08:00
parent efe8c2a96d
commit 1926d6a867
7 changed files with 66 additions and 30 deletions

View File

@ -153,7 +153,9 @@ class Clash implements ProtocolInterface
if (data_get($protocol_settings, 'tls')) { if (data_get($protocol_settings, 'tls')) {
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure');
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$array['servername'] = $serverName;
}
} }
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
@ -193,7 +195,9 @@ class Clash implements ProtocolInterface
$array['port'] = $server['port']; $array['port'] = $server['port'];
$array['password'] = $password; $array['password'] = $password;
$array['udp'] = true; $array['udp'] = true;
$array['sni'] = data_get($protocol_settings, 'server_name'); if ($serverName = data_get($protocol_settings, 'server_name')) {
$array['sni'] = $serverName;
}
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'allow_insecure'); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'allow_insecure');
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {

View File

@ -204,7 +204,9 @@ class ClashMeta implements ProtocolInterface
case 1: case 1:
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure', false); $array['skip-cert-verify'] = (bool) data_get($protocol_settings, 'tls_settings.allow_insecure', false);
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$array['servername'] = $serverName;
}
break; break;
case 2: case 2:
$array['tls'] = true; $array['tls'] = true;
@ -258,9 +260,11 @@ class ClashMeta implements ProtocolInterface
'port' => $server['port'], 'port' => $server['port'],
'password' => $password, 'password' => $password,
'udp' => true, 'udp' => true,
'sni' => data_get($protocol_settings, 'server_name'),
'skip-cert-verify' => (bool) data_get($protocol_settings, 'allow_insecure', false) 'skip-cert-verify' => (bool) data_get($protocol_settings, 'allow_insecure', false)
]; ];
if ($serverName = data_get($protocol_settings, 'server_name')) {
$array['sni'] = $serverName;
}
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'grpc': case 'grpc':

View File

@ -77,8 +77,10 @@ class General implements ProtocolInterface
"host" => "", "host" => "",
"path" => "", "path" => "",
"tls" => $protocol_settings['tls'] ? "tls" : "", "tls" => $protocol_settings['tls'] ? "tls" : "",
"sni" => data_get($protocol_settings, 'tls_settings.server_name'),
]; ];
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$config['sni'] = $serverName;
}
switch ($protocol_settings['network']) { switch ($protocol_settings['network']) {
case 'tcp': case 'tcp':
@ -123,7 +125,9 @@ class General implements ProtocolInterface
switch ($server['protocol_settings']['tls']) { switch ($server['protocol_settings']['tls']) {
case 1: case 1:
$config['security'] = "tls"; $config['security'] = "tls";
$config['sni'] = data_get($protocol_settings, 'tls_settings.server_name'); if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$config['sni'] = $serverName;
}
break; break;
case 2: //reality case 2: //reality
$config['security'] = "reality"; $config['security'] = "reality";
@ -175,11 +179,13 @@ class General implements ProtocolInterface
{ {
$protocol_settings = $server['protocol_settings']; $protocol_settings = $server['protocol_settings'];
$name = rawurlencode($server['name']); $name = rawurlencode($server['name']);
$query = http_build_query([ $array = [];
'allowInsecure' => $protocol_settings['allow_insecure'], $array['allowInsecure'] = $protocol_settings['allow_insecure'];
'peer' => $protocol_settings['server_name'], if ($serverName = data_get($protocol_settings, 'server_name')) {
'sni' => $protocol_settings['server_name'] $array['peer'] = $serverName;
]); $array['sni'] = $serverName;
}
$query = http_build_query($array);
$uri = "trojan://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}"; $uri = "trojan://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}";
$uri .= "\r\n"; $uri .= "\r\n";
return $uri; return $uri;
@ -194,8 +200,8 @@ class General implements ProtocolInterface
return ''; return '';
} }
if (data_get($protocol_settings, 'tls.server_name')) { if ($serverName = data_get($protocol_settings, 'tls.server_name')) {
$params['sni'] = data_get($protocol_settings, 'tls.server_name'); $params['sni'] = $serverName;
$params['security'] = 'tls'; $params['security'] = 'tls';
} }

View File

@ -145,7 +145,7 @@ class Loon implements ProtocolInterface
'fast-open=false', 'fast-open=false',
'udp=true' 'udp=true'
]; ];
if (!empty($server['allow_insecure'])) { if (!empty($protocol_settings['allow_insecure'])) {
array_push($config, data_get($protocol_settings, 'tls_settings')['allow_insecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); array_push($config, data_get($protocol_settings, 'tls_settings')['allow_insecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false');
} }
$config = array_filter($config); $config = array_filter($config);

View File

@ -145,7 +145,9 @@ class Shadowrocket implements ProtocolInterface
case 1: case 1:
$config['tls'] = 1; $config['tls'] = 1;
$config['allowInsecure'] = (int) data_get($protocol_settings, 'tls_settings.allow_insecure'); $config['allowInsecure'] = (int) data_get($protocol_settings, 'tls_settings.allow_insecure');
$config['peer'] = data_get($protocol_settings, 'tls_settings.server_name'); if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$config['peer'] = $serverName;
}
break; break;
case 2: case 2:
$config['tls'] = 1; $config['tls'] = 1;
@ -187,10 +189,10 @@ class Shadowrocket implements ProtocolInterface
{ {
$protocol_settings = $server['protocol_settings']; $protocol_settings = $server['protocol_settings'];
$name = rawurlencode($server['name']); $name = rawurlencode($server['name']);
$params = [ $params['allowInsecure'] = data_get($protocol_settings, 'tls.allow_insecure');
'allowInsecure' => data_get($protocol_settings, 'tls.allow_insecure'), if ($serverName = data_get($protocol_settings, 'tls.server_name')) {
'peer' => data_get($protocol_settings, 'tls.server_name') $params['peer'] = $serverName;
]; }
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'grpc': case 'grpc':
$params['obfs'] = 'grpc'; $params['obfs'] = 'grpc';
@ -218,9 +220,11 @@ class Shadowrocket implements ProtocolInterface
"upmbps" => data_get($protocol_settings, 'bandwidth.up'), "upmbps" => data_get($protocol_settings, 'bandwidth.up'),
"downmbps" => data_get($protocol_settings, 'bandwidth.down'), "downmbps" => data_get($protocol_settings, 'bandwidth.down'),
"protocol" => 'udp', "protocol" => 'udp',
"peer" => data_get($protocol_settings, 'tls.server_name'),
"fastopen" => 1, "fastopen" => 1,
]; ];
if ($serverName = data_get($protocol_settings, 'tls.server_name')) {
$params['peer'] = $serverName;
}
if (data_get($protocol_settings, 'obfs.open')) { if (data_get($protocol_settings, 'obfs.open')) {
$params["obfs"] = "xplus"; $params["obfs"] = "xplus";
$params["obfsParam"] = data_get($protocol_settings, 'obfs_settings.password'); $params["obfsParam"] = data_get($protocol_settings, 'obfs_settings.password');
@ -234,10 +238,12 @@ class Shadowrocket implements ProtocolInterface
break; break;
case 2: case 2:
$params = [ $params = [
"peer" => data_get($protocol_settings, 'tls.server_name'),
"obfs" => 'none', "obfs" => 'none',
"fastopen" => 1 "fastopen" => 1
]; ];
if ($serverName = data_get($protocol_settings, 'tls.server_name')) {
$params['peer'] = $serverName;
}
if (data_get($protocol_settings, 'obfs.open')) { if (data_get($protocol_settings, 'obfs.open')) {
$params['obfs'] = data_get($protocol_settings, 'obfs.type'); $params['obfs'] = data_get($protocol_settings, 'obfs.type');
$params['obfs-password'] = data_get($protocol_settings, 'obfs.password'); $params['obfs-password'] = data_get($protocol_settings, 'obfs.password');

View File

@ -128,9 +128,11 @@ class SingBox implements ProtocolInterface
'tls' => $protocol_settings['tls'] ? [ 'tls' => $protocol_settings['tls'] ? [
'enabled' => true, 'enabled' => true,
'insecure' => (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'), 'insecure' => (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'),
'server_name' => data_get($protocol_settings, 'tls_settings.server_name')
] : null ] : null
]; ];
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$array['tls']['server_name'] = $serverName;
}
$transport = match ($protocol_settings['network']) { $transport = match ($protocol_settings['network']) {
'tcp' => [ 'tcp' => [
@ -174,12 +176,14 @@ class SingBox implements ProtocolInterface
$tlsConfig = [ $tlsConfig = [
'enabled' => true, 'enabled' => true,
'insecure' => (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'), 'insecure' => (bool) data_get($protocol_settings, 'tls_settings.allow_insecure'),
'server_name' => data_get($protocol_settings, 'tls_settings.server_name'),
'utls' => [ 'utls' => [
'enabled' => true, 'enabled' => true,
'fingerprint' => Helper::getRandFingerprint() 'fingerprint' => Helper::getRandFingerprint()
] ]
]; ];
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$tlsConfig['server_name'] = $serverName;
}
if ($protocol_settings['tls'] == 2) { if ($protocol_settings['tls'] == 2) {
$tlsConfig['reality'] = [ $tlsConfig['reality'] = [
'enabled' => true, 'enabled' => true,
@ -194,7 +198,7 @@ class SingBox implements ProtocolInterface
$transport = match ($protocol_settings['network']) { $transport = match ($protocol_settings['network']) {
'tcp' => data_get($protocol_settings, 'network_settings.header.type') == 'http' ? [ 'tcp' => data_get($protocol_settings, 'network_settings.header.type') == 'http' ? [
'type' => 'http', 'type' => 'http',
'path' => data_get($protocol_settings, 'network_settings.header.request.path') 'path' => \Arr::random(data_get($protocol_settings, 'network_settings.header.request.path', ['/']))
] : null, ] : null,
'ws' => array_filter([ 'ws' => array_filter([
'type' => 'ws', 'type' => 'ws',
@ -240,9 +244,11 @@ class SingBox implements ProtocolInterface
'tls' => [ 'tls' => [
'enabled' => true, 'enabled' => true,
'insecure' => (bool) data_get($protocol_settings, 'allow_insecure', false), 'insecure' => (bool) data_get($protocol_settings, 'allow_insecure', false),
'server_name' => data_get($protocol_settings, 'server_name')
] ]
]; ];
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$array['tls']['server_name'] = $serverName;
}
$transport = match (data_get($protocol_settings, 'network')) { $transport = match (data_get($protocol_settings, 'network')) {
'grpc' => [ 'grpc' => [
'type' => 'grpc', 'type' => 'grpc',
@ -271,9 +277,11 @@ class SingBox implements ProtocolInterface
'tls' => [ 'tls' => [
'enabled' => true, 'enabled' => true,
'insecure' => (bool) $protocol_settings['tls']['allow_insecure'], 'insecure' => (bool) $protocol_settings['tls']['allow_insecure'],
'server_name' => $protocol_settings['tls']['server_name']
] ]
]; ];
if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$baseConfig['tls']['server_name'] = $serverName;
}
$speedConfig = [ $speedConfig = [
'up_mbps' => $protocol_settings['bandwidth']['up'], 'up_mbps' => $protocol_settings['bandwidth']['up'],
'down_mbps' => $protocol_settings['bandwidth']['down'], 'down_mbps' => $protocol_settings['bandwidth']['down'],

View File

@ -142,7 +142,9 @@ class Stash implements ProtocolInterface
$array['tls'] = data_get($protocol_settings, 'tls'); $array['tls'] = data_get($protocol_settings, 'tls');
$array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure'); $array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure');
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$array['servername'] = $serverName;
}
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
case 'tcp': case 'tcp':
@ -186,7 +188,9 @@ class Stash implements ProtocolInterface
case 1: case 1:
$array['tls'] = true; $array['tls'] = true;
$array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure'); $array['skip-cert-verify'] = data_get($protocol_settings, 'tls_settings.allow_insecure');
$array['servername'] = data_get($protocol_settings, 'tls_settings.server_name'); if ($serverName = data_get($protocol_settings, 'tls_settings.server_name')) {
$array['servername'] = $serverName;
}
break; break;
case 2: case 2:
$array['tls'] = true; $array['tls'] = true;
@ -241,7 +245,9 @@ class Stash implements ProtocolInterface
$array['ws-opts']['headers'] = data_get($protocol_settings, 'network_settings.headers.Host') ? ['Host' => data_get($protocol_settings, 'network_settings.headers.Host')] : null; $array['ws-opts']['headers'] = data_get($protocol_settings, 'network_settings.headers.Host') ? ['Host' => data_get($protocol_settings, 'network_settings.headers.Host')] : null;
break; break;
} }
$array['sni'] = data_get($protocol_settings, 'server_name'); if ($serverName = data_get($protocol_settings, 'server_name')) {
$array['sni'] = $serverName;
}
$array['skip-cert-verify'] = data_get($protocol_settings, 'allow_insecure'); $array['skip-cert-verify'] = data_get($protocol_settings, 'allow_insecure');
return $array; return $array;
} }
@ -255,7 +261,9 @@ class Stash implements ProtocolInterface
$array['up-speed'] = data_get($protocol_settings, 'bandwidth.up'); $array['up-speed'] = data_get($protocol_settings, 'bandwidth.up');
$array['down-speed'] = data_get($protocol_settings, 'bandwidth.down'); $array['down-speed'] = data_get($protocol_settings, 'bandwidth.down');
$array['skip-cert-verify'] = data_get($protocol_settings, 'tls.allow_insecure'); $array['skip-cert-verify'] = data_get($protocol_settings, 'tls.allow_insecure');
$array['sni'] = data_get($protocol_settings, 'tls.server_name') ?? ''; if ($serverName = data_get($protocol_settings, 'tls.server_name')) {
$array['sni'] = $serverName;
}
switch (data_get($protocol_settings, 'version')) { switch (data_get($protocol_settings, 'version')) {
case 1: case 1:
$array['type'] = 'hysteria'; $array['type'] = 'hysteria';