mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
[feat]: add v2rayNG hysteria2 support
This commit is contained in:
parent
af1f1e9fdf
commit
0873ce591f
@ -34,6 +34,9 @@ class V2rayNG
|
||||
if ($item['type'] === 'vless') {
|
||||
$uri .= self::buildVless($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= self::buildHysteria($user['uuid'], $item);
|
||||
}
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
@ -190,5 +193,34 @@ 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