iamsaltedfish 3 years ago
parent
commit
0496da6521
2 changed files with 2 additions and 472 deletions
  1. 0 463
      config/appprofile.example.php
  2. 2 9
      src/Command/Tool.php

+ 0 - 463
config/appprofile.example.php

@@ -1,463 +0,0 @@
-<?php
-
-/**
- * default 为默认配置,你可以添加其他配置,但必须保证默认配置存在
- *
- * Checks 填写为没有直接在规则文件中使用的并且使用了筛选规则且组内或可能无节点的策略组名
- *  - 例如使用 regex 分类国家分组,未匹配时组内无节点,此类需要填入 Checks 中以保证配置文件无误
- *
- * Surge 以及 Surfboard 的 General 中,布尔值请填写为字符串
- *
- * Surge 以及 Surfboard 的 Proxy 中,请填写为该应用的格式
- * Clash 的 Proxy 中,请填写为数组
- */
-
-/**
- * Surge 配置文件定义
- */
-$_ENV['Surge_Profiles'] = [
-    'default' => [
-        'Checks' => [],
-        'General' => [
-            'loglevel'                    => 'notify',
-            'dns-server'                  => 'system, 119.29.29.29, 1.1.1.1',
-            'skip-proxy'                  => '127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, 17.0.0.0/8, localhost, *.local, *.crashlytics.com',
-            'external-controller-access'  => '[email protected]:8233',
-            'allow-wifi-access'           => 'true',
-            'enhanced-mode-by-rule'       => 'false',
-            'exclude-simple-hostnames'    => 'true',
-            'show-error-page-for-reject'  => 'true',
-            'ipv6'                        => 'true',
-            'replica'                     => 'false',
-            'http-listen'                 => '0.0.0.0:8234',
-            'socks5-listen'               => '0.0.0.0:8235',
-            'wifi-access-http-port'       => 6152,
-            'wifi-access-socks5-port'     => 6153,
-            'internet-test-url'           => 'http://wifi.vivo.com.cn/generate_204',
-            'proxy-test-url'              => 'http://cp.cloudflare.com',
-            'test-timeout'                => 3
-        ],
-        'Proxy' => [
-            '🚀直接连接 = direct'
-        ],
-        'ProxyGroup' => [
-            [
-                'name' => '🔰国外流量',
-                'type' => 'select',
-                'content' => [
-                    'regex' => '(.*)',
-                    'right-proxies' => [
-                        '🚀直接连接'
-                    ],
-                ]
-            ],
-            [
-                'name' => '⚓️其他流量',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量',
-                        '🚀直接连接'
-                    ]
-                ]
-            ],
-            [
-                'name' => '✈️Telegram',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Youtube',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Netflix',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬哔哩哔哩',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬国外媒体',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🍎苹果服务',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接',
-                        '🔰国外流量'
-                    ]
-                ]
-            ]
-        ],
-        'Rule' => [
-            'source' => 'surge/default.tpl'
-        ]
-    ]
-];
-
-/**
- * Surge 2.x 版本的配置文件定义
- */
-$_ENV['Surge2_Profiles'] = [
-    'default' => [
-        'Checks' => [],
-        'General' => [
-            'loglevel'                   => 'notify',
-            'ipv6'                       => 'true',
-            'replica'                    => 'false',
-            'dns-server'                 => 'system, 119.29.29.29, 1.1.1.1',
-            'skip-proxy'                 => '127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, 17.0.0.0/8, localhost, *.local, *.crashlytics.com',
-            'bypass-system'              => 'true',
-            'allow-wifi-access'          => 'true',
-            'external-controller-access' => '[email protected]:8233'
-        ],
-        'Proxy' => [
-            '🚀直接连接 = direct'
-        ],
-        'ProxyGroup' => [
-            [
-                'name' => '🔰国外流量',
-                'type' => 'select',
-                'content' => [
-                    'regex' => '(.*)',
-                    'right-proxies' => [
-                        '🚀直接连接'
-                    ],
-                ]
-            ],
-            [
-                'name' => '⚓️其他流量',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量',
-                        '🚀直接连接'
-                    ]
-                ]
-            ],
-            [
-                'name' => '✈️Telegram',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Youtube',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Netflix',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬哔哩哔哩',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬国外媒体',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🍎苹果服务',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接',
-                        '🔰国外流量'
-                    ]
-                ]
-            ]
-        ],
-        'Rule' => [
-            'source' => 'surge2/default.tpl'
-        ]
-    ]
-];
-
-/**
- * Clash 配置文件定义
- */
-$_ENV['Clash_Profiles'] = [
-    'default' => [
-        'Checks' => [],
-        'General' => [
-            'port'                => 7890,
-            'socks-port'          => 7891,
-            'redir-port'          => 7892,
-            'allow-lan'           => false,
-            'mode'                => 'rule',
-            'log-level'           => 'silent',
-            'external-controller' => '0.0.0.0:9090',
-            'secret'              => ''
-        ],
-        'DNS' => [
-            'enable'              => true,
-            'ipv6'                => false,
-            'listen'              => '0.0.0.0:53',
-            'enhanced-mode'       => 'fake-ip',
-            'fake-ip-range'       => '198.18.0.1/16',
-            'nameserver'=>[
-                '119.29.29.29',
-                '1.1.1.1'
-            ],
-            'fallback'=>[
-                '1.0.0.1',
-                '8.8.8.8'
-            ],
-            'fallback-filter'=>[
-                'geoip'=> true,
-                'ipcidr'=>[
-                    '240.0.0.0/4'
-                ]
-            ]
-        ],
-        'Proxy' => [],
-        'ProxyGroup' => [
-            [
-                'name' => '🔰国外流量',
-                'type' => 'select',
-                'content' => [
-                    'regex' => '(.*)',
-                    'right-proxies' => [
-                        '🚀直接连接'
-                    ],
-                ]
-            ],
-            [
-                'name' => '⚓️其他流量',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量',
-                        '🚀直接连接'
-                    ]
-                ]
-            ],
-            [
-                'name' => '✈️Telegram',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Youtube',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Netflix',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬哔哩哔哩',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬国外媒体',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🍎苹果服务',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接',
-                        '🔰国外流量'
-                    ]
-                ]
-            ],
-            [
-                'name' => '🚀直接连接',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        'DIRECT'
-                    ]
-                ]
-            ]
-        ],
-        'Rule' => [
-            'source' => 'clash/default.tpl'
-        ]
-    ]
-];
-
-/**
- * Surfboard 配置文件定义
- */
-$_ENV['Surfboard_Profiles'] = [
-    'default' => [
-        'Checks' => [],
-        'General' => [
-            'loglevel'   => 'notify',
-            'dns-server' => 'system, 119.29.29.29, 1.1.1.1',
-            'skip-proxy' => '127.0.0.1, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 100.64.0.0/10, 17.0.0.0/8, localhost, *.local, *.crashlytics.com',
-        ],
-        'Proxy' => [
-            '🚀直接连接 = direct'
-        ],
-        'ProxyGroup' => [
-            [
-                'name' => '🔰国外流量',
-                'type' => 'select',
-                'content' => [
-                    'regex' => '(.*)',
-                    'right-proxies' => [
-                        '🚀直接连接'
-                    ],
-                ]
-            ],
-            [
-                'name' => '⚓️其他流量',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量',
-                        '🚀直接连接'
-                    ]
-                ]
-            ],
-            [
-                'name' => '✈️Telegram',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Youtube',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬Netflix',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬哔哩哔哩',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🚀直接连接'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ],
-            [
-                'name' => '🎬国外媒体',
-                'type' => 'select',
-                'content' => [
-                    'left-proxies' => [
-                        '🔰国外流量'
-                    ],
-                    'regex' => '(.*)',
-                ]
-            ]
-        ],
-        'Rule' => [
-            'source' => 'surfboard/default.tpl'
-        ]
-    ]
-];

+ 2 - 9
src/Command/Tool.php

@@ -12,7 +12,6 @@ class Tool extends Command
         . '├─=: php xcat Tool [选项]' . PHP_EOL
         . '│ ├─ initQQWry               - 下载 IP 解析库' . PHP_EOL
         . '│ ├─ setTelegram             - 设置 Telegram 机器人' . PHP_EOL
-        . '│ ├─ detectConfigs           - 检查数据库内新增的配置' . PHP_EOL
         . '│ ├─ resetAllSettings        - 使用默认值覆盖设置中心设置' . PHP_EOL
         . '│ ├─ exportAllSettings       - 导出所有设置' . PHP_EOL
         . '│ ├─ importAllSettings       - 导入所有设置' . PHP_EOL;
@@ -85,11 +84,6 @@ class Tool extends Command
         }
     }
     
-    public function detectConfigs()
-    {
-        echo \App\Services\DefaultConfig::detectConfigs();
-    }
-    
     public function resetAllSettings()
     {
         $settings = Setting::all();
@@ -123,8 +117,6 @@ class Tool extends Command
 
     public function importAllSettings()
     {
-        $db = new DatatablesHelper();
-        
         $json_settings = file_get_contents('./config/settings.json');
         $settings      = json_decode($json_settings, true);
         $number        = count($settings);
@@ -133,8 +125,9 @@ class Tool extends Command
         for ($i = 0; $i < $number; $i++)
         {
             $item = $settings[$i]['item'];
+            $object = Setting::where('item', $item)->first();
             
-            if ($db->query("SELECT id FROM config WHERE item = '$item'") == null) {
+            if ($object == null) {
                 $new_item            = new Setting;
                 $new_item->id        = null;
                 $new_item->item      = $settings[$i]['item'];