Passed
Push — main ( f4445e...52352c )
by YeBeKhe
01:48
created
modules/singbox.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
     return $length % 2 == 0;
8 8
 }
9 9
 
10
-function process_jsons($input, $locationNames){
10
+function process_jsons($input, $locationNames) {
11 11
     $input[0]['outbounds'] = array_merge($input[0]['outbounds'], array_filter($locationNames));
12 12
     return $input;
13 13
 }
14 14
 
15
-function extract_names($input){
16
-    foreach($input as $config){
17
-        if ($config['tag'] !== ""){
15
+function extract_names($input) {
16
+    foreach ($input as $config) {
17
+        if ($config['tag'] !== "") {
18 18
              $locationNames[] = $config['tag'];
19 19
         }
20 20
     }
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 function VmessSingbox($VmessUrl) {
25 25
     $decode_vmess = decode_vmess($VmessUrl);
26
-    if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === ""){
26
+    if (is_null($decode_vmess['ps']) || $decode_vmess['ps'] === "") {
27 27
         return null;
28 28
     }
29 29
     $configResult = array(
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
     return $configResult;
181 181
 }
182 182
 
183
-function TrojanSingbox($TrojanUrl){
183
+function TrojanSingbox($TrojanUrl) {
184 184
     $decoded_trojan = parseProxyUrl($TrojanUrl);
185
-    if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === ""){
185
+    if (is_null($decoded_trojan['hash']) || $decoded_trojan['hash'] === "") {
186 186
         return null;
187 187
     }
188 188
     $configResult = array(
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         )
199 199
     );
200 200
 
201
-    if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls"){
201
+    if ($decoded_trojan['port'] === "443" || $decoded_trojan['params']["security"] === "tls") {
202 202
         $configResult['tls'] = array(
203 203
             "enabled"=> true,
204 204
             "server_name"=> !is_null($decoded_trojan['params']['sni']) ? $decoded_trojan['params']['sni'] : "",
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
             "permit_without_stream" => false
227 227
           )
228 228
     );
229
-    if (isset($decoded_trojan['params']["type"])){
230
-        if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc"){
229
+    if (isset($decoded_trojan['params']["type"])) {
230
+        if ($decoded_trojan['params']["type"] === "ws" || $decoded_trojan['params']["type"] === "grpc") {
231 231
             $configResult["transport"] = $transportTypes[$decoded_trojan['params']["type"]];
232 232
         }
233 233
     }
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 function ShadowsocksSingbox($ShadowsocksUrl) {
238 238
     $decoded_shadowsocks = ParseShadowsocks($ShadowsocksUrl);
239
-    if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === ""){
239
+    if (is_null($decoded_shadowsocks['name']) || $decoded_shadowsocks['name'] === "") {
240 240
         return null;
241 241
     }
242 242
     $configResult = [
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
     return $configResult;
253 253
 }
254 254
 
255
-function GenerateConfig($input, $output){
255
+function GenerateConfig($input, $output) {
256 256
     $outbound = [];
257 257
     $v2ray_subscription = str_replace(" ", "%20", $input);
258 258
 
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
     foreach ($configArray as $config) {
261 261
         $configType = detect_type($config);
262 262
         $config = str_replace("%20", " ", $config);
263
-        switch($configType) {
263
+        switch ($configType) {
264 264
             case "vmess":
265 265
                 $configSingbox = VmessSingbox($config);
266 266
                 break;
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
                 $configSingbox = ShadowsocksSingbox($config);
275 275
                 break;
276 276
         }
277
-        if (!is_null($configSingbox)){
277
+        if (!is_null($configSingbox)) {
278 278
             $configName = $configSingbox['tag'];
279
-            if (stripos($configName, "RELAY
Please login to merge, or discard this patch.