@@ -3,10 +3,10 @@ discard block |
||
3 | 3 | header("Content-type: application/json;"); |
4 | 4 | |
5 | 5 | function create_tehran_timestamp_tomorrow() { |
6 | - date_default_timezone_set('Asia/Tehran'); |
|
7 | - $dateTomorrow = new DateTime('tomorrow'); |
|
8 | - $timestampTomorrow = strtotime($dateTomorrow->format('Y-m-d H:i:s')); |
|
9 | - return $timestampTomorrow; |
|
6 | + date_default_timezone_set('Asia/Tehran'); |
|
7 | + $dateTomorrow = new DateTime('tomorrow'); |
|
8 | + $timestampTomorrow = strtotime($dateTomorrow->format('Y-m-d H:i:s')); |
|
9 | + return $timestampTomorrow; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | function isEvenLength($str) { |
@@ -22,27 +22,27 @@ discard block |
||
22 | 22 | function extract_names($input){ |
23 | 23 | foreach($input as $config){ |
24 | 24 | if ($config['tag'] !== ""){ |
25 | - $locationNames[] = $config['tag']; |
|
25 | + $locationNames[] = $config['tag']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | return $locationNames; |
29 | 29 | } |
30 | 30 | |
31 | 31 | function processWsPath($input) { |
32 | - if (strpos($input, '/') === 0) { |
|
32 | + if (strpos($input, '/') === 0) { |
|
33 | 33 | $input = substr($input, 1); |
34 | - } |
|
35 | - $max_early_data = 0; |
|
36 | - if (strpos($input, '?ed=2048') !== false) { |
|
34 | + } |
|
35 | + $max_early_data = 0; |
|
36 | + if (strpos($input, '?ed=2048') !== false) { |
|
37 | 37 | $input = str_replace('?ed=2048', '', $input); |
38 | 38 | $max_early_data = 2048; |
39 | - } |
|
40 | - $output = [ |
|
41 | - "path" => "/" . $input, |
|
42 | - "max_early_data" => $max_early_data |
|
43 | - ]; |
|
39 | + } |
|
40 | + $output = [ |
|
41 | + "path" => "/" . $input, |
|
42 | + "max_early_data" => $max_early_data |
|
43 | + ]; |
|
44 | 44 | |
45 | - return $output; |
|
45 | + return $output; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | function VmessSingbox($VmessUrl) |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | "ping_timeout" => "15s", |
107 | 107 | "permit_without_stream" => false, |
108 | 108 | ]; |
109 | - if ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"])) return null; |
|
109 | + if ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"])) return null; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | return $configResult; |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | ], |
323 | 323 | ]; |
324 | 324 | if (!isset($decodedTuic['params']['alpn']) || is_null($decodedTuic['params']['alpn']) || $decodedTuic['params']['alpn'] === "") { |
325 | - unset($configResult['tls']["alpn"]); |
|
325 | + unset($configResult['tls']["alpn"]); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | return $configResult; |
@@ -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 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | function ShadowsocksSingbox($ShadowsocksUrl) { |
271 | 271 | $decoded_shadowsocks = ParseShadowsocks($ShadowsocksUrl); |
272 | - if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === ""){ |
|
272 | + if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === "") { |
|
273 | 273 | return null; |
274 | 274 | } |
275 | 275 | if ($decoded_shadowsocks['encryption_method'] === "chacha20-poly1305") { |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | return $configResult; |
370 | 370 | } |
371 | 371 | |
372 | -function GenerateConfig($input, $output, $theType){ |
|
372 | +function GenerateConfig($input, $output, $theType) { |
|
373 | 373 | $outbound = []; |
374 | 374 | $v2ray_subscription = str_replace(" ", "%20", $input); |
375 | 375 | |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | foreach ($configArray as $config) { |
378 | 378 | $configType = detect_type($config); |
379 | 379 | $config = str_replace("%20", " ", $config); |
380 | - switch($configType) { |
|
380 | + switch ($configType) { |
|
381 | 381 | case "vmess": |
382 | 382 | $configSingbox = VmessSingbox($config); |
383 | 383 | break; |
@@ -397,9 +397,9 @@ discard block |
||
397 | 397 | $configSingbox = ShadowsocksSingbox($config); |
398 | 398 | break; |
399 | 399 | } |
400 | - if (!is_null($configSingbox)){ |
|
400 | + if (!is_null($configSingbox)) { |
|
401 | 401 | $configName = $configSingbox['tag']; |
402 | - if (stripos($configName, "RELAY |
@@ -97,7 +97,9 @@ discard block |
||
97 | 97 | "max_early_data" => $pathProcess['max_early_data'], |
98 | 98 | "early_data_header_name" => "Sec-WebSocket-Protocol", |
99 | 99 | ]; |
100 | - if ($configResult["transport"]["headers"]["Host"] === "" || is_null($configResult["transport"]["headers"]["Host"])) return null; |
|
100 | + if ($configResult["transport"]["headers"]["Host"] === "" || is_null($configResult["transport"]["headers"]["Host"])) { |
|
101 | + return null; |
|
102 | + } |
|
101 | 103 | } elseif ($decode_vmess["net"] === "grpc") { |
102 | 104 | $configResult["transport"] = [ |
103 | 105 | "type" => $decode_vmess["net"], |
@@ -106,7 +108,9 @@ discard block |
||
106 | 108 | "ping_timeout" => "15s", |
107 | 109 | "permit_without_stream" => false, |
108 | 110 | ]; |
109 | - if ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"])) return null; |
|
111 | + if ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"])) { |
|
112 | + return null; |
|
113 | + } |
|
110 | 114 | } |
111 | 115 | |
112 | 116 | return $configResult; |
@@ -200,8 +204,12 @@ discard block |
||
200 | 204 | $transportTypes[$decoded_vless["params"]["type"]]; |
201 | 205 | } |
202 | 206 | } |
203 | - if ($decoded_vless["params"]["type"] === "ws" && ($configResult["transport"]["headers"]["Host"] === "" || is_null($configResult["transport"]["headers"]["Host"]))) return null; |
|
204 | - if ($decoded_vless["params"]["type"] === "grpc" && ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"]))) return null; |
|
207 | + if ($decoded_vless["params"]["type"] === "ws" && ($configResult["transport"]["headers"]["Host"] === "" || is_null($configResult["transport"]["headers"]["Host"]))) { |
|
208 | + return null; |
|
209 | + } |
|
210 | + if ($decoded_vless["params"]["type"] === "grpc" && ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"]))) { |
|
211 | + return null; |
|
212 | + } |
|
205 | 213 | return $configResult; |
206 | 214 | } |
207 | 215 |