From edbd8de35661c9ed0da4d9b1425511483ccc31ec Mon Sep 17 00:00:00 2001 From: yootus <151767033+yootus@users.noreply.github.com> Date: Thu, 16 Apr 2026 19:31:24 +0800 Subject: [PATCH] =?UTF-8?q?QuantumultX=E4=B8=8B=E5=8F=91Anytls=E8=8A=82?= =?UTF-8?q?=E7=82=B9=20(#880)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QuantumultX最新版本支持Anytls了,做适配 --- app/Protocols/QuantumultX.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/Protocols/QuantumultX.php b/app/Protocols/QuantumultX.php index 8488e0a..15f48ab 100644 --- a/app/Protocols/QuantumultX.php +++ b/app/Protocols/QuantumultX.php @@ -14,6 +14,7 @@ class QuantumultX extends AbstractProtocol Server::TYPE_VMESS, Server::TYPE_VLESS, Server::TYPE_TROJAN, + Server::TYPE_ANYTLS, Server::TYPE_SOCKS, Server::TYPE_HTTP, ]; @@ -29,6 +30,7 @@ class QuantumultX extends AbstractProtocol Server::TYPE_VMESS => self::buildVmess($item['password'], $item), Server::TYPE_VLESS => self::buildVless($item['password'], $item), Server::TYPE_TROJAN => self::buildTrojan($item['password'], $item), + Server::TYPE_ANYTLS => self::buildAnyTLS($item['password'], $item), Server::TYPE_SOCKS => self::buildSocks5($item['password'], $item), Server::TYPE_HTTP => self::buildHttp($item['password'], $item), default => '' @@ -198,6 +200,32 @@ class QuantumultX extends AbstractProtocol return implode(',', array_filter($config)) . "\r\n"; } + public static function buildAnyTLS($password, $server) + { + $protocol_settings = data_get($server, 'protocol_settings', []); + $addr = Helper::wrapIPv6($server['host']); + $config = [ + "anytls={$addr}:{$server['port']}", + "password={$password}", + 'udp-relay=true', + "tag={$server['name']}", + "over-tls=true", + ]; + + // allow_insecure=false => tls-verification=true; + // allow_insecure=true 时不写,沿用 QX 默认 false + $allowInsecure = (bool) data_get($protocol_settings, 'tls.allow_insecure', false); + if (!$allowInsecure) { + $config[] = 'tls-verification=true'; + } + + if ($serverName = data_get($protocol_settings, 'tls.server_name')) { + $config[] = "tls-host=$serverName"; + } + + return implode(',', array_filter($config)) . "\r\n"; + } + public static function buildSocks5($password, $server) { $protocol_settings = $server['protocol_settings'];