mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
Fixed trojan and polished Vmess/VLESS for General.php and Clash/Meta.php
This commit is contained in:
parent
e0e76a22ea
commit
bc16656371
@ -170,16 +170,17 @@ class Clash implements ProtocolInterface
|
||||
break;
|
||||
case 'ws':
|
||||
$array['network'] = 'ws';
|
||||
$array['ws-opts']['path'] = data_get($protocol_settings, 'network_settings.path', '/');
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) {
|
||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||
$array['ws-opts']['path'] = $path;
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||
}
|
||||
break;
|
||||
case 'grpc':
|
||||
$array['network'] = 'grpc';
|
||||
$array['grpc-opts'] = [
|
||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||
];
|
||||
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $array;
|
||||
@ -206,16 +207,15 @@ class Clash implements ProtocolInterface
|
||||
break;
|
||||
case 'ws':
|
||||
$array['network'] = 'ws';
|
||||
$array['ws-opts']['path'] = data_get($protocol_settings, 'network_settings.path', '/');
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) {
|
||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||
$array['ws-opts']['path'] = $path;
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||
}
|
||||
break;
|
||||
case 'grpc':
|
||||
$array['network'] = 'grpc';
|
||||
$array['grpc-opts'] = [
|
||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||
];
|
||||
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||
break;
|
||||
default:
|
||||
$array['network'] = 'tcp';
|
||||
@ -234,6 +234,6 @@ class Clash implements ProtocolInterface
|
||||
if (empty($exp)) {
|
||||
return false;
|
||||
}
|
||||
return @preg_match((string)$exp, '') !== false;
|
||||
return @preg_match((string) $exp, '') !== false;
|
||||
}
|
||||
}
|
||||
|
@ -167,16 +167,15 @@ class ClashMeta implements ProtocolInterface
|
||||
break;
|
||||
case 'ws':
|
||||
$array['network'] = 'ws';
|
||||
$array['ws-opts'] = [
|
||||
'path' => data_get($protocol_settings, 'network_settings.path'),
|
||||
'headers' => ['Host' => data_get($protocol_settings, 'network_settings.headers.Host', $server['host'])]
|
||||
];
|
||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||
$array['ws-opts']['path'] = $path;
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||
break;
|
||||
case 'grpc':
|
||||
$array['network'] = 'grpc';
|
||||
$array['grpc-opts'] = [
|
||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||
];
|
||||
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -226,23 +225,15 @@ class ClashMeta implements ProtocolInterface
|
||||
switch (data_get($protocol_settings, 'network')) {
|
||||
case 'ws':
|
||||
$array['network'] = 'ws';
|
||||
$array['ws-opts']['path'] = data_get($protocol_settings, 'network_settings.path', '/');
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) {
|
||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||
$array['ws-opts']['path'] = $path;
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||
}
|
||||
break;
|
||||
case 'grpc':
|
||||
$array['network'] = 'grpc';
|
||||
$array['grpc-opts'] = [
|
||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||
];
|
||||
break;
|
||||
case 'h2':
|
||||
$array['network'] = 'h2';
|
||||
$array['h2-opts'] = [
|
||||
'path' => data_get($protocol_settings, 'network_settings.path', '/'),
|
||||
'host' => data_get($protocol_settings, 'network_settings.host')
|
||||
];
|
||||
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -268,20 +259,23 @@ class ClashMeta implements ProtocolInterface
|
||||
}
|
||||
|
||||
switch (data_get($protocol_settings, 'network')) {
|
||||
case 'grpc':
|
||||
$array['network'] = 'grpc';
|
||||
$array['grpc-opts'] = [
|
||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
||||
];
|
||||
case 'tcp':
|
||||
$array['network'] = 'tcp';
|
||||
break;
|
||||
case 'ws':
|
||||
$array['network'] = 'ws';
|
||||
$array['ws-opts']['path'] = data_get($protocol_settings, 'network_settings.path', '/');
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host')) {
|
||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||
$array['ws-opts']['path'] = $path;
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||
}
|
||||
break;
|
||||
case 'grpc':
|
||||
$array['network'] = 'grpc';
|
||||
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||
break;
|
||||
default:
|
||||
$array['network'] = 'tcp';
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -189,6 +189,23 @@ class General implements ProtocolInterface
|
||||
$array['peer'] = $serverName;
|
||||
$array['sni'] = $serverName;
|
||||
}
|
||||
switch ($server['protocol_settings']['network']) {
|
||||
case 'ws':
|
||||
$array['type'] = 'ws';
|
||||
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||
$array['path'] = $path;
|
||||
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||
$array['host'] = $host;
|
||||
break;
|
||||
case 'grpc':
|
||||
// Follow V2rayN family standards
|
||||
$array['type'] = 'grpc';
|
||||
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||
$array['serviceName'] = $serviceName;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$query = http_build_query($array);
|
||||
$uri = "trojan://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}";
|
||||
$uri .= "\r\n";
|
||||
|
Loading…
Reference in New Issue
Block a user