mirror of
https://github.com/v2board/v2board.git
synced 2025-06-14 21:57:50 +08:00
clean up buildvmess()
This commit is contained in:
@ -20,23 +20,32 @@ class Shadowrocket
|
||||
{
|
||||
$userinfo = base64_encode('auto:' . $uuid . '@' . $server['host'] . ':' . $server['port']);
|
||||
$config = [
|
||||
'tfo' => 1,
|
||||
'remark' => $server['name'],
|
||||
'alterId' => $server['alter_id']
|
||||
];
|
||||
if ($server['tls']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
$config['tls'] = 1;
|
||||
if (isset($tlsSettings['serverName'])) $config['peer'] = $tlsSettings['serverName'];
|
||||
if (isset($tlsSettings['allowInsecure'])) $config['allowInsecure'] = 1;
|
||||
if ($server['tlsSettings']) {
|
||||
$tlsSettings = json_decode($server['tlsSettings'], true);
|
||||
if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure']))
|
||||
$config['allowInsecure'] = (int)$tlsSettings['allowInsecure'];
|
||||
if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName']))
|
||||
$config['peer'] = $tlsSettings['serverName'];
|
||||
}
|
||||
}
|
||||
if ($server['network'] === 'ws') {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
$config['obfs'] = "websocket";
|
||||
if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path'];
|
||||
if (isset($wsSettings['headers']['Host'])) $config['obfsParam'] = $wsSettings['headers']['Host'];
|
||||
if ($server['networkSettings']) {
|
||||
$wsSettings = json_decode($server['networkSettings'], true);
|
||||
if (isset($wsSettings['path']) && !empty($wsSettings['path']))
|
||||
$config['path'] = $wsSettings['path'];
|
||||
if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host']))
|
||||
$config['obfsParam'] = $wsSettings['headers']['Host'];
|
||||
}
|
||||
}
|
||||
$query = http_build_query($config, null, '&', PHP_QUERY_RFC3986);
|
||||
$uri = "vmess://{$userinfo}?{$query}&tfo=1";
|
||||
$query = http_build_query($config, '', '&', PHP_QUERY_RFC3986);
|
||||
$uri = "vmess://{$userinfo}?{$query}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
Reference in New Issue
Block a user