mirror of
https://github.com/lkddi/Xboard.git
synced 2026-04-03 10:30:51 +08:00
Compare commits
2 Commits
f3fd40008b
...
ec49ba3fd1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec49ba3fd1 | ||
|
|
b7c8b31a91 |
@@ -15,6 +15,7 @@ class Loon extends AbstractProtocol
|
||||
Server::TYPE_TROJAN,
|
||||
Server::TYPE_HYSTERIA,
|
||||
Server::TYPE_VLESS,
|
||||
Server::TYPE_ANYTLS,
|
||||
];
|
||||
|
||||
protected $protocolRequirements = [
|
||||
@@ -47,6 +48,9 @@ class Loon extends AbstractProtocol
|
||||
if ($item['type'] === Server::TYPE_VLESS) {
|
||||
$uri .= self::buildVless($item['password'], $item);
|
||||
}
|
||||
if ($item['type'] === Server::TYPE_ANYTLS) {
|
||||
$uri .= self::buildAnyTLS($item['password'], $item);
|
||||
}
|
||||
}
|
||||
return response($uri)
|
||||
->header('content-type', 'text/plain')
|
||||
@@ -325,4 +329,29 @@ class Loon extends AbstractProtocol
|
||||
$uri .= "\r\n";
|
||||
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_VMESS,
|
||||
Server::TYPE_TROJAN,
|
||||
Server::TYPE_ANYTLS,
|
||||
];
|
||||
const CUSTOM_TEMPLATE_FILE = 'resources/rules/custom.surfboard.conf';
|
||||
const DEFAULT_TEMPLATE_FILE = 'resources/rules/default.surfboard.conf';
|
||||
@@ -36,7 +37,10 @@ class Surfboard extends AbstractProtocol
|
||||
'aes-128-gcm',
|
||||
'aes-192-gcm',
|
||||
'aes-256-gcm',
|
||||
'chacha20-ietf-poly1305'
|
||||
'chacha20-ietf-poly1305',
|
||||
'2022-blake3-aes-128-gcm',
|
||||
'2022-blake3-aes-256-gcm',
|
||||
'2022-blake3-chacha20-poly1305'
|
||||
])
|
||||
) {
|
||||
// [Proxy]
|
||||
@@ -56,6 +60,10 @@ class Surfboard extends AbstractProtocol
|
||||
// [Proxy Group]
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
if ($item['type'] === Server::TYPE_ANYTLS) {
|
||||
$proxies .= self::buildAnyTLS($item['password'], $item);
|
||||
$proxyGroup .= $item['name'] . ', ';
|
||||
}
|
||||
}
|
||||
|
||||
$config = subscribe_template('surfboard');
|
||||
@@ -190,4 +198,32 @@ class Surfboard extends AbstractProtocol
|
||||
$uri .= "\r\n";
|
||||
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