@@ -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,7 +22,7 @@ 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; |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | "authenticated_length"=> true, |
46 | 46 | "packet_encoding"=> "", |
47 | 47 | "multiplex"=> array( |
48 | - "enabled"=> false, |
|
49 | - "protocol"=> "smux", |
|
50 | - "max_streams"=> 32 |
|
48 | + "enabled"=> false, |
|
49 | + "protocol"=> "smux", |
|
50 | + "max_streams"=> 32 |
|
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | "utls"=> array( |
61 | 61 | "enabled"=> true, |
62 | 62 | "fingerprint"=> "chrome" |
63 | - ) |
|
63 | + ) |
|
64 | 64 | ); |
65 | 65 | } |
66 | 66 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | if ( |
151 | 151 | !isEvenLength($decoded_vless["params"]["sid"]) && |
152 | 152 | !is_null($decoded_vless["params"]["sid"]) |
153 | - ) { |
|
153 | + ) { |
|
154 | 154 | return null; |
155 | 155 | } |
156 | 156 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | "server_port"=> intval($decoded_trojan['port']), |
200 | 200 | "password"=> $decoded_trojan['username'], |
201 | 201 | "multiplex"=> array( |
202 | - "enabled"=> false, |
|
203 | - "protocol"=> "smux", |
|
204 | - "max_streams"=> 32 |
|
202 | + "enabled"=> false, |
|
203 | + "protocol"=> "smux", |
|
204 | + "max_streams"=> 32 |
|
205 | 205 | ) |
206 | 206 | ); |
207 | 207 | |
@@ -224,14 +224,14 @@ discard block |
||
224 | 224 | "headers"=> array( |
225 | 225 | "Host"=> $decoded_trojan['params']["host"] |
226 | 226 | ) |
227 | - ), |
|
228 | - "grpc" => array( |
|
227 | + ), |
|
228 | + "grpc" => array( |
|
229 | 229 | "type" => $decoded_trojan['params']["type"], |
230 | 230 | "service_name" => $decoded_trojan['params']["serviceName"], |
231 | 231 | "idle_timeout" => "15s", |
232 | 232 | "ping_timeout" => "15s", |
233 | 233 | "permit_without_stream" => false |
234 | - ) |
|
234 | + ) |
|
235 | 235 | ); |
236 | 236 | if (isset($decoded_trojan['params']["type"])){ |
237 | 237 | if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc"){ |
@@ -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 | $configResult = [ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | return $configResult; |
260 | 260 | } |
261 | 261 | |
262 | -function GenerateConfig($input, $output){ |
|
262 | +function GenerateConfig($input, $output) { |
|
263 | 263 | $outbound = []; |
264 | 264 | $v2ray_subscription = str_replace(" ", "%20", $input); |
265 | 265 | |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | foreach ($configArray as $config) { |
268 | 268 | $configType = detect_type($config); |
269 | 269 | $config = str_replace("%20", " ", $config); |
270 | - switch($configType) { |
|
270 | + switch ($configType) { |
|
271 | 271 | case "vmess": |
272 | 272 | $configSingbox = VmessSingbox($config); |
273 | 273 | break; |
@@ -281,9 +281,9 @@ discard block |
||
281 | 281 | $configSingbox = ShadowsocksSingbox($config); |
282 | 282 | break; |
283 | 283 | } |
284 | - if (!is_null($configSingbox)){ |
|
284 | + if (!is_null($configSingbox)) { |
|
285 | 285 | $configName = $configSingbox['tag']; |
286 | - if (stripos($configName, "RELAY |