From 0000c071e7bf1c5f4f790654fabdfc14e313ac5d Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Thu, 11 Jan 2024 22:15:43 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=BAv2rayn=E7=9A=84=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0hysteria2=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Protocols/V2rayN.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/app/Protocols/V2rayN.php b/app/Protocols/V2rayN.php index 9d62f36..b86b06f 100644 --- a/app/Protocols/V2rayN.php +++ b/app/Protocols/V2rayN.php @@ -36,6 +36,9 @@ class V2rayN if ($item['type'] === 'trojan') { $uri .= self::buildTrojan($user['uuid'], $item); } + if ($item['type'] === 'hysteria') { + $uri .= self::buildHysteria($user['uuid'], $item); + } } return base64_encode($uri); @@ -199,4 +202,20 @@ class V2rayN return $uri; } + public static function buildHysteria($password, $server) + { + $name = rawurlencode($server['name']); + if ($server['server_name']) $params = ['sni' => $server['server_name']]; + $params['insecure'] = $server['insecure'] ? 1 : 0; + $query = http_build_query($params); + if ($server['version'] == 2) { + $uri = "hysteria2://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}"; + $uri .= "\r\n"; + } else { + // V2rayN似乎不支持v1, 返回空 + $uri = ""; + } + return $uri; + } + } From 0b5baa70f0a3dc7d5b7fb0a7b6af85a9d5b04ac9 Mon Sep 17 00:00:00 2001 From: ishkong <19740260+ishkong@users.noreply.github.com> Date: Sat, 13 Jan 2024 17:25:11 +0800 Subject: [PATCH 2/2] Update V2rayN.php --- app/Protocols/V2rayN.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Protocols/V2rayN.php b/app/Protocols/V2rayN.php index b86b06f..c7eedf5 100644 --- a/app/Protocols/V2rayN.php +++ b/app/Protocols/V2rayN.php @@ -205,7 +205,8 @@ class V2rayN public static function buildHysteria($password, $server) { $name = rawurlencode($server['name']); - if ($server['server_name']) $params = ['sni' => $server['server_name']]; + $params = []; + if ($server['server_name']) $params['sni'] = $server['server_name']; $params['insecure'] = $server['insecure'] ? 1 : 0; $query = http_build_query($params); if ($server['version'] == 2) {