feat: add AnyTLS protocol support for Surge
This commit is contained in:
@@ -18,6 +18,7 @@ class Surge extends AbstractProtocol
|
|||||||
Server::TYPE_VMESS,
|
Server::TYPE_VMESS,
|
||||||
Server::TYPE_TROJAN,
|
Server::TYPE_TROJAN,
|
||||||
Server::TYPE_HYSTERIA,
|
Server::TYPE_HYSTERIA,
|
||||||
|
Server::TYPE_ANYTLS,
|
||||||
];
|
];
|
||||||
protected $protocolRequirements = [
|
protected $protocolRequirements = [
|
||||||
'surge.hysteria.protocol_settings.version' => [2 => '2398'],
|
'surge.hysteria.protocol_settings.version' => [2 => '2398'],
|
||||||
@@ -58,6 +59,10 @@ class Surge extends AbstractProtocol
|
|||||||
$proxies .= self::buildHysteria($item['password'], $item);
|
$proxies .= self::buildHysteria($item['password'], $item);
|
||||||
$proxyGroup .= $item['name'] . ', ';
|
$proxyGroup .= $item['name'] . ', ';
|
||||||
}
|
}
|
||||||
|
if ($item['type'] === Server::TYPE_ANYTLS) {
|
||||||
|
$proxies .= self::buildAnyTLS($item['password'], $item);
|
||||||
|
$proxyGroup .= $item['name'] . ', ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -193,6 +198,28 @@ class Surge extends AbstractProtocol
|
|||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//参考文档: https://manual.nssurge.com/policy/proxy.html
|
||||||
|
public static function buildAnyTLS($password, $server)
|
||||||
|
{
|
||||||
|
$protocol_settings = data_get($server, 'protocol_settings', []);
|
||||||
|
$config = [
|
||||||
|
"{$server['name']}=anytls",
|
||||||
|
"{$server['host']}",
|
||||||
|
"{$server['port']}",
|
||||||
|
"password={$password}",
|
||||||
|
];
|
||||||
|
if ($serverName = data_get($protocol_settings, 'tls.server_name')) {
|
||||||
|
$config[] = "sni={$serverName}";
|
||||||
|
}
|
||||||
|
if (data_get($protocol_settings, 'tls.allow_insecure')) {
|
||||||
|
$config[] = 'skip-cert-verify=true';
|
||||||
|
}
|
||||||
|
$config = array_filter($config);
|
||||||
|
$uri = implode(',', $config);
|
||||||
|
$uri .= "\r\n";
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
//参考文档: https://manual.nssurge.com/policy/proxy.html
|
//参考文档: https://manual.nssurge.com/policy/proxy.html
|
||||||
public static function buildHysteria($password, $server)
|
public static function buildHysteria($password, $server)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user