update: clash.meta conf support hysteria

This commit is contained in:
cubemaze 2023-06-10 14:56:20 +08:00
parent 32eaf301fe
commit abcf63d770

View File

@ -48,6 +48,10 @@ class ClashMeta
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);
@ -174,6 +178,22 @@ class ClashMeta
return $array;
}
public static function buildHysteria($password, $server)
{
$array = [];
$array['name'] = $server['name'];
$array['type'] = 'hysteria';
$array['server'] = $server['host'];
$array['port'] = $server['port'];
$array['auth_str'] = $password;
$array['up'] = $server['up_mbps'];
$array['down'] = $server['down_mbps'];
$array['obfs'] = Helper::getServerKey($server['created_at'], 16);
if (!empty($server['server_name'])) $array['sni'] = $server['server_name'];
if (!empty($server['insecure'])) $array['skip-cert-verify'] = ($server['insecure'] ? true : false);
return $array;
}
private function isMatch($exp, $str)
{
return @preg_match($exp, $str);