fix: correct know issues

This commit is contained in:
xboard 2025-01-16 21:59:39 +08:00
parent 78370717df
commit 94ecd10704
4 changed files with 25 additions and 25 deletions

View File

@ -43,6 +43,7 @@ class ClashMeta implements ProtocolInterface
$proxies = []; $proxies = [];
foreach ($servers as $item) { foreach ($servers as $item) {
$protocol_settings = $item['protocol_settings'];
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
array_push($proxy, self::buildShadowsocks($item['password'], $item)); array_push($proxy, self::buildShadowsocks($item['password'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
@ -55,7 +56,10 @@ class ClashMeta implements ProtocolInterface
array_push($proxy, self::buildTrojan($user['uuid'], $item)); array_push($proxy, self::buildTrojan($user['uuid'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }
if ($item['type'] === 'vless') { if (
$item['type'] === 'vless'
&& in_array(data_get($protocol_settings, 'network'), ['tcp', 'ws', 'grpc', 'http', 'h2'])
) {
array_push($proxy, self::buildVless($user['uuid'], $item)); array_push($proxy, self::buildVless($user['uuid'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }

View File

@ -51,6 +51,7 @@ class SingBox implements ProtocolInterface
$outbounds = $this->config['outbounds']; $outbounds = $this->config['outbounds'];
$proxies = []; $proxies = [];
foreach ($this->servers as $item) { foreach ($this->servers as $item) {
$protocol_settings = $item['protocol_settings'];
if ($item['type'] === 'shadowsocks') { if ($item['type'] === 'shadowsocks') {
$ssConfig = $this->buildShadowsocks($item['password'], $item); $ssConfig = $this->buildShadowsocks($item['password'], $item);
$proxies[] = $ssConfig; $proxies[] = $ssConfig;
@ -63,7 +64,9 @@ class SingBox implements ProtocolInterface
$vmessConfig = $this->buildVmess($this->user['uuid'], $item); $vmessConfig = $this->buildVmess($this->user['uuid'], $item);
$proxies[] = $vmessConfig; $proxies[] = $vmessConfig;
} }
if ($item['type'] === 'vless') { if ($item['type'] === 'vless'
&& in_array(data_get($protocol_settings, 'network'), ['tcp', 'ws', 'grpc', 'http', 'quic', 'httpupgrade'])
) {
$vlessConfig = $this->buildVless($this->user['uuid'], $item); $vlessConfig = $this->buildVless($this->user['uuid'], $item);
$proxies[] = $vlessConfig; $proxies[] = $vlessConfig;
} }
@ -213,13 +216,13 @@ class SingBox implements ProtocolInterface
], ],
'h2' => [ 'h2' => [
'type' => 'http', 'type' => 'http',
'host' => data_get($protocol_settings, 'network_settings.host') ? [data_get($protocol_settings, 'network_settings.host')] : null, 'host' => data_get($protocol_settings, 'network_settings.host'),
'path' => data_get($protocol_settings, 'network_settings.path') 'path' => data_get($protocol_settings, 'network_settings.path')
], ],
'httpupgrade' => [ 'httpupgrade' => [
'type' => 'httpupgrade', 'type' => 'httpupgrade',
'path' => data_get($protocol_settings, 'network_settings.path'), 'path' => data_get($protocol_settings, 'network_settings.path'),
'host' => data_get($protocol_settings, 'network_settings.headers.Host', $server['host']), 'host' => data_get($protocol_settings, 'network_settings.host', $server['host']),
'headers' => data_get($protocol_settings, 'network_settings.headers') 'headers' => data_get($protocol_settings, 'network_settings.headers')
], ],
default => null default => null

View File

@ -59,10 +59,15 @@ class Stash implements ProtocolInterface
array_push($proxy, self::buildVmess($user['uuid'], $item)); array_push($proxy, self::buildVmess($user['uuid'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }
// if ($item['type'] === 'vless') { if (
// array_push($proxy, self::buildVless($user['uuid'], $item)); $item['type'] === 'vless'
// array_push($proxies, $item['name']); && in_array(data_get($item['protocol_settings'], 'network'), ['tcp', 'ws', 'grpc', 'http', 'h2'])
// } && in_array(data_get($item['protocol_settings'], 'tls'), [1, 0])
&& in_array(data_get($item['protocol_settings'], 'flow'), ['xtls-rprx-origin', 'xtls-rprx-direct', 'xtls-rprx-splice'])
) {
array_push($proxy, self::buildVless($user['uuid'], $item));
array_push($proxies, $item['name']);
}
if ($item['type'] === 'hysteria') { if ($item['type'] === 'hysteria') {
array_push($proxy, self::buildHysteria($user['uuid'], $item)); array_push($proxy, self::buildHysteria($user['uuid'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
@ -192,15 +197,6 @@ class Stash implements ProtocolInterface
$array['servername'] = $serverName; $array['servername'] = $serverName;
} }
break; break;
case 2:
$array['tls'] = true;
$array['skip-cert-verify'] = data_get($protocol_settings, 'reality_settings.allow_insecure');
$array['servername'] = data_get($protocol_settings, 'reality_settings.server_name');
$array['reality-opts'] = [
'public-key' => data_get($protocol_settings, 'reality_settings.public_key'),
'short-id' => data_get($protocol_settings, 'reality_settings.short_id')
];
break;
} }
switch (data_get($protocol_settings, 'network')) { switch (data_get($protocol_settings, 'network')) {
@ -219,6 +215,11 @@ class Stash implements ProtocolInterface
$array['network'] = 'grpc'; $array['network'] = 'grpc';
$array['grpc-opts']['grpc-service-name'] = data_get($protocol_settings, 'network_settings.serviceName'); $array['grpc-opts']['grpc-service-name'] = data_get($protocol_settings, 'network_settings.serviceName');
break; break;
// case 'h2':
// $array['network'] = 'h2';
// $array['h2-opts']['host'] = data_get($protocol_settings, 'network_settings.host');
// $array['h2-opts']['path'] = data_get($protocol_settings, 'network_settings.path');
// break;
} }
return $array; return $array;

View File

@ -42,27 +42,19 @@ class Surge implements ProtocolInterface
'chacha20-ietf-poly1305' 'chacha20-ietf-poly1305'
]) ])
) { ) {
// [Proxy]
$proxies .= self::buildShadowsocks($item['password'], $item); $proxies .= self::buildShadowsocks($item['password'], $item);
// [Proxy Group]
$proxyGroup .= $item['name'] . ', '; $proxyGroup .= $item['name'] . ', ';
} }
if ($item['type'] === 'vmess') { if ($item['type'] === 'vmess') {
// [Proxy]
$proxies .= self::buildVmess($user['uuid'], $item); $proxies .= self::buildVmess($user['uuid'], $item);
// [Proxy Group]
$proxyGroup .= $item['name'] . ', '; $proxyGroup .= $item['name'] . ', ';
} }
if ($item['type'] === 'trojan') { if ($item['type'] === 'trojan') {
// [Proxy]
$proxies .= self::buildTrojan($user['uuid'], $item); $proxies .= self::buildTrojan($user['uuid'], $item);
// [Proxy Group]
$proxyGroup .= $item['name'] . ', '; $proxyGroup .= $item['name'] . ', ';
} }
if ($item['type'] === 'hysteria') { if ($item['type'] === 'hysteria') {
// [Proxy]
$proxies .= self::buildHysteria($user['uuid'], $item); $proxies .= self::buildHysteria($user['uuid'], $item);
// [Proxy Group]
$proxyGroup .= $item['name'] . ', '; $proxyGroup .= $item['name'] . ', ';
} }
} }