mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	clean up buildvmess()
This commit is contained in:
		| @@ -29,22 +29,27 @@ class Clash | ||||
|         $array['alterId'] = $server['alter_id']; | ||||
|         $array['cipher'] = 'auto'; | ||||
|         $array['udp'] = true; | ||||
|  | ||||
|         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 ($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'] | ||||
|                 ]; | ||||
|             if ($server['tlsSettings']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure'])) | ||||
|                     $array['skip-cert-verify'] = ($tlsSettings['allowInsecure'] ? true : false); | ||||
|                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName'])) | ||||
|                     $array['servername'] = $tlsSettings['serverName']; | ||||
|             } | ||||
|         } | ||||
|         if ($server['network'] === 'ws') { | ||||
|             if ($server['networkSettings']) { | ||||
|                 $wsSettings = json_decode($server['networkSettings'], true); | ||||
|                 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']]; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return $array; | ||||
|     } | ||||
|  | ||||
| @@ -58,7 +63,7 @@ class Clash | ||||
|         $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['allow_insecure'])) $array['skip-cert-verify'] = ($server['allow_insecure'] ? true : false); | ||||
|         return $array; | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -31,34 +31,33 @@ class QuantumultX | ||||
|             'udp-relay=true', | ||||
|             "tag={$server['name']}" | ||||
|         ]; | ||||
|         if ($server['network'] === 'tcp') { | ||||
|             if ($server['tls']) { | ||||
|                 $tlsSettings = json_decode($server['tlsSettings'], true); | ||||
|  | ||||
|         if ($server['tls']) { | ||||
|             if ($server['network'] === 'tcp') { | ||||
|                 array_push($config, 'obfs=over-tls'); | ||||
|                 if (isset($tlsSettings['allowInsecure'])) { | ||||
|                     // Tips: allowInsecure=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']}"); | ||||
|                 } | ||||
|             } else { | ||||
|                 array_push($config, 'obfs=wss'); | ||||
|             } | ||||
|         } else if ($server['network'] === 'ws') { | ||||
|             array_push($config, 'obfs=ws'); | ||||
|         } | ||||
|  | ||||
|         if ($server['network'] === 'ws') { | ||||
|             if ($server['tls']) { | ||||
|         if ($server['tls']) { | ||||
|             if ($server['tlsSettings']) { | ||||
|                 $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'); | ||||
|                 } | ||||
|             } else { | ||||
|                 array_push($config, 'obfs=ws'); | ||||
|                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure'])) | ||||
|                     array_push($config, 'tls-verification=' . $tlsSettings['allowInsecure'] ? 'false' : 'true'); | ||||
|                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName'])) | ||||
|                     array_push($config, "sni={$tlsSettings['serverName']}"); | ||||
|             } | ||||
|         } | ||||
|         if ($server['network'] === 'ws') { | ||||
|             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']}"); | ||||
|                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) | ||||
|                     array_push($config, "obfs-uri={$wsSettings['path']}"); | ||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||
|                     array_push($config, "obfs-host={$wsSettings['headers']['Host']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
|   | ||||
| @@ -33,29 +33,25 @@ class Surfboard | ||||
|             'tfo=true', | ||||
|             'udp-relay=true' | ||||
|         ]; | ||||
|         if ($server['network'] === 'tcp') { | ||||
|             if ($server['tls']) { | ||||
|  | ||||
|         if ($server['tls']) { | ||||
|             array_push($config, 'tls=true'); | ||||
|             if ($server['tlsSettings']) { | ||||
|                 $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 (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure'])) | ||||
|                     array_push($config, 'skip-cert-verify=' . $tlsSettings['allowInsecure'] ? 'true' : 'false'); | ||||
|                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName'])) | ||||
|                     array_push($config, "sni={$tlsSettings['serverName']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($server['network'] === 'ws') { | ||||
|             array_push($config, 'ws=true'); | ||||
|             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'], 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']}"); | ||||
|                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) | ||||
|                     array_push($config, "ws-path={$wsSettings['path']}"); | ||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||
|                     array_push($config, "ws-headers=Host:{$wsSettings['headers']['Host']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
| @@ -32,32 +32,25 @@ class Surge | ||||
|             'tfo=true', | ||||
|             'udp-relay=true' | ||||
|         ]; | ||||
|         if ($server['network'] === 'tcp') { | ||||
|             if ($server['tls']) { | ||||
|  | ||||
|         if ($server['tls']) { | ||||
|             array_push($config, 'tls=true'); | ||||
|             if ($server['tlsSettings']) { | ||||
|                 $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'])) { | ||||
|                 if (isset($tlsSettings['allowInsecure']) && !empty($tlsSettings['allowInsecure'])) | ||||
|                     array_push($config, 'skip-cert-verify=' . $tlsSettings['allowInsecure'] ? 'true' : 'false'); | ||||
|                 if (isset($tlsSettings['serverName']) && !empty($tlsSettings['serverName'])) | ||||
|                     array_push($config, "sni={$tlsSettings['serverName']}"); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($server['network'] === 'ws') { | ||||
|             array_push($config, 'ws=true'); | ||||
|             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'], 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']}"); | ||||
|                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) | ||||
|                     array_push($config, "ws-path={$wsSettings['path']}"); | ||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||
|                     array_push($config, "ws-headers=Host:{$wsSettings['headers']['Host']}"); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user