mirror of
https://github.com/v2board/v2board.git
synced 2025-03-12 21:54:42 +08:00
修复支持vless协议的客户端订阅链接
This commit is contained in:
parent
079af33b78
commit
451cfd341c
@ -52,6 +52,10 @@ class Clash
|
||||
array_push($proxy, self::buildVmess($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']);
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
array_push($proxy, self::buildTrojan($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
@ -159,6 +163,64 @@ class Clash
|
||||
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['flow'] = !empty($server['flow']) ? $server['flow']: "";
|
||||
$array['client-fingerprint'] = 'chrome';
|
||||
$array['udp'] = true;
|
||||
|
||||
if ($server['tls']) {
|
||||
$array['tls'] = true;
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$array['servername'] = $tlsSettings['server_name'];
|
||||
if ($server['tls'] == 2) {
|
||||
$array['reality-opts'] = [];
|
||||
$array['reality-opts']['public-key'] = $tlsSettings['public_key'];
|
||||
$array['reality-opts']['short-id'] = $tlsSettings['shortId'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
}
|
||||
|
||||
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 = [];
|
||||
|
@ -172,7 +172,7 @@ class ClashMeta
|
||||
$array['server'] = $server['host'];
|
||||
$array['port'] = $server['port'];
|
||||
$array['uuid'] = $uuid;
|
||||
$array['flow'] = $server['flow'];
|
||||
$array['flow'] = !empty($server['flow']) ? $server['flow']: "";
|
||||
$array['client-fingerprint'] = 'chrome';
|
||||
$array['udp'] = true;
|
||||
|
||||
|
@ -103,51 +103,85 @@ class General
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => Helper::encodeURIComponent($server['name']),
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"id" => $uuid,
|
||||
"net" => $server['network'],
|
||||
"type" => "none",
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) $config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['flow']) && !empty($tlsSettings['flow'])) $config['flow'] = $tlsSettings['flow'];
|
||||
|
||||
$output .= "&sni={$config['sni']}" . "&flow={$config['flow']}";
|
||||
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
|
||||
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = Helper::encodeURIComponent($tcpSettings['header']['request']['path'][0]);
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
//grpc需要继续修
|
||||
if ($server['tls'] == 2) {
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}&pbk={$config['pbk']}&sid={$config['sid']}#${config['ps']}" . "\r\n";
|
||||
}
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}#${config['ps']}" . "\r\n";
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Protocols;
|
||||
|
||||
use App\Utils\Helper;
|
||||
|
||||
class Passwall
|
||||
{
|
||||
@ -25,6 +26,9 @@ class Passwall
|
||||
if ($item['type'] === 'vmess') {
|
||||
$uri .= self::buildVmess($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'vless') {
|
||||
$uri .= self::buildVless($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
$uri .= self::buildShadowsocks($user['uuid'], $item);
|
||||
}
|
||||
@ -85,6 +89,90 @@ class Passwall
|
||||
return "vmess://" . base64_encode(json_encode($config)) . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) $config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['flow']) && !empty($tlsSettings['flow'])) $config['flow'] = $tlsSettings['flow'];
|
||||
|
||||
$output .= "&sni={$config['sni']}" . "&flow={$config['flow']}";
|
||||
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$name = rawurlencode($server['name']);
|
||||
|
@ -25,6 +25,9 @@ class SSRPlus
|
||||
if ($item['type'] === 'vmess') {
|
||||
$uri .= self::buildVmess($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'vless') {
|
||||
$uri .= self::buildVless($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
$uri .= self::buildShadowsocks($user['uuid'], $item);
|
||||
}
|
||||
@ -80,6 +83,89 @@ class SSRPlus
|
||||
return "vmess://" . base64_encode(json_encode($config)) . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) {
|
||||
$config['sni'] = $tlsSettings['server_name'];
|
||||
$output .= "&sni={$config['sni']}";
|
||||
}
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$name = rawurlencode($server['name']);
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Protocols;
|
||||
|
||||
|
||||
use App\Utils\Helper;
|
||||
|
||||
class SagerNet
|
||||
{
|
||||
public $flag = 'sagernet';
|
||||
@ -24,6 +27,9 @@ class SagerNet
|
||||
if ($item['type'] === 'vmess') {
|
||||
$uri .= self::buildVmess($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'vless') {
|
||||
$uri .= self::buildVless($user['uuid'], $item);
|
||||
}
|
||||
if ($item['type'] === 'shadowsocks') {
|
||||
$uri .= self::buildShadowsocks($user['uuid'], $item);
|
||||
}
|
||||
@ -89,6 +95,90 @@ class SagerNet
|
||||
return "vmess://" . $uuid . "@" . $server['host'] . ":" . $server['port'] . "?" . http_build_query($config) . "#" . urlencode($server['name']) . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) $config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['flow']) && !empty($tlsSettings['flow'])) $config['flow'] = $tlsSettings['flow'];
|
||||
|
||||
$output .= "&sni={$config['sni']}" . "&flow={$config['flow']}";
|
||||
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($uuid, $server)
|
||||
{
|
||||
$name = rawurlencode($server['name']);
|
||||
|
@ -122,54 +122,89 @@ class Shadowrocket
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => Helper::encodeURIComponent($server['name']),
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"id" => $uuid,
|
||||
"net" => $server['network'],
|
||||
"type" => "none",
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) $config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['flow']) && !empty($tlsSettings['flow'])) $config['flow'] = $tlsSettings['flow'];
|
||||
|
||||
$output .= "&sni={$config['sni']}" . "&flow={$config['flow']}";
|
||||
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
|
||||
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = Helper::encodeURIComponent($tcpSettings['header']['request']['path'][0]);
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
//grpc需要继续修
|
||||
if ($server['tls'] == 2) {
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}&pbk={$config['pbk']}&sid={$config['sid']}#${config['ps']}" . "\r\n";
|
||||
}
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}#${config['ps']}" . "\r\n";
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
|
@ -51,6 +51,10 @@ class Stash
|
||||
array_push($proxy, self::buildVmess($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']);
|
||||
}
|
||||
if ($item['type'] === 'trojan') {
|
||||
array_push($proxy, self::buildTrojan($user['uuid'], $item));
|
||||
array_push($proxies, $item['name']);
|
||||
@ -157,6 +161,63 @@ class Stash
|
||||
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['flow'] = !empty($server['flow']) ? $server['flow']: "";
|
||||
$array['client-fingerprint'] = 'chrome';
|
||||
$array['udp'] = true;
|
||||
|
||||
if ($server['tls']) {
|
||||
$array['tls'] = true;
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$array['servername'] = $tlsSettings['server_name'];
|
||||
if ($server['tls'] == 2) {
|
||||
$array['reality-opts'] = [];
|
||||
$array['reality-opts']['public-key'] = $tlsSettings['public_key'];
|
||||
$array['reality-opts']['short-id'] = $tlsSettings['shortId'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
}
|
||||
|
||||
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 = [];
|
||||
|
@ -103,51 +103,85 @@ class V2rayN
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => Helper::encodeURIComponent($server['name']),
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"id" => $uuid,
|
||||
"net" => $server['network'],
|
||||
"type" => "none",
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) $config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['flow']) && !empty($tlsSettings['flow'])) $config['flow'] = $tlsSettings['flow'];
|
||||
|
||||
$output .= "&sni={$config['sni']}" . "&flow={$config['flow']}";
|
||||
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
|
||||
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = Helper::encodeURIComponent($tcpSettings['header']['request']['path'][0]);
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
//grpc需要继续修
|
||||
if ($server['tls'] == 2) {
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}&pbk={$config['pbk']}&sid={$config['sid']}#${config['ps']}" . "\r\n";
|
||||
}
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}#${config['ps']}" . "\r\n";
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
|
@ -92,51 +92,85 @@ class V2rayNG
|
||||
public static function buildVless($uuid, $server)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => Helper::encodeURIComponent($server['name']),
|
||||
"name" => Helper::encodeURIComponent($server['name']),
|
||||
"add" => $server['host'],
|
||||
"port" => (string)$server['port'],
|
||||
"id" => $uuid,
|
||||
"net" => $server['network'],
|
||||
"type" => "none",
|
||||
"type" => $server['network'],
|
||||
"encryption" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"headerType" => "none",
|
||||
"quicSecurity" => "none",
|
||||
"serviceName" => "",
|
||||
"mode" => "gun",
|
||||
"security" => $server['tls'] !=0 ? ($server['tls'] == 2 ? "reality":"tls") : "",
|
||||
"flow" => $server['flow'],
|
||||
"sni" => "",
|
||||
"pbk" => "",
|
||||
"sid" =>"",
|
||||
];
|
||||
|
||||
$output = "vless://" . $uuid . "@" . $config['add'] . ":" . $config['port'];
|
||||
$output .= "?" . "type={$config['type']}" . "&encryption={$config['encryption']}" . "&security={$config['security']}";
|
||||
|
||||
if ($server['tls']) {
|
||||
if ($server['tls_settings']) {
|
||||
$tlsSettings = $server['tls_settings'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name']))
|
||||
$config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['server_name']) && !empty($tlsSettings['server_name'])) $config['sni'] = $tlsSettings['server_name'];
|
||||
if (isset($tlsSettings['flow']) && !empty($tlsSettings['flow'])) $config['flow'] = $tlsSettings['flow'];
|
||||
|
||||
$output .= "&sni={$config['sni']}" . "&flow={$config['flow']}";
|
||||
|
||||
if ($server['tls'] == 2) {
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$config['pbk'] = $tlsSettings['public_key'];
|
||||
$config['sid'] = $tlsSettings['shortId'];
|
||||
$output .= "&pbk={$config['pbk']}" . "&sid={$config['sid']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((string)$server['network'] === 'tcp') {
|
||||
$tcpSettings = $server['network_settings'];
|
||||
if (isset($tcpSettings['header']['type'])) $config['type'] = $tcpSettings['header']['type'];
|
||||
if (isset($tcpSettings['header']['request']['path'][0])) $config['path'] = Helper::encodeURIComponent($tcpSettings['header']['request']['path'][0]);
|
||||
if (isset($tcpSettings['header']['type'])) $config['headerType'] = $tcpSettings['header']['type'];
|
||||
$output .= "&headerType={$config['headerType']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'kcp') {
|
||||
$kcpSettings = $server['network_settings'];
|
||||
if (isset($kcpSettings['header']['type'])) $config['headerType'] = $kcpSettings['header']['type'];
|
||||
if (isset($kcpSettings['seed'])) $config['path'] = Helper::encodeURIComponent($kcpSettings['seed']);
|
||||
$output .= "&headerType={$config['headerType']}" . "&seed={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'ws') {
|
||||
$wsSettings = $server['network_settings'];
|
||||
if (isset($wsSettings['path'])) $config['path'] = Helper::encodeURIComponent($wsSettings['path']);
|
||||
if (isset($wsSettings['headers']['Host'])) $config['host'] = Helper::encodeURIComponent($wsSettings['headers']['Host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'h2') {
|
||||
$h2Settings = $server['network_settings'];
|
||||
if (isset($h2Settings['path'])) $config['path'] = Helper::encodeURIComponent($h2Settings['path']);
|
||||
if (isset($h2Settings['host'])) $config['host'] = Helper::encodeURIComponent($h2Settings['host']);
|
||||
$output .= "&path={$config['path']}" . "&host={$config['host']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'quic') {
|
||||
$quicSettings = $server['network_settings'];
|
||||
if (isset($quicSettings['security'])) $config['quicSecurity'] = $quicSettings['security'];
|
||||
if (isset($quicSettings['header']['type'])) $config['headerType'] = $quicSettings['header']['type'];
|
||||
|
||||
$output .= "&quicSecurity={$config['quicSecurity']}" . "&headerType={$config['headerType']}";
|
||||
|
||||
if ((string)$quicSettings['security'] !== 'none' && isset($quicSettings['key'])) $config['path'] = Helper::encodeURIComponent($quicSettings['key']);
|
||||
|
||||
$output .= "&key={$config['path']}";
|
||||
}
|
||||
if ((string)$server['network'] === 'grpc') {
|
||||
$grpcSettings = $server['network_settings'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['path'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['serviceName'])) $config['serviceName'] = $grpcSettings['serviceName'];
|
||||
if (isset($grpcSettings['multiMode'])) $config['mode'] = $grpcSettings['multiMode'] ? "multi" : "gun";
|
||||
$output .= "&serviceName={$config['serviceName']}" . "&mode={$config['mode']}";
|
||||
}
|
||||
//grpc需要继续修
|
||||
if ($server['tls'] == 2) {
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}&pbk={$config['pbk']}&sid={$config['sid']}#${config['ps']}" . "\r\n";
|
||||
}
|
||||
return "vless://{$uuid}@{$config['add']}:{$server['port']}?type={$config['net']}&encryption=none&security={$config['tls']}&path={$config['path']}&host={$config['host']}&headerType={$config['type']}&flow={$server['flow']}&fp=chrome&sni={$config['sni']}#${config['ps']}" . "\r\n";
|
||||
$output .= "&fp=chrome" . "#" . $config['name'];
|
||||
|
||||
return $output . "\r\n";
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
@ -151,6 +185,4 @@ class V2rayNG
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user