mirror of
https://github.com/v2board/v2board.git
synced 2025-03-12 21:54:42 +08:00
为ClashVerge增加hysteria1/2的订阅
This commit is contained in:
parent
dffe39b6d9
commit
19521a1393
@ -124,6 +124,8 @@ class UniProxyController extends Controller
|
||||
if ($this->nodeInfo->version == 1) {
|
||||
$response['obfs'] = $this->nodeInfo->obfs_password ?? null;
|
||||
} elseif ($this->nodeInfo->version == 2) {
|
||||
//TODO 处理hy2客户端上下行宽带设置
|
||||
$response['ignore_client_bandwidth'] = true;
|
||||
$response['obfs'] = $this->nodeInfo->obfs ?? null;
|
||||
$response['obfs-password'] = $this->nodeInfo->obfs_password ?? null;
|
||||
}
|
||||
|
@ -52,6 +52,10 @@ class ClashVerge
|
||||
array_push($proxy, self::buildTrojan($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
array_push($proxy, self::buildHysteria($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
}
|
||||
}
|
||||
|
||||
$config['proxies'] = array_merge($config['proxies'] ? $config['proxies'] : [], $proxy);
|
||||
@ -243,6 +247,38 @@ class ClashVerge
|
||||
return $array;
|
||||
}
|
||||
|
||||
public static function buildHysteria($password, $server)
|
||||
{
|
||||
$array = [];
|
||||
$array['name'] = $server['name'];
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
$array['udp'] = true;
|
||||
|
||||
if (isset($server['server_name'])) $array['sni'] = $server['server_name'];
|
||||
|
||||
if ($server['version'] === 2) {
|
||||
$array['type'] = 'hysteria2';
|
||||
$array['password'] = $password;
|
||||
if (isset($server['obfs'])){
|
||||
$array['obfs'] = $server['obfs'];
|
||||
$array['obfs-password'] = $server['obfs_password'];
|
||||
}
|
||||
} else {
|
||||
$array['type'] = 'hysteria';
|
||||
$array['auth_str'] = $password;
|
||||
if (isset($server['obfs']) && isset($server['obfs_password'])){
|
||||
$array['obfs'] = $server['obfs_password'];
|
||||
}
|
||||
//Todo:完善客户端上下行
|
||||
$array['up'] = $user->speed_limit ? min($server['down_mbps'], $user->speed_limit) : $server['down_mbps'];
|
||||
$array['down'] = $user->speed_limit ? min($server['up_mbps'], $user->speed_limit) : $server['up_mbps'];
|
||||
$array['protocol'] = 'udp';
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
private function isMatch($exp, $str)
|
||||
{
|
||||
return @preg_match($exp, $str);
|
||||
|
Loading…
x
Reference in New Issue
Block a user