mirror of
https://github.com/cedar2025/Xboard.git
synced 2025-01-22 10:38:14 -05:00
feat: 增加Loon自动下发Hysteria2节点
This commit is contained in:
parent
145d3580a0
commit
e16618142a
@ -42,7 +42,8 @@ class ClientController extends Controller
|
||||
'Nekoray' => '3.24',
|
||||
'verge' => '1.3.8',
|
||||
'ClashX Meta' => '1.3.5',
|
||||
'Hiddify' => '0.1.0'
|
||||
'Hiddify' => '0.1.0',
|
||||
'loon' => '637'
|
||||
];
|
||||
foreach($minSupportHy2ClinetVersionMap as $client => $minVersion){
|
||||
if (stripos($flag, $client) !== false && $this->versionCompare($version, $minVersion)) {
|
||||
|
@ -38,6 +38,9 @@ class Loon
|
||||
if ($item['type'] === 'trojan') {
|
||||
$uri .= self::buildTrojan($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'hysteria') {
|
||||
$uri .= self::buildHysteria($user['uuid'], $item, $user);
|
||||
}
|
||||
}
|
||||
return response($uri, 200)
|
||||
->header('Subscription-Userinfo', "upload={$user['u']}; download={$user['d']}; total={$user['transfer_enable']}; expire={$user['expired_at']}");
|
||||
@ -132,4 +135,25 @@ class Loon
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildHysteria($password, $server, $user)
|
||||
{
|
||||
if ($server['version'] !== 2){
|
||||
return ;
|
||||
}
|
||||
$config = [
|
||||
"{$server['name']}=Hysteria2",
|
||||
$server['host'],
|
||||
$server['port'],
|
||||
$password,
|
||||
$server['server_name'] ? "tls={$server['server_name']}" : "(null)"
|
||||
];
|
||||
if ($server['insecure']) $config[] = "skip-cert-verify=true";
|
||||
$config[] = "download-bandwidth=" . ($user->speed_limit ? min($server['down_mbps'], $user->speed_limit) : $server['down_mbps']);
|
||||
$config[] = "udp=true";
|
||||
$config = array_filter($config);
|
||||
$uri = implode(',', $config);
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user