Passed
Push — main ( 501794...c2fc7c )
by YeBeKhe
02:25
created
modules/singbox.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@  discard block
 block discarded – undo
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
     }
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 
272 272
 function ShadowsocksSingbox($ShadowsocksUrl) {
273 273
     $decoded_shadowsocks = ParseShadowsocks($ShadowsocksUrl);
274
-    if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === ""){
274
+    if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === "") {
275 275
         return null;
276 276
     }
277 277
     if ($decoded_shadowsocks['encryption_method'] === "chacha20-poly1305") {
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     return $configResult;
372 372
 }
373 373
 
374
-function GenerateConfig($input, $output, $theType){
374
+function GenerateConfig($input, $output, $theType) {
375 375
     $outbound = [];
376 376
     $v2ray_subscription = str_replace(" ", "%20", $input);
377 377
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     foreach ($configArray as $config) {
380 380
         $configType = detect_type($config);
381 381
         $config = str_replace("%20", " ", $config);
382
-        switch($configType) {
382
+        switch ($configType) {
383 383
             case "vmess":
384 384
                 $configSingbox = VmessSingbox($config);
385 385
                 break;
@@ -399,9 +399,9 @@  discard block
 block discarded – undo
399 399
                 $configSingbox = ShadowsocksSingbox($config);
400 400
                 break;
401 401
         }
402
-        if (!is_null($configSingbox)){
402
+        if (!is_null($configSingbox)) {
403 403
             $configName = $configSingbox['tag'];
404
-            if (stripos($configName, "RELAY
Please login to merge, or discard this patch.
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -97,7 +97,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -264,8 +272,12 @@  discard block
 block discarded – undo
264 272
                 $transportTypes[$decoded_trojan["params"]["type"]];
265 273
         }
266 274
     }
267
-    if ($decoded_trojan["params"]["type"] === "ws" && ($configResult["transport"]["headers"]["Host"] === "" || is_null($configResult["transport"]["headers"]["Host"]))) return null;
268
-    if ($decoded_trojan["params"]["type"] === "grpc" && ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"]))) return null;
275
+    if ($decoded_trojan["params"]["type"] === "ws" && ($configResult["transport"]["headers"]["Host"] === "" || is_null($configResult["transport"]["headers"]["Host"]))) {
276
+        return null;
277
+    }
278
+    if ($decoded_trojan["params"]["type"] === "grpc" && ($configResult["transport"]["service_name"] === "" || is_null($configResult["transport"]["service_name"]))) {
279
+        return null;
280
+    }
269 281
     return $configResult;
270 282
 }
271 283
 
Please login to merge, or discard this patch.