This commit is contained in:
wouiSB 2025-01-14 10:42:17 +01:00 committed by GitHub
commit 3d747adb7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,10 +52,16 @@ class Stash
array_push($proxy, self::buildVmess($user['uuid'], $item)); array_push($proxy, self::buildVmess($user['uuid'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
} }
// if ($item['type'] === 'vless') { if ($item['type'] === 'vless') {
// array_push($proxy, self::buildVless($user['uuid'], $item)); if ($item['flow'] === 'xtls-rprx-vision') {
// array_push($proxies, $item['name']); continue;
// } }
if ($item['tls'] === 2) {
continue;
}
array_push($proxy, self::buildVless($user['uuid'], $item));
array_push($proxies, $item['name']);
}
if ($item['type'] === 'hysteria') { if ($item['type'] === 'hysteria') {
array_push($proxy, self::buildHysteria($user['uuid'], $item)); array_push($proxy, self::buildHysteria($user['uuid'], $item));
array_push($proxies, $item['name']); array_push($proxies, $item['name']);
@ -169,55 +175,49 @@ class Stash
return $array; return $array;
} }
public static function buildVless($uuid, $server) public static function buildVless($password, $server){
{
$array = []; $array = [];
$array['name'] = $server['name']; $array['name'] = $server['name'];
$array['type'] = 'vless'; $array['type'] = 'vless';
$array['server'] = $server['host']; $array['server'] = $server['host'];
$array['port'] = $server['port']; $array['port'] = $server['port'];
$array['uuid'] = $uuid; $array['uuid'] = $password;
$array['flow'] = !empty($server['flow']) ? $server['flow']: ""; $array['alterId'] = 0;
$array['cipher'] = 'auto';
$array['udp'] = true; $array['udp'] = true;
$fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq']; //随机客户端指纹 // XTLS流控算法
$array['client-fingerprint'] = $fingerprints[rand(0,count($fingerprints) - 1)]; if($server['flow']) ($array['flow'] = $server['flow']);
if ($server['tls']) { if ($server['tls']) {
$array['tls'] = true;
switch($server['tls']){ switch($server['tls']){
case 1: case 1: //开启TLS
$array['tls'] = true;
if ($server['tls_settings']) { if ($server['tls_settings']) {
$tlsSettings = $server['tls_settings']; $tlsSettings = $server['tls_settings'];
if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
$array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false);
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
$array['servername'] = $tlsSettings['server_name']; $array['servername'] = $tlsSettings['server_name'];
} }
break; break;
case 2: case 2: //开启reality
if (!isset($server['network_settings'])) break; $array['tls'] = true;
$networkSettings = $server['network_settings']; $tls_settings = $server['tls_settings'];
if (isset($networkSettings['reality-opts'])){ if (!empty($tls_settings['allowInsecure'])) $array['skip-cert-verify'] = (bool)$tls_settings['allowInsecure'];
$realitySettings = $networkSettings['reality-opts'];
$array['reality-opts'] = [];
$array['reality-opts']['public-key'] = $realitySettings['public-key'];
$array['reality-opts']['short-id'] = $realitySettings['short-id'];
}
break;
}
} if(($tls_settings['public_key'] ?? null)
&& ($tls_settings['short_id'] ?? null)
if ($server['network'] === 'tcp') { && ($tls_settings['server_name'] ?? null)){
$tcpSettings = $server['networkSettings']; $array['servername'] = $tls_settings['server_name'];
if (isset($tcpSettings['header']['type']) && $tcpSettings['header']['type'] == 'http') { $array['reality-opts'] = [
$array['network'] = $tcpSettings['header']['type']; 'public-key' => $tls_settings['public_key'],
if (isset($tcpSettings['header']['request']['headers']['Host'])){ 'short-id' => $tls_settings['short_id']
$array['http-opts']['headers']['Host'] = $tcpSettings['header']['request']['headers']['Host']; ];
} $fingerprints = ['chrome', 'firefox', 'safari', 'ios', 'edge', 'qq']; //随机客户端指纹
if (isset($tcpSettings['header']['request']['path'][0])){ $array['client-fingerprint'] = $fingerprints[rand(0,count($fingerprints) - 1)];
$paths = $tcpSettings['header']['request']['path'];
$array['http-opts']['path'] = $paths[array_rand($paths)];
}; };
break;
} }
} }
@ -241,7 +241,9 @@ class Stash
if ($server['network_settings']) { if ($server['network_settings']) {
$grpcSettings = $server['network_settings']; $grpcSettings = $server['network_settings'];
$array['grpc-opts'] = []; $array['grpc-opts'] = [];
if (isset($grpcSettings['serviceName'])) $array['grpc-opts']['grpc-service-name'] = $grpcSettings['serviceName']; if (isset($grpcSettings['serviceName'])) {
$array['grpc-opts']['grpc-service-name'] = $grpcSettings['serviceName'];
};
} }
} }