mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
feat: add support for hysteria2 in Passwall and SSRPLUS
This commit is contained in:
parent
ab52e61ed1
commit
e79465c90d
@ -36,6 +36,9 @@ class General
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= self::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= self::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
@ -170,4 +173,33 @@ class General
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildHysteria($password, $server)
|
||||
{
|
||||
$params = [];
|
||||
// Return empty if version is not 2
|
||||
if ($server['version'] !== 2) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($server['server_name']) {
|
||||
$params['sni'] = $server['server_name'];
|
||||
$params['security'] = 'tls';
|
||||
}
|
||||
|
||||
if ($server['is_obfs']) {
|
||||
$params['obfs'] = 'salamander';
|
||||
$params['obfs-password'] = $server['server_key'];
|
||||
}
|
||||
|
||||
$params['insecure'] = $server['insecure'] ? 1 : 0;
|
||||
|
||||
$query = http_build_query($params);
|
||||
$name = rawurlencode($server['name']);
|
||||
|
||||
$uri = "hysteria2://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}";
|
||||
$uri .= "\r\n";
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ class Passwall
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= self::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= General::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ class SSRPlus
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= self::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= General::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class V2rayN
|
||||
$uri .= self::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= self::buildHysteria($user['uuid'], $item);
|
||||
$uri .= General::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
|
||||
}
|
||||
@ -192,25 +192,5 @@ class V2rayN
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildHysteria($password, $server)
|
||||
{
|
||||
$name = rawurlencode($server['name']);
|
||||
$params = [];
|
||||
if ($server['server_name']) $params['sni'] = $server['server_name'];
|
||||
$params['insecure'] = $server['insecure'] ? 1 : 0;
|
||||
if($server['is_obfs']) {
|
||||
$params['obfs'] = 'salamander';
|
||||
$params['obfs-password'] = $server['server_key'];
|
||||
}
|
||||
$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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class V2rayNG
|
||||
$uri .= self::buildVless($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= self::buildHysteria($user['uuid'], $item);
|
||||
$uri .= General::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
@ -193,34 +193,4 @@ class V2rayNG
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildHysteria($password, $server)
|
||||
{
|
||||
$params = [];
|
||||
// Return empty if version is not 2
|
||||
if ($server['version'] !== 2) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($server['server_name']) {
|
||||
$params['sni'] = $server['server_name'];
|
||||
$params['security'] = 'tls';
|
||||
}
|
||||
|
||||
if ($server['is_obfs']) {
|
||||
$params['obfs'] = 'salamander';
|
||||
$params['obfs-password'] = $server['server_key'];
|
||||
}
|
||||
|
||||
$params['insecure'] = $server['insecure'] ? 1 : 0;
|
||||
|
||||
$query = http_build_query($params);
|
||||
$name = rawurlencode($server['name']);
|
||||
|
||||
$uri = "hysteria2://{$password}@{$server['host']}:{$server['port']}?{$query}#{$name}";
|
||||
$uri .= "\r\n";
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user