mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
Merge pull request #323 from NekoCareLab/master
Fixed trojan and polished Vmess/VLESS for General.php and Clash/Meta.php
This commit is contained in:
commit
d7b88d7b5d
@ -170,16 +170,17 @@ class Clash implements ProtocolInterface
|
|||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
$array['network'] = 'ws';
|
$array['network'] = 'ws';
|
||||||
$array['ws-opts']['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')) {
|
$array['ws-opts']['path'] = $path;
|
||||||
|
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'grpc':
|
case 'grpc':
|
||||||
$array['network'] = 'grpc';
|
$array['network'] = 'grpc';
|
||||||
$array['grpc-opts'] = [
|
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||||
];
|
break;
|
||||||
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
@ -206,16 +207,15 @@ class Clash implements ProtocolInterface
|
|||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
$array['network'] = 'ws';
|
$array['network'] = 'ws';
|
||||||
$array['ws-opts']['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')) {
|
$array['ws-opts']['path'] = $path;
|
||||||
|
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'grpc':
|
case 'grpc':
|
||||||
$array['network'] = 'grpc';
|
$array['network'] = 'grpc';
|
||||||
$array['grpc-opts'] = [
|
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||||
];
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$array['network'] = 'tcp';
|
$array['network'] = 'tcp';
|
||||||
@ -234,6 +234,6 @@ class Clash implements ProtocolInterface
|
|||||||
if (empty($exp)) {
|
if (empty($exp)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return @preg_match((string)$exp, '') !== false;
|
return @preg_match((string) $exp, '') !== false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -167,16 +167,15 @@ class ClashMeta implements ProtocolInterface
|
|||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
$array['network'] = 'ws';
|
$array['network'] = 'ws';
|
||||||
$array['ws-opts'] = [
|
if ($path = data_get($protocol_settings, 'network_settings.path'))
|
||||||
'path' => data_get($protocol_settings, 'network_settings.path'),
|
$array['ws-opts']['path'] = $path;
|
||||||
'headers' => ['Host' => data_get($protocol_settings, 'network_settings.headers.Host', $server['host'])]
|
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||||
];
|
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||||
break;
|
break;
|
||||||
case 'grpc':
|
case 'grpc':
|
||||||
$array['network'] = 'grpc';
|
$array['network'] = 'grpc';
|
||||||
$array['grpc-opts'] = [
|
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
$array['grpc-opts']['grpc-service-name'] = $serviceName;
|
||||||
];
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -226,23 +225,15 @@ class ClashMeta implements ProtocolInterface
|
|||||||
switch (data_get($protocol_settings, 'network')) {
|
switch (data_get($protocol_settings, 'network')) {
|
||||||
case 'ws':
|
case 'ws':
|
||||||
$array['network'] = 'ws';
|
$array['network'] = 'ws';
|
||||||
$array['ws-opts']['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')) {
|
$array['ws-opts']['path'] = $path;
|
||||||
|
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||||
$array['ws-opts']['headers'] = ['Host' => $host];
|
$array['ws-opts']['headers'] = ['Host' => $host];
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'grpc':
|
case 'grpc':
|
||||||
$array['network'] = 'grpc';
|
$array['network'] = 'grpc';
|
||||||
$array['grpc-opts'] = [
|
if ($serviceName = data_get($protocol_settings, 'network_settings.serviceName'))
|
||||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
$array['grpc-opts']['grpc-service-name'] = $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')
|
|
||||||
];
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -268,20 +259,23 @@ class ClashMeta implements ProtocolInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (data_get($protocol_settings, 'network')) {
|
switch (data_get($protocol_settings, 'network')) {
|
||||||
case 'grpc':
|
case 'tcp':
|
||||||
$array['network'] = 'grpc';
|
$array['network'] = 'tcp';
|
||||||
$array['grpc-opts'] = [
|
|
||||||
'grpc-service-name' => data_get($protocol_settings, 'network_settings.serviceName')
|
|
||||||
];
|
|
||||||
break;
|
break;
|
||||||
case 'ws':
|
case 'ws':
|
||||||
$array['network'] = 'ws';
|
$array['network'] = 'ws';
|
||||||
$array['ws-opts']['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')) {
|
$array['ws-opts']['path'] = $path;
|
||||||
|
if ($host = data_get($protocol_settings, 'network_settings.headers.Host'))
|
||||||
$array['ws-opts']['headers'] = ['Host' => $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;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$array['network'] = 'tcp';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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':
|
||||||
@ -179,12 +183,29 @@ class General implements ProtocolInterface
|
|||||||
{
|
{
|
||||||
$protocol_settings = $server['protocol_settings'];
|
$protocol_settings = $server['protocol_settings'];
|
||||||
$name = rawurlencode($server['name']);
|
$name = rawurlencode($server['name']);
|
||||||
$array = [];
|
$array = [];
|
||||||
$array['allowInsecure'] = $protocol_settings['allow_insecure'];
|
$array['allowInsecure'] = $protocol_settings['allow_insecure'];
|
||||||
if ($serverName = data_get($protocol_settings, 'server_name')) {
|
if ($serverName = data_get($protocol_settings, 'server_name')) {
|
||||||
$array['peer'] = $serverName;
|
$array['peer'] = $serverName;
|
||||||
$array['sni'] = $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);
|
$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";
|
||||||
@ -209,7 +230,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'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user