尝试增加ClashMeta的hy2订阅,调整hy数据库以储存混淆obfs

This commit is contained in:
root
2023-09-30 21:35:31 +09:00
parent 28ad50650e
commit 21c03fc1e1
7 changed files with 144 additions and 11 deletions

View File

@ -52,6 +52,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);
@ -244,6 +248,38 @@ class ClashMeta
return $array;
}
public static function buildHysteria($password, $server)
{
$array = [];
$array['name'] = $server['name'];
$array['server'] = $server['host'];
$array['port'] = $server['port'];
$array['udp'] = true;
//Todo:完善客户端上下行
//$array['up'] = $server['up_mbps'];
//$array['down'] = $server['down_mbps'];
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'];
}
$array['protocol'] = 'udp';
}
return $array;
}
private function isMatch($exp, $str)
{
return @preg_match($exp, $str);