@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | return $length % 2 == 0; |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | -function process_jsons($input, $locationNames){ |
|
| 17 | +function process_jsons($input, $locationNames) { |
|
| 18 | 18 | $input[0]['outbounds'] = array_merge($input[0]['outbounds'], array_filter($locationNames)); |
| 19 | 19 | return $input; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -function extract_names($input){ |
|
| 23 | - foreach($input as $config){ |
|
| 24 | - if ($config['tag'] !== ""){ |
|
| 22 | +function extract_names($input) { |
|
| 23 | + foreach ($input as $config) { |
|
| 24 | + if ($config['tag'] !== "") { |
|
| 25 | 25 | $locationNames[] = $config['tag']; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | function VmessSingbox($VmessUrl) { |
| 32 | 32 | $decode_vmess = decode_vmess($VmessUrl); |
| 33 | - if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === ""){ |
|
| 33 | + if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === "") { |
|
| 34 | 34 | return null; |
| 35 | 35 | } |
| 36 | 36 | $configResult = array( |
@@ -187,9 +187,9 @@ discard block |
||
| 187 | 187 | return $configResult; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | -function TrojanSingbox($TrojanUrl){ |
|
| 190 | +function TrojanSingbox($TrojanUrl) { |
|
| 191 | 191 | $decoded_trojan = parseProxyUrl($TrojanUrl); |
| 192 | - if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === ""){ |
|
| 192 | + if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === "") { |
|
| 193 | 193 | return null; |
| 194 | 194 | } |
| 195 | 195 | $configResult = array( |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | ) |
| 206 | 206 | ); |
| 207 | 207 | |
| 208 | - if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls"){ |
|
| 208 | + if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls") { |
|
| 209 | 209 | $configResult['tls'] = array( |
| 210 | 210 | "enabled"=> true, |
| 211 | 211 | "server_name"=> !is_null($decoded_trojan['params']['sni']) ? $decoded_trojan['params']['sni'] : "", |
@@ -233,8 +233,8 @@ discard block |
||
| 233 | 233 | "permit_without_stream" => false |
| 234 | 234 | ) |
| 235 | 235 | ); |
| 236 | - if (isset($decoded_trojan['params']["type"])){ |
|
| 237 | - if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc"){ |
|
| 236 | + if (isset($decoded_trojan['params']["type"])) { |
|
| 237 | + if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc") { |
|
| 238 | 238 | $configResult["transport"] = $transportTypes[$decoded_trojan['params']["type"]]; |
| 239 | 239 | } |
| 240 | 240 | } |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | function ShadowsocksSingbox($ShadowsocksUrl) { |
| 245 | 245 | $decoded_shadowsocks = ParseShadowsocks($ShadowsocksUrl); |
| 246 | - if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === ""){ |
|
| 246 | + if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === "") { |
|
| 247 | 247 | return null; |
| 248 | 248 | } |
| 249 | 249 | if ($decoded_shadowsocks['encryption_method'] === "chacha20-poly1305") { |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | return $configResult; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | -function GenerateConfig($input, $output, $theType){ |
|
| 305 | +function GenerateConfig($input, $output, $theType) { |
|
| 306 | 306 | $outbound = []; |
| 307 | 307 | $v2ray_subscription = str_replace(" ", "%20", $input); |
| 308 | 308 | |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | foreach ($configArray as $config) { |
| 311 | 311 | $configType = detect_type($config); |
| 312 | 312 | $config = str_replace("%20", " ", $config); |
| 313 | - switch($configType) { |
|
| 313 | + switch ($configType) { |
|
| 314 | 314 | case "vmess": |
| 315 | 315 | $configSingbox = VmessSingbox($config); |
| 316 | 316 | break; |
@@ -327,9 +327,9 @@ discard block |
||
| 327 | 327 | $configSingbox = ShadowsocksSingbox($config); |
| 328 | 328 | break; |
| 329 | 329 | } |
| 330 | - if (!is_null($configSingbox)){ |
|
| 330 | + if (!is_null($configSingbox)) { |
|
| 331 | 331 | $configName = $configSingbox['tag']; |
| 332 | - if (stripos($configName, "RELAY |
|