mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 10:30:51 +08:00
Loon和Surfboard适配anytls (#854)
* Loon适配anytls * Surfboard适配anytls Surfboard适配anytls
This commit is contained in:
@@ -15,6 +15,7 @@ class Loon extends AbstractProtocol
|
|||||||
Server::TYPE_TROJAN,
|
Server::TYPE_TROJAN,
|
||||||
Server::TYPE_HYSTERIA,
|
Server::TYPE_HYSTERIA,
|
||||||
Server::TYPE_VLESS,
|
Server::TYPE_VLESS,
|
||||||
|
Server::TYPE_ANYTLS,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $protocolRequirements = [
|
protected $protocolRequirements = [
|
||||||
@@ -47,6 +48,9 @@ class Loon extends AbstractProtocol
|
|||||||
if ($item['type'] === Server::TYPE_VLESS) {
|
if ($item['type'] === Server::TYPE_VLESS) {
|
||||||
$uri .= self::buildVless($item['password'], $item);
|
$uri .= self::buildVless($item['password'], $item);
|
||||||
}
|
}
|
||||||
|
if ($item['type'] === Server::TYPE_ANYTLS) {
|
||||||
|
$uri .= self::buildAnyTLS($item['password'], $item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return response($uri)
|
return response($uri)
|
||||||
->header('content-type', 'text/plain')
|
->header('content-type', 'text/plain')
|
||||||
@@ -325,4 +329,29 @@ class Loon extends AbstractProtocol
|
|||||||
$uri .= "\r\n";
|
$uri .= "\r\n";
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function buildAnyTLS($password, $server)
|
||||||
|
{
|
||||||
|
$protocol_settings = data_get($server, 'protocol_settings', []);
|
||||||
|
|
||||||
|
$config = [
|
||||||
|
"{$server['name']}=anytls",
|
||||||
|
"{$server['host']}",
|
||||||
|
"{$server['port']}",
|
||||||
|
"{$password}",
|
||||||
|
"udp=true"
|
||||||
|
];
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return implode(',', $config) . "\r\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ class Surfboard extends AbstractProtocol
|
|||||||
Server::TYPE_SHADOWSOCKS,
|
Server::TYPE_SHADOWSOCKS,
|
||||||
Server::TYPE_VMESS,
|
Server::TYPE_VMESS,
|
||||||
Server::TYPE_TROJAN,
|
Server::TYPE_TROJAN,
|
||||||
|
Server::TYPE_ANYTLS,
|
||||||
];
|
];
|
||||||
const CUSTOM_TEMPLATE_FILE = 'resources/rules/custom.surfboard.conf';
|
const CUSTOM_TEMPLATE_FILE = 'resources/rules/custom.surfboard.conf';
|
||||||
const DEFAULT_TEMPLATE_FILE = 'resources/rules/default.surfboard.conf';
|
const DEFAULT_TEMPLATE_FILE = 'resources/rules/default.surfboard.conf';
|
||||||
@@ -59,6 +60,10 @@ class Surfboard extends AbstractProtocol
|
|||||||
// [Proxy Group]
|
// [Proxy Group]
|
||||||
$proxyGroup .= $item['name'] . ', ';
|
$proxyGroup .= $item['name'] . ', ';
|
||||||
}
|
}
|
||||||
|
if ($item['type'] === Server::TYPE_ANYTLS) {
|
||||||
|
$proxies .= self::buildAnyTLS($item['password'], $item);
|
||||||
|
$proxyGroup .= $item['name'] . ', ';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$config = subscribe_template('surfboard');
|
$config = subscribe_template('surfboard');
|
||||||
@@ -193,4 +198,32 @@ class Surfboard extends AbstractProtocol
|
|||||||
$uri .= "\r\n";
|
$uri .= "\r\n";
|
||||||
return $uri;
|
return $uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function buildAnyTLS($password, $server)
|
||||||
|
{
|
||||||
|
$protocol_settings = data_get($server, 'protocol_settings', []);
|
||||||
|
|
||||||
|
$config = [
|
||||||
|
"{$server['name']}=anytls",
|
||||||
|
"{$server['host']}",
|
||||||
|
"{$server['port']}",
|
||||||
|
"password={$password}",
|
||||||
|
"tfo=true",
|
||||||
|
"udp-relay=true"
|
||||||
|
];
|
||||||
|
|
||||||
|
// SNI
|
||||||
|
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);
|
||||||
|
|
||||||
|
return implode(',', $config) . "\r\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user