update: hysteria2

This commit is contained in:
v2board 2023-09-28 13:34:58 +08:00
parent 3f24ba9917
commit 4434b13361
5 changed files with 89 additions and 3 deletions

View File

@ -24,7 +24,9 @@ class HysteriaController extends Controller
'up_mbps' => 'required|numeric|min:1',
'down_mbps' => 'required|numeric|min:1',
'server_name' => 'nullable',
'insecure' => 'required|in:0,1'
'insecure' => 'required|in:0,1',
'obfs_type' => 'nullable|in:salamander',
'ignore_client_bandwidth' => 'required|in:0,1'
]);
if ($request->input('id')) {

View File

@ -108,7 +108,9 @@ class UniProxyController extends Controller
'server_name' => $this->nodeInfo->server_name,
'up_mbps' => $this->nodeInfo->up_mbps,
'down_mbps' => $this->nodeInfo->down_mbps,
'obfs' => Helper::getServerKey($this->nodeInfo->created_at, 16)
'obfs' => Helper::getServerKey($this->nodeInfo->created_at, 16),
'obfs_type' => $this->nodeInfo->obfs_type,
'ignore_client_bandwidth' => !!$this->nodeInfo->ignore_client_bandwidth
];
break;
case "vless":

View File

@ -48,6 +48,10 @@ class ClashMeta
array_push($proxy, self::buildTrojan($user['uuid'], $item));
array_push($proxies, $item['name']);
}
if ($item['type'] === 'vless') {
array_push($proxy, self::buildVless($user['uuid'], $item));
array_push($proxies, $item['name']);
}
}
$config['proxies'] = array_merge($config['proxies'] ? $config['proxies'] : [], $proxy);
@ -160,6 +164,78 @@ class ClashMeta
return $array;
}
public static function buildVless($uuid, $server)
{
$array = [];
$array['name'] = $server['name'];
$array['type'] = 'vless';
$array['server'] = $server['host'];
$array['port'] = $server['port'];
$array['uuid'] = $uuid;
$array['udp'] = true;
if ($server['tls'] === 1) {
$array['tls'] = true;
if ($server['tls_settings']) {
$tlsSettings = $server['tls_settings'];
if (isset($tlsSettings['allow_insecure']) && !empty($tlsSettings['allow_insecure']))
$array['skip-cert-verify'] = ($tlsSettings['allow_insecure'] ? true : false);
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
$array['servername'] = $tlsSettings['server_name'];
}
}
if (isset($server['flow']) && $server['flow']) {
$array['flow'] = $server['flow'];
$array['client-fingerprint'] = 'chrome';
}
if ($server['tls'] === 2) {
$array['client-fingerprint'] = 'chrome';
$array['tls'] = true;
$array['reality-opts'] = [];
if ($server['tls_settings']) {
$tlsSettings = $server['tls_settings'];
if (isset($tlsSettings['allow_insecure']) && !empty($tlsSettings['allow_insecure']))
$array['skip-cert-verify'] = ($tlsSettings['allow_insecure'] ? true : false);
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
$array['servername'] = $tlsSettings['server_name'];
if (isset($tlsSettings['public_key'])) $array['reality-opts']['public-key'] = $tlsSettings['public_key'];
}
}
if ($server['network'] === 'tcp') {
$tcpSettings = $server['network_settings'];
if (isset($tcpSettings['header']['type'])) $array['network'] = $tcpSettings['header']['type'];
if (isset($tcpSettings['header']['request']['path'][0])) $array['http-opts']['path'] = $tcpSettings['header']['request']['path'][0];
}
if ($server['network'] === 'ws') {
$array['network'] = 'ws';
if ($server['network_settings']) {
$wsSettings = $server['network_settings'];
$array['ws-opts'] = [];
if (isset($wsSettings['path']) && !empty($wsSettings['path']))
$array['ws-opts']['path'] = $wsSettings['path'];
if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))
$array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']];
if (isset($wsSettings['path']) && !empty($wsSettings['path']))
$array['ws-path'] = $wsSettings['path'];
if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))
$array['ws-headers'] = ['Host' => $wsSettings['headers']['Host']];
}
}
if ($server['network'] === 'grpc') {
$array['network'] = 'grpc';
if ($server['network_settings']) {
$grpcSettings = $server['network_settings'];
$array['grpc-opts'] = [];
if (isset($grpcSettings['serviceName'])) $array['grpc-opts']['grpc-service-name'] = $grpcSettings['serviceName'];
}
}
return $array;
}
public static function buildTrojan($password, $server)
{
$array = [];

View File

@ -231,6 +231,8 @@ CREATE TABLE `v2_server_hysteria` (
`down_mbps` int(11) NOT NULL,
`server_name` varchar(64) DEFAULT NULL,
`insecure` tinyint(1) NOT NULL DEFAULT '0',
`ignore_client_bandwidth` tinyint(1) NOT NULL DEFAULT '0',
`obfs_type` varchar(11) DEFAULT NULL,
`created_at` int(11) NOT NULL,
`updated_at` int(11) NOT NULL,
PRIMARY KEY (`id`)
@ -470,4 +472,4 @@ CREATE TABLE `v2_user` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- 2023-09-06 07:17:40
-- 2023-09-24 19:19:32

View File

@ -720,3 +720,7 @@ ADD `transfer_unit_price` int(11) NULL AFTER `daily_unit_price`;
ALTER TABLE `v2_order`
DROP `surplus_order_ids`;
ALTER TABLE `v2_server_hysteria`
ADD `ignore_client_bandwidth` tinyint(1) NOT NULL DEFAULT '0' AFTER `insecure`,
ADD `obfs_type` varchar(11) NULL AFTER `ignore_client_bandwidth`;