feat: 增加surge的hy2下发、添加clash meta、shadowrocket、stash订阅hy2端口跳跃的下发

This commit is contained in:
xboard
2024-05-14 21:57:36 +08:00
parent 227f50b9d1
commit 5a0e59b103
7 changed files with 107 additions and 74 deletions
+29
View File
@@ -52,6 +52,12 @@ class Surge
// [Proxy Group]
$proxyGroup .= $item['name'] . ', ';
}
if ($item['type'] === 'hysteria') {
// [Proxy]
$proxies .= self::buildHysteria($user['uuid'], $item);
// [Proxy Group]
$proxyGroup .= $item['name'] . ', ';
}
}
$defaultConfig = base_path() . '/resources/rules/default.surge.conf';
@@ -160,4 +166,27 @@ class Surge
$uri .= "\r\n";
return $uri;
}
//参考文档: https://manual.nssurge.com/policy/proxy.html
public static function buildHysteria($password, $server)
{
if($server['version'] != 2) return '';
$config = [
"{$server['name']}=hysteria2",
"{$server['host']}",
"{$server['port']}",
"password={$password}",
"download-bandwidth={$server['up_mbps']}",
$server['server_name'] ? "sni={$server['server_name']}" : "",
// 'tfo=true',
'udp-relay=true'
];
if ($server['insecure']) {
$config[] = $server['insecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false';
}
$config = array_filter($config);
$uri = implode(',', $config);
$uri .= "\r\n";
return $uri;
}
}