mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	update: server
This commit is contained in:
		| @@ -8,11 +8,11 @@ class Clash | ||||
|     public static function buildShadowsocks($uuid, $server) | ||||
|     { | ||||
|         $array = []; | ||||
|         $array['name'] = $server->name; | ||||
|         $array['name'] = $server['name']; | ||||
|         $array['type'] = 'ss'; | ||||
|         $array['server'] = $server->host; | ||||
|         $array['port'] = $server->port; | ||||
|         $array['cipher'] = $server->cipher; | ||||
|         $array['server'] = $server['host']; | ||||
|         $array['port'] = $server['port']; | ||||
|         $array['cipher'] = $server['cipher']; | ||||
|         $array['password'] = $uuid; | ||||
|         $array['udp'] = true; | ||||
|         return $array; | ||||
| @@ -21,27 +21,27 @@ class Clash | ||||
|     public static function buildVmess($uuid, $server) | ||||
|     { | ||||
|         $array = []; | ||||
|         $array['name'] = $server->name; | ||||
|         $array['name'] = $server['name']; | ||||
|         $array['type'] = 'vmess'; | ||||
|         $array['server'] = $server->host; | ||||
|         $array['port'] = $server->port; | ||||
|         $array['server'] = $server['host']; | ||||
|         $array['port'] = $server['port']; | ||||
|         $array['uuid'] = $uuid; | ||||
|         $array['alterId'] = 2; | ||||
|         $array['cipher'] = 'auto'; | ||||
|         $array['udp'] = true; | ||||
|         if ($server->tls) { | ||||
|             $tlsSettings = json_decode($server->tlsSettings); | ||||
|         if ($server['tls']) { | ||||
|             $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|             $array['tls'] = true; | ||||
|             if (!empty($tlsSettings->allowInsecure)) $array['skip-cert-verify'] = ($tlsSettings->allowInsecure ? true : false ); | ||||
|             if (!empty($tlsSettings->serverName)) $array['servername'] = $tlsSettings->serverName; | ||||
|             if (!empty($tlsSettings['allowInsecure'])) $array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false ); | ||||
|             if (!empty($tlsSettings['serverName'])) $array['servername'] = $tlsSettings['serverName']; | ||||
|         } | ||||
|         if ($server->network == 'ws') { | ||||
|             $array['network'] = $server->network; | ||||
|             if ($server->networkSettings) { | ||||
|                 $wsSettings = json_decode($server->networkSettings); | ||||
|                 if (isset($wsSettings->path)) $array['ws-path'] = $wsSettings->path; | ||||
|                 if (isset($wsSettings->headers->Host)) $array['ws-headers'] = [ | ||||
|                     'Host' => $wsSettings->headers->Host | ||||
|         if ($server['network'] == 'ws') { | ||||
|             $array['network'] = $server['network']; | ||||
|             if ($server['networkSettings']) { | ||||
|                 $wsSettings = json_decode($server['networkSettings'], true); | ||||
|                 if (isset($wsSettings['path'])) $array['ws-path'] = $wsSettings['path']; | ||||
|                 if (isset($wsSettings['headers']['Host'])) $array['ws-headers'] = [ | ||||
|                     'Host' => $wsSettings['headers']['Host'] | ||||
|                 ]; | ||||
|             } | ||||
|         } | ||||
| @@ -51,14 +51,14 @@ class Clash | ||||
|     public static function buildTrojan($password, $server) | ||||
|     { | ||||
|         $array = []; | ||||
|         $array['name'] = $server->name; | ||||
|         $array['name'] = $server['name']; | ||||
|         $array['type'] = 'trojan'; | ||||
|         $array['server'] = $server->host; | ||||
|         $array['port'] = $server->port; | ||||
|         $array['server'] = $server['host']; | ||||
|         $array['port'] = $server['port']; | ||||
|         $array['password'] = $password; | ||||
|         $array['udp'] = true; | ||||
|         if (!empty($server->server_name)) $array['sni'] = $server->server_name; | ||||
|         if (!empty($server->allow_insecure)) $array['skip-cert-verify'] = ($server->allow_insecure ? true : false ); | ||||
|         if (!empty($server['server_name'])) $array['sni'] = $server['server_name']; | ||||
|         if (!empty($server['allow_insecure'])) $array['skip-cert-verify'] = ($server['allow_insecure'] ? true : false ); | ||||
|         return $array; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -8,12 +8,12 @@ class QuantumultX | ||||
|     public static function buildShadowsocks($password, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "shadowsocks={$server->host}:{$server->port}", | ||||
|             "method={$server->cipher}", | ||||
|             "shadowsocks={$server['host']}:{$server['port']}", | ||||
|             "method={$server['cipher']}", | ||||
|             "password={$password}", | ||||
|             'fast-open=true', | ||||
|             'udp-relay=true', | ||||
|             "tag={$server->name}" | ||||
|             "tag={$server['name']}" | ||||
|         ]; | ||||
|         $config = array_filter($config); | ||||
|         $uri = implode(',', $config); | ||||
| @@ -24,41 +24,41 @@ class QuantumultX | ||||
|     public static function buildVmess($uuid, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "vmess={$server->host}:{$server->port}", | ||||
|             "vmess={$server['host']}:{$server['port']}", | ||||
|             'method=chacha20-poly1305', | ||||
|             "password={$uuid}", | ||||
|             'fast-open=true', | ||||
|             'udp-relay=true', | ||||
|             "tag={$server->name}" | ||||
|             "tag={$server['name']}" | ||||
|         ]; | ||||
|         if ($server->network === 'tcp') { | ||||
|             if ($server->tls) { | ||||
|                 $tlsSettings = json_decode($server->tlsSettings); | ||||
|         if ($server['network'] === 'tcp') { | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 array_push($config, 'obfs=over-tls'); | ||||
|                 if (isset($tlsSettings->allowInsecure)) { | ||||
|                 if (isset($tlsSettings['allowInsecure'])) { | ||||
|                     // Tips: allowInsecure=false = tls-verification=true | ||||
|                     array_push($config, $tlsSettings->allowInsecure ? 'tls-verification=false' : 'tls-verification=true'); | ||||
|                     array_push($config, $tlsSettings['allowInsecure'] ? 'tls-verification=false' : 'tls-verification=true'); | ||||
|                 } | ||||
|                 if (!empty($tlsSettings->serverName)) { | ||||
|                     array_push($config, "obfs-host={$tlsSettings->serverName}"); | ||||
|                 if (!empty($tlsSettings['serverName'])) { | ||||
|                     array_push($config, "obfs-host={$tlsSettings['serverName']}"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($server->network === 'ws') { | ||||
|             if ($server->tls) { | ||||
|                 $tlsSettings = json_decode($server->tlsSettings); | ||||
|         if ($server['network'] === 'ws') { | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 array_push($config, 'obfs=wss'); | ||||
|                 if (isset($tlsSettings->allowInsecure)) { | ||||
|                     array_push($config, $tlsSettings->allowInsecure ? 'tls-verification=false' : 'tls-verification=true'); | ||||
|                 if (isset($tlsSettings['allowInsecure'])) { | ||||
|                     array_push($config, $tlsSettings['allowInsecure'] ? 'tls-verification=false' : 'tls-verification=true'); | ||||
|                 } | ||||
|             } else { | ||||
|                 array_push($config, 'obfs=ws'); | ||||
|             } | ||||
|             if ($server->networkSettings) { | ||||
|                 $wsSettings = json_decode($server->networkSettings); | ||||
|                 if (isset($wsSettings->path)) array_push($config, "obfs-uri={$wsSettings->path}"); | ||||
|                 if (isset($wsSettings->headers->Host)) array_push($config, "obfs-host={$wsSettings->headers->Host}"); | ||||
|             if ($server['networkSettings']) { | ||||
|                 $wsSettings = json_decode($server['networkSettings'], true); | ||||
|                 if (isset($wsSettings['path'])) array_push($config, "obfs-uri={$wsSettings['path']}"); | ||||
|                 if (isset($wsSettings['headers']['Host'])) array_push($config, "obfs-host={$wsSettings['headers']['Host']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -70,15 +70,15 @@ class QuantumultX | ||||
|     public static function buildTrojan($password, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "trojan={$server->host}:{$server->port}", | ||||
|             "trojan={$server['host']}:{$server['port']}", | ||||
|             "password={$password}", | ||||
|             'over-tls=true', | ||||
|             $server->server_name ? "tls-host={$server->server_name}" : "", | ||||
|             $server['server_name'] ? "tls-host={$server['server_name']}" : "", | ||||
|             // Tips: allowInsecure=false = tls-verification=true | ||||
|             $server->allow_insecure ? 'tls-verification=false' : 'tls-verification=true', | ||||
|             $server['allow_insecure'] ? 'tls-verification=false' : 'tls-verification=true', | ||||
|             'fast-open=true', | ||||
|             'udp-relay=true', | ||||
|             "tag={$server->name}" | ||||
|             "tag={$server['name']}" | ||||
|         ]; | ||||
|         $config = array_filter($config); | ||||
|         $uri = implode(',', $config); | ||||
|   | ||||
| @@ -7,32 +7,32 @@ class Shadowrocket | ||||
| { | ||||
|     public static function buildShadowsocks($password, $server) | ||||
|     { | ||||
|         $name = rawurlencode($server->name); | ||||
|         $name = rawurlencode($server['name']); | ||||
|         $str = str_replace( | ||||
|             ['+', '/', '='], | ||||
|             ['-', '_', ''], | ||||
|             base64_encode("{$server->cipher}:{$password}") | ||||
|             base64_encode("{$server['cipher']}:{$password}") | ||||
|         ); | ||||
|         return "ss://{$str}@{$server->host}:{$server->port}#{$name}\r\n"; | ||||
|         return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n"; | ||||
|     } | ||||
|  | ||||
|     public static function buildVmess($uuid, $server) | ||||
|     { | ||||
|         $userinfo = base64_encode('auto:' . $uuid . '@' . $server->host . ':' . $server->port); | ||||
|         $userinfo = base64_encode('auto:' . $uuid . '@' . $server['host'] . ':' . $server['port']); | ||||
|         $config = [ | ||||
|             'remark' => $server->name | ||||
|             'remark' => $server['name'] | ||||
|         ]; | ||||
|         if ($server->tls) { | ||||
|             $tlsSettings = json_decode($server->tlsSettings); | ||||
|         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 (isset($tlsSettings['serverName'])) $config['peer'] = $tlsSettings['serverName']; | ||||
|             if (isset($tlsSettings['allowInsecure'])) $config['allowInsecure'] = 1; | ||||
|         } | ||||
|         if ($server->network === 'ws') { | ||||
|             $wsSettings = json_decode($server->networkSettings); | ||||
|         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 (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; | ||||
|             if (isset($wsSettings['headers']['Host'])) $config['obfsParam'] = $wsSettings['headers']['Host']; | ||||
|         } | ||||
|         $query = http_build_query($config, null, '&', PHP_QUERY_RFC3986); | ||||
|         $uri = "vmess://{$userinfo}?{$query}&tfo=1"; | ||||
| @@ -42,12 +42,12 @@ class Shadowrocket | ||||
|  | ||||
|     public static function buildTrojan($password, $server) | ||||
|     { | ||||
|         $name = rawurlencode($server->name); | ||||
|         $name = rawurlencode($server['name']); | ||||
|         $query = http_build_query([ | ||||
|             'allowInsecure' => $server->allow_insecure, | ||||
|             'peer' => $server->server_name | ||||
|             'allowInsecure' => $server['allow_insecure'], | ||||
|             'peer' => $server['server_name'] | ||||
|         ]); | ||||
|         $uri = "trojan://{$password}@{$server->host}:{$server->port}?{$query}&tfo=1#{$name}"; | ||||
|         $uri = "trojan://{$password}@{$server['host']}:{$server['port']}?{$query}&tfo=1#{$name}"; | ||||
|         $uri .= "\r\n"; | ||||
|         return $uri; | ||||
|     } | ||||
|   | ||||
| @@ -8,10 +8,10 @@ class Surfboard | ||||
|     public static function buildShadowsocks($password, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "{$server->name}=custom", | ||||
|             "{$server->host}", | ||||
|             "{$server->port}", | ||||
|             "{$server->cipher}", | ||||
|             "{$server['name']}=custom", | ||||
|             "{$server['host']}", | ||||
|             "{$server['port']}", | ||||
|             "{$server['cipher']}", | ||||
|             "{$password}", | ||||
|             'https://raw.githubusercontent.com/Hackl0us/proxy-tool-backup/master/SSEncrypt.module', | ||||
|             'tfo=true', | ||||
| @@ -26,36 +26,36 @@ class Surfboard | ||||
|     public static function buildVmess($uuid, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "{$server->name}=vmess", | ||||
|             "{$server->host}", | ||||
|             "{$server->port}", | ||||
|             "{$server['name']}=vmess", | ||||
|             "{$server['host']}", | ||||
|             "{$server['port']}", | ||||
|             "username={$uuid}", | ||||
|             'tfo=true', | ||||
|             'udp-relay=true' | ||||
|         ]; | ||||
|         if ($server->network === 'tcp') { | ||||
|             if ($server->tls) { | ||||
|                 $tlsSettings = json_decode($server->tlsSettings); | ||||
|                 array_push($config, $server->tls ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings->allowInsecure)) { | ||||
|                     array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|         if ($server['network'] === 'tcp') { | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 array_push($config, $server['tls'] ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings['allowInsecure'])) { | ||||
|                     array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($server->network === 'ws') { | ||||
|         if ($server['network'] === 'ws') { | ||||
|             array_push($config, 'ws=true'); | ||||
|             if ($server->tls) { | ||||
|                 $tlsSettings = json_decode($server->tlsSettings); | ||||
|                 array_push($config, $server->tls ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings->allowInsecure)) { | ||||
|                     array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 array_push($config, $server['tls'] ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings['allowInsecure'])) { | ||||
|                     array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|                 } | ||||
|             } | ||||
|             if ($server->networkSettings) { | ||||
|                 $wsSettings = json_decode($server->networkSettings); | ||||
|                 if (isset($wsSettings->path)) array_push($config, "ws-path={$wsSettings->path}"); | ||||
|                 if (isset($wsSettings->headers->Host)) array_push($config, "ws-headers=host:{$wsSettings->headers->Host}"); | ||||
|             if ($server['networkSettings']) { | ||||
|                 $wsSettings = json_decode($server['networkSettings'], true); | ||||
|                 if (isset($wsSettings['path'])) array_push($config, "ws-path={$wsSettings['path']}"); | ||||
|                 if (isset($wsSettings['headers']['Host'])) array_push($config, "ws-headers=host:{$wsSettings['headers']['Host']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -8,10 +8,10 @@ class Surge | ||||
|     public static function buildShadowsocks($password, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "{$server->name}=ss", | ||||
|             "{$server->host}", | ||||
|             "{$server->port}", | ||||
|             "encrypt-method={$server->cipher}", | ||||
|             "{$server['name']}=ss", | ||||
|             "{$server['host']}", | ||||
|             "{$server['port']}", | ||||
|             "encrypt-method={$server['cipher']}", | ||||
|             "password={$password}", | ||||
|             'tfo=true', | ||||
|             'udp-relay=true' | ||||
| @@ -25,39 +25,39 @@ class Surge | ||||
|     public static function buildVmess($uuid, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "{$server->name}=vmess", | ||||
|             "{$server->host}", | ||||
|             "{$server->port}", | ||||
|             "{$server['name']}=vmess", | ||||
|             "{$server['host']}", | ||||
|             "{$server['port']}", | ||||
|             "username={$uuid}", | ||||
|             'tfo=true', | ||||
|             'udp-relay=true' | ||||
|         ]; | ||||
|         if ($server->network === 'tcp') { | ||||
|             if ($server->tls) { | ||||
|                 $tlsSettings = json_decode($server->tlsSettings); | ||||
|                 array_push($config, $server->tls ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings->allowInsecure)) { | ||||
|                     array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|         if ($server['network'] === 'tcp') { | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 array_push($config, $server['tls'] ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings['allowInsecure'])) { | ||||
|                     array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|                 } | ||||
|                 if (!empty($tlsSettings->serverName)) { | ||||
|                     array_push($config, "sni={$tlsSettings->serverName}"); | ||||
|                 if (!empty($tlsSettings['serverName'])) { | ||||
|                     array_push($config, "sni={$tlsSettings['serverName']}"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($server->network === 'ws') { | ||||
|         if ($server['network'] === 'ws') { | ||||
|             array_push($config, 'ws=true'); | ||||
|             if ($server->tls) { | ||||
|                 $tlsSettings = json_decode($server->tlsSettings); | ||||
|                 array_push($config, $server->tls ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings->allowInsecure)) { | ||||
|                     array_push($config, $tlsSettings->allowInsecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 array_push($config, $server['tls'] ? 'tls=true' : 'tls=false'); | ||||
|                 if (!empty($tlsSettings['allowInsecure'])) { | ||||
|                     array_push($config, $tlsSettings['allowInsecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|                 } | ||||
|             } | ||||
|             if ($server->networkSettings) { | ||||
|                 $wsSettings = json_decode($server->networkSettings); | ||||
|                 if (isset($wsSettings->path)) array_push($config, "ws-path={$wsSettings->path}"); | ||||
|                 if (isset($wsSettings->headers->Host)) array_push($config, "ws-headers=host:{$wsSettings->headers->Host}"); | ||||
|             if ($server['networkSettings']) { | ||||
|                 $wsSettings = json_decode($server['networkSettings'], true); | ||||
|                 if (isset($wsSettings['path'])) array_push($config, "ws-path={$wsSettings['path']}"); | ||||
|                 if (isset($wsSettings['headers']['Host'])) array_push($config, "ws-headers=host:{$wsSettings['headers']['Host']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
| @@ -69,16 +69,16 @@ class Surge | ||||
|     public static function buildTrojan($password, $server) | ||||
|     { | ||||
|         $config = [ | ||||
|             "{$server->name}=trojan", | ||||
|             "{$server->host}", | ||||
|             "{$server->port}", | ||||
|             "{$server['name']}=trojan", | ||||
|             "{$server['host']}", | ||||
|             "{$server['port']}", | ||||
|             "password={$password}", | ||||
|             $server->server_name ? "sni={$server->server_name}" : "", | ||||
|             $server['server_name'] ? "sni={$server['server_name']}" : "", | ||||
|             'tfo=true', | ||||
|             'udp-relay=true' | ||||
|         ]; | ||||
|         if (!empty($server->allow_insecure)) { | ||||
|             array_push($config, $server->allow_insecure ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|         if (!empty($server['allow_insecure'])) { | ||||
|             array_push($config, $server['allow_insecure'] ? 'skip-cert-verify=true' : 'skip-cert-verify=false'); | ||||
|         } | ||||
|         $config = array_filter($config); | ||||
|         $uri = implode(',', $config); | ||||
|   | ||||
| @@ -2,56 +2,54 @@ | ||||
| namespace App\Utils; | ||||
|  | ||||
| use App\Models\Server; | ||||
| use App\Models\ServerShadowsocks; | ||||
| use App\Models\ServerTrojan; | ||||
| use App\Models\User; | ||||
|  | ||||
| class URLSchemes | ||||
| { | ||||
|     public static function buildShadowsocks(ServerShadowsocks $server, User $user) | ||||
|     public static function buildShadowsocks($server, User $user) | ||||
|     { | ||||
|         $name = rawurlencode($server->name); | ||||
|         $name = rawurlencode($server['name']); | ||||
|         $str = str_replace( | ||||
|             ['+', '/', '='], | ||||
|             ['-', '_', ''], | ||||
|             base64_encode("{$server->cipher}:{$user->uuid}") | ||||
|             base64_encode("{$server['cipher']}:{$user['uuid']}") | ||||
|         ); | ||||
|         return "ss://{$str}@{$server->host}:{$server->port}#{$name}\r\n"; | ||||
|         return "ss://{$str}@{$server['host']}:{$server['port']}#{$name}\r\n"; | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public static function buildVmess(Server $server, User $user) | ||||
|     public static function buildVmess($server, User $user) | ||||
|     { | ||||
|         $config = [ | ||||
|             "v" => "2", | ||||
|             "ps" => $server->name, | ||||
|             "add" => $server->host, | ||||
|             "port" => $server->port, | ||||
|             "id" => $user->uuid, | ||||
|             "ps" => $server['name'], | ||||
|             "add" => $server['host'], | ||||
|             "port" => $server['port'], | ||||
|             "id" => $user['uuid'], | ||||
|             "aid" => "2", | ||||
|             "net" => $server->network, | ||||
|             "net" => $server['network'], | ||||
|             "type" => "none", | ||||
|             "host" => "", | ||||
|             "path" => "", | ||||
|             "tls" => $server->tls ? "tls" : "" | ||||
|             "tls" => $server['tls'] ? "tls" : "" | ||||
|         ]; | ||||
|         if ((string)$server->network === 'ws') { | ||||
|             $wsSettings = json_decode($server->networkSettings); | ||||
|             if (isset($wsSettings->path)) $config['path'] = $wsSettings->path; | ||||
|             if (isset($wsSettings->headers->Host)) $config['host'] = $wsSettings->headers->Host; | ||||
|         if ((string)$server['network'] === 'ws') { | ||||
|             $wsSettings = json_decode($server['networkSettings'], true); | ||||
|             if (isset($wsSettings['path'])) $config['path'] = $wsSettings['path']; | ||||
|             if (isset($wsSettings['headers']['Host'])) $config['host'] = $wsSettings['headers']['Host']; | ||||
|         } | ||||
|         return "vmess://" . base64_encode(json_encode($config)) . "\r\n"; | ||||
|     } | ||||
|  | ||||
|     public static function buildTrojan(ServerTrojan $server, User $user) | ||||
|     public static function buildTrojan($server, User $user) | ||||
|     { | ||||
|         $name = rawurlencode($server->name); | ||||
|         $name = rawurlencode($server['name']); | ||||
|         $query = http_build_query([ | ||||
|             'allowInsecure' => $server->allow_insecure, | ||||
|             'peer' => $server->server_name, | ||||
|             'sni' => $server->server_name | ||||
|             'allowInsecure' => $server['allow_insecure'], | ||||
|             'peer' => $server['server_name'], | ||||
|             'sni' => $server['server_name'] | ||||
|         ]); | ||||
|         $uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$name}"; | ||||
|         $uri = "trojan://{$user['uuid']}@{$server['host']}:{$server['port']}?{$query}#{$name}"; | ||||
|         $uri .= "\r\n"; | ||||
|         return $uri; | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user