admin 7 лет назад
Родитель
Сommit
5ef80a5058

+ 1 - 1
app/Console/Commands/AutoCheckNodeStatus.php

@@ -99,7 +99,7 @@ class AutoCheckNodeStatus extends Command
                 Log::info("【TCP阻断检测】" . $node->name . ' - ' . $node->ip . ' - ' . $text);
             }
 
-            // 10分钟内无节点负载信息且TCP检测认为不是宕机则认为是SSR(R)后端炸了
+            // 10分钟内无节点负载信息且TCP检测认为不是离线则认为是后端炸了
             $nodeTTL = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
             if ($tcpCheck !== 1 && !$nodeTTL) {
                 $this->notifyMaster($title, "节点**{$node->name}【{$node->ip}】**异常:**心跳异常**", $node->name, $node->server);

+ 19 - 1
app/Http/Controllers/AdminController.php

@@ -553,7 +553,7 @@ class AdminController extends Controller
 
             // 负载(10分钟以内)
             $node_info = SsNodeInfo::query()->where('node_id', $node->id)->where('log_time', '>=', strtotime("-10 minutes"))->orderBy('id', 'desc')->first();
-            $node->load = empty($node_info) || empty($node_info->load) ? '宕机' : $node_info->load;
+            $node->load = empty($node_info) || empty($node_info->load) ? '离线' : $node_info->load;
             $node->uptime = empty($online_log) ? 0 : seconds2time($node_info->uptime);
         }
 
@@ -2487,6 +2487,24 @@ EOF;
         return Response::view('admin.emailLog', $view);
     }
 
+    // 在线IP监控
+    public function onlineIPMonitor(Request $request)
+    {
+        $ip = $request->get('ip');
+
+        $query = SsNodeIp::query()->with(['node', 'user'])->where('type', 'tcp')->where('created_at', '>=', strtotime("-10 minutes"));
+
+        if ($ip) {
+            $query->where('ip', 'like', '%' . $ip . '%');
+        }
+        
+        $list = $query->orderBy('id', 'desc')->paginate(20)->appends($request->except('page'));
+
+        $view['list'] = $list;
+
+        return Response::view('admin.onlineIPMonitor', $view);
+    }
+
     // 生成用户标签
     private function makeUserLabels($userId, $labels)
     {

+ 8 - 8
app/Http/Models/Device.php

@@ -21,13 +21,13 @@ class Device extends Model
     {
         switch ($this->attributes['type']) {
             case 1:
-                $type_label = '<span class="label label-info"> Shadowsocks(R) </span>';
+                $type_label = '<span class="label label-danger"> Shadowsocks(R) </span>';
                 break;
             case 2:
-                $type_label = '<span class="label label-info"> V2Ray </span>';
+                $type_label = '<span class="label label-danger"> V2Ray </span>';
                 break;
             default:
-                $type_label = '<span class="label label-info"> 其他 </span>';
+                $type_label = '<span class="label label-default"> 其他 </span>';
         }
 
         return $type_label;
@@ -37,19 +37,19 @@ class Device extends Model
     {
         switch ($this->attributes['platform']) {
             case 1:
-                $platform_label = '<i class="fa fa-apple"></i>';
+                $platform_label = '<i class="fa fa-apple"></i> iOS';
                 break;
             case 2:
-                $platform_label = '<i class="fa fa-android"></i>';
+                $platform_label = '<i class="fa fa-android"></i> Android';
                 break;
             case 3:
-                $platform_label = '<i class="fa fa-apple"></i>';
+                $platform_label = '<i class="fa fa-apple"></i> Mac';
                 break;
             case 4:
-                $platform_label = '<i class="fa fa-windows"></i>';
+                $platform_label = '<i class="fa fa-windows"></i> Windows';
                 break;
             case 5:
-                $platform_label = '<i class="fa fa-linux"></i>';
+                $platform_label = '<i class="fa fa-linux"></i> Linux';
                 break;
             case 0:
             default:

+ 1 - 1
app/Mail/nodeCrashWarning.php

@@ -22,7 +22,7 @@ class nodeCrashWarning extends Mailable
 
     public function build()
     {
-        return $this->view('emails.nodeCrashWarning')->subject('节点宕机警告')->with([
+        return $this->view('emails.nodeCrashWarning')->subject('节点离线警告')->with([
             'nodeName'   => $this->nodeName,
             'nodeServer' => $this->nodeServer
         ]);

+ 7 - 1
resources/views/admin/layouts.blade.php

@@ -154,7 +154,7 @@
                         <span class="title">文章管理</span>
                     </a>
                 </li>
-                <li class="nav-item {{in_array(Request::path(), ['admin/userList', 'admin/addUser', 'admin/editUser', 'admin/userOrderList', 'admin/userBalanceLogList', 'admin/userTrafficLogList', 'admin/userRebateList', 'admin/userBanLogList', 'admin/export', 'admin/userMonitor', 'admin/subscribeLog', 'admin/userOnlineIPList']) ? 'active open' : ''}}">
+                <li class="nav-item {{in_array(Request::path(), ['admin/userList', 'admin/addUser', 'admin/editUser', 'admin/userOrderList', 'admin/userBalanceLogList', 'admin/userTrafficLogList', 'admin/userRebateList', 'admin/userBanLogList', 'admin/export', 'admin/userMonitor', 'admin/subscribeLog', 'admin/userOnlineIPList', 'admin/onlineIPMonitor']) ? 'active open' : ''}}">
                     <a href="javascript:;" class="nav-link nav-toggle">
                         <i class="fa fa-users"></i>
                         <span class="title">用户管理</span>
@@ -173,6 +173,12 @@
                                 <span class="title">用户在线IP</span>
                             </a>
                         </li>
+                        <li class="nav-item {{in_array(Request::path(), ['admin/onlineIPMonitor']) ? 'active open' : ''}}">
+                            <a href="{{url('admin/onlineIPMonitor')}}" class="nav-link">
+                                <i class="icon-list"></i>
+                                <span class="title">在线IP监控</span>
+                            </a>
+                        </li>
                         <li class="nav-item {{in_array(Request::path(), ['admin/userBalanceLogList']) ? 'active open' : ''}}">
                             <a href="{{url('admin/userBalanceLogList')}}" class="nav-link ">
                                 <i class="fa fa-money"></i>

+ 1 - 1
resources/views/admin/nodeList.blade.php

@@ -11,7 +11,7 @@
             <div class="col-md-12">
                 <div class="note note-info">
                     <p>节点绑定域名推荐使用<a href="https://www.namesilo.com/?rid=326ec20pa" target="_blank">Namesilo</a>,本面板支持自动更新DNS <a href="https://github.com/ssrpanel/SSRPanel/wiki/%E8%B4%AD%E4%B9%B0%E5%9F%9F%E5%90%8D%EF%BC%88%E8%87%AA%E5%B8%A6%E9%9A%90%E7%A7%81%E4%BF%9D%E6%8A%A4%EF%BC%89" target="_blank" style="color:red;">[购买域名]</a></p>
-                    <p>状态显示为'宕机':1.ShadowsocksR进程挂掉;2.节点和数据库之间的时区不一致或者通信延迟过高;3.服务器真的宕机。<a href="https://github.com/ssrpanel/ssrpanel/wiki/VPS%E6%8E%A8%E8%8D%90&%E8%B4%AD%E4%B9%B0%E7%BB%8F%E9%AA%8C" target="_blank" style="color:red;">[VPS推荐]</a></p>
+                    <p>状态显示为'离线':1.后端进程挂掉;2.节点和数据库之间的时区不一致或者通信延迟过高;3.服务器真的宕机。<a href="https://github.com/ssrpanel/ssrpanel/wiki/VPS%E6%8E%A8%E8%8D%90&%E8%B4%AD%E4%B9%B0%E7%BB%8F%E9%AA%8C" target="_blank" style="color:red;">[VPS推荐]</a></p>
                     <p>务必检查各节点服务器的时间是否同步。<a href="https://github.com/ssrpanel/SSRPanel/wiki/%E5%8D%95%E7%AB%AF%E5%8F%A3%E5%A4%9A%E7%94%A8%E6%88%B7%E7%9A%84%E5%9D%91" target="_blank" style="color:red;">[时间校准]</a></p>
                 </div>
             </div>

+ 98 - 0
resources/views/admin/onlineIPMonitor.blade.php

@@ -0,0 +1,98 @@
+@extends('admin.layouts')
+@section('css')
+    <link href="/assets/global/plugins/datatables/datatables.min.css" rel="stylesheet" type="text/css" />
+    <link href="/assets/global/plugins/datatables/plugins/bootstrap/datatables.bootstrap.css" rel="stylesheet" type="text/css" />
+    <style type="text/css">
+        input,select {
+            margin-bottom: 5px;
+        }
+    </style>
+@endsection
+@section('content')
+    <!-- BEGIN CONTENT BODY -->
+    <div class="page-content" style="padding-top:0;">
+        <!-- BEGIN PAGE BASE CONTENT -->
+        <div class="row">
+            <div class="col-md-12">
+                <!-- BEGIN EXAMPLE TABLE PORTLET-->
+                <div class="portlet light bordered">
+                    <div class="portlet-title">
+                        <div class="caption font-dark">
+                            <span class="caption-subject bold uppercase"> 在线IP监控<small>(最近10分钟)</small> </span>
+                        </div>
+                    </div>
+                    <div class="portlet-body">
+                        <div class="row">
+                            <div class="col-md-3 col-sm-4 col-xs-12">
+                                <input type="text" class="col-md-4 col-sm-4 col-xs-12 form-control" name="ip" value="{{Request::get('ip')}}" id="ip" placeholder="IP" onkeydown="if(event.keyCode==13){doSearch();}">
+                            </div>
+                            <div class="col-md-3 col-sm-4 col-xs-12">
+                                <button type="button" class="btn blue" onclick="doSearch();">查询</button>
+                                <button type="button" class="btn grey" onclick="doReset();">重置</button>
+                            </div>
+                        </div>
+                        <div class="table-scrollable table-scrollable-borderless">
+                            <table class="table table-hover table-light">
+                                <thead>
+                                    <tr>
+                                        <th> # </th>
+                                        <th> 时间 </th>
+                                        <th> 节点 </th>
+                                        <th> 类型 </th>
+                                        <th> IP </th>
+                                    </tr>
+                                </thead>
+                                <tbody>
+                                    @if ($list->isEmpty())
+                                        <tr>
+                                            <td colspan="5" style="text-align: center;">暂无数据</td>
+                                        </tr>
+                                    @else
+                                        @foreach($list as $vo)
+                                            <tr>
+                                                <td>{{$vo->id}}</td>
+                                                <td>{{$vo->created_at}}</td>
+                                                <td>{{$vo->node ? $vo->node->name : '【节点已删除】'}}</td>
+                                                <td>{{$vo->type}}</td>
+                                                <td>{{$vo->ip}}</td>
+                                            </tr>
+                                        @endforeach
+                                    @endif
+                                </tbody>
+                            </table>
+                        </div>
+                        <div class="row">
+                            <div class="col-md-4 col-sm-4">
+                                <div class="dataTables_info" role="status" aria-live="polite">共 {{$list->total()}} 个账号</div>
+                            </div>
+                            <div class="col-md-8 col-sm-8">
+                                <div class="dataTables_paginate paging_bootstrap_full_number pull-right">
+                                    {{ $list->links() }}
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <!-- END EXAMPLE TABLE PORTLET-->
+            </div>
+        </div>
+        <!-- END PAGE BASE CONTENT -->
+    </div>
+    <!-- END CONTENT BODY -->
+@endsection
+@section('script')
+    <script src="/assets/global/plugins/clipboardjs/clipboard.min.js" type="text/javascript"></script>
+    <script type="text/javascript">
+        // 搜索
+        function doSearch() {
+            var ip = $("#ip").val();
+
+            window.location.href = '{{url('admin/onlineIPMonitor')}}' + '?ip=' + ip;
+        }
+
+        // 重置
+        function doReset() {
+            window.location.href = '{{url('admin/onlineIPMonitor')}}';
+        }
+    </script>
+@endsection

+ 7 - 7
resources/views/admin/system.blade.php

@@ -526,10 +526,10 @@
                                                     </div>
                                                     <div class="form-group">
                                                         <div class="col-md-6 col-sm-6 col-xs-12">
-                                                            <label for="is_node_crash_warning" class="col-md-3 control-label">节点宕机提醒</label>
+                                                            <label for="is_node_crash_warning" class="col-md-3 control-label">节点离线提醒</label>
                                                             <div class="col-md-9">
                                                                 <input type="checkbox" class="make-switch" @if($is_node_crash_warning) checked @endif id="is_node_crash_warning" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
-                                                                <span class="help-block"> 启用后如果节点宕机则发出提醒邮件 </span>
+                                                                <span class="help-block"> 启用后如果节点离线则发出提醒邮件 </span>
                                                             </div>
                                                         </div>
                                                         <div class="col-md-6 col-sm-6 col-xs-12">
@@ -541,7 +541,7 @@
                                                                         <button class="btn btn-success" type="button" onclick="setCrashWarningEmail()">修改</button>
                                                                     </span>
                                                                 </div>
-                                                                <span class="help-block"> 填写此值则节点宕机、用户回复工单都会自动提醒 </span>
+                                                                <span class="help-block"> 填写此值则节点离线、用户回复工单都会自动提醒 </span>
                                                             </div>
                                                         </div>
                                                     </div>
@@ -572,7 +572,7 @@
                                                             <label for="is_server_chan" class="col-md-3 control-label">ServerChan</label>
                                                             <div class="col-md-9">
                                                                 <input type="checkbox" class="make-switch" @if($is_server_chan) checked @endif id="is_server_chan" data-on-color="success" data-off-color="danger" data-on-text="启用" data-off-text="关闭">
-                                                                <span class="help-block"> 推送节点宕机提醒、用户流量异常警告、节点使用报告(<a href="http://sc.ftqq.com" target="_blank">绑定微信</a>) </span>
+                                                                <span class="help-block"> 推送节点离线提醒、用户流量异常警告、节点使用报告(<a href="http://sc.ftqq.com" target="_blank">绑定微信</a>) </span>
                                                             </div>
                                                         </div>
                                                         <div class="col-md-6 col-sm-6 col-xs-12">
@@ -1203,7 +1203,7 @@
             }
         });
 
-        // 启用、禁用节点宕机发件提醒管理员
+        // 启用、禁用节点离线发件提醒管理员
         $('#is_node_crash_warning').on({
             'switchChange.bootstrapSwitch': function(event, state) {
                 var is_node_crash_warning = state ? 1 : 0;
@@ -1218,7 +1218,7 @@
             }
         });
 
-        // 启用、禁用节点宕机发ServerChan微信消息提醒
+        // 启用、禁用节点离线发ServerChan微信消息提醒
         $('#is_server_chan').on({
             'switchChange.bootstrapSwitch': function(event, state) {
                 var is_server_chan = state ? 1 : 0;
@@ -1524,7 +1524,7 @@
             });
         }
 
-        // 设置节点宕机警告收件地址
+        // 设置节点离线警告收件地址
         function setCrashWarningEmail() {
             var crash_warning_email = $("#crash_warning_email").val();
 

+ 11 - 6
resources/views/admin/userOnlineIPList.blade.php

@@ -98,12 +98,12 @@
                                                     @if(!$user->onlineIPList->isEmpty())
                                                         <table class="table table-hover table-light">
                                                             <thead>
-                                                            <tr>
-                                                                <th> 时间 </th>
-                                                                <th> 节点 </th>
-                                                                <th> 类型 </th>
-                                                                <th> IP </th>
-                                                            </tr>
+                                                                <tr>
+                                                                    <th> 时间 </th>
+                                                                    <th> 节点 </th>
+                                                                    <th> 类型 </th>
+                                                                    <th> IP </th>
+                                                                </tr>
                                                             </thead>
                                                             <tbody>
                                                             @foreach($user->onlineIPList as $vo)
@@ -157,5 +157,10 @@
 
             window.location.href = '{{url('admin/userOnlineIPList')}}' + '?username=' + username + '&wechat=' + wechat + '&qq=' + qq + '&port=' + port + '&status=' + status + '&enable=' + enable;
         }
+
+        // 重置
+        function doReset() {
+            window.location.href = '{{url('admin/userOnlineIPList')}}';
+        }
     </script>
 @endsection

+ 2 - 2
resources/views/emails/nodeCrashWarning.blade.php

@@ -47,7 +47,7 @@
                                                 <th style="Margin:0;color:#333;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:19px;margin:0;padding:0;text-align:left">
                                                     <h6 style="Margin:0;Margin-bottom:10px;color:#f3f3f3;font-family:Helvetica,Arial,sans-serif;font-size:18px;font-weight:400;line-height:1.3;margin:0;margin-bottom:8px;margin-top:8px;padding:0;text-align:left;word-wrap:normal">
                                                         <a href="#" style="Margin:0;color:#f3f3f3;font-family:Helvetica,Arial,sans-serif;font-weight:400;line-height:1.3;margin:0;padding:0;text-align:left;text-decoration:none" target="_blank">
-                                                            节点宕机警告
+                                                            节点离线警告
                                                         </a>
                                                     </h6>
                                                 </th>
@@ -68,7 +68,7 @@
                                 <tr style="padding:0;text-align:left;vertical-align:top">
                                     <th style="Margin:0;color:#333;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:19px;margin:0;padding:0;text-align:left">
                                         <div class="release" style="padding-top:5px;padding-left:20px;padding-bottom:20px;">
-                                            <p>节点【{{$nodeName}}】({{$nodeServer}})可能宕机,请及时检查。</p>
+                                            <p>节点【{{$nodeName}}】({{$nodeServer}})离线,请及时检查。</p>
                                         </div>
                                     </th>
                                     <th class="expander" style="Margin:0;color:#333;font-family:Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;line-height:19px;margin:0;padding:0!important;text-align:left;visibility:hidden;width:0"></th>

+ 12 - 6
resources/views/subscribe/deviceList.blade.php

@@ -11,10 +11,16 @@
 @section('content')
     <!-- BEGIN CONTENT BODY -->
     <div class="page-content" style="padding-top:0;">
-        <!-- BEGIN PAGE BASE CONTENT -->
         <div class="row">
             <div class="col-md-12">
-                <!-- BEGIN EXAMPLE TABLE PORTLET-->
+                <div class="row">
+                    <div class="col-md-12">
+                        <div class="note note-info">
+                            <p>1.禁止设备订阅功能是根据客户端订阅时请求头信息做判断,禁用相应设备订阅时返回错误信息</p>
+                            <p>以下请求头信息不全或者错误,请各位自行检测,提到Issues</p>
+                        </div>
+                    </div>
+                </div>
                 <div class="portlet light bordered">
                     <div class="portlet-title">
                         <div class="caption font-dark">
@@ -46,9 +52,10 @@
                                 <thead>
                                 <tr>
                                     <th> # </th>
+                                    <th> 名称 </th>
                                     <th> 类型 </th>
                                     <th> 平台 </th>
-                                    <th> 名称 </th>
+                                    <th> 请求头 </th>
                                     <th> 操作 </th>
                                 </tr>
                                 </thead>
@@ -61,9 +68,10 @@
                                         @foreach($deviceList as $vo)
                                             <tr class="odd gradeX">
                                                 <td> {{$vo->id}} </td>
+                                                <td> {{$vo->name}} </td>
                                                 <td> {!! $vo->type_label !!} </td>
                                                 <td> {!! $vo->platform_label !!} </td>
-                                                <td> {{$vo->name}} </td>
+                                                <td> {{$vo->header}} </td>
                                                 <td>
                                                     @if($vo->status == 0)
                                                         <button type="button" class="btn btn-sm green btn-outline" onclick="setDeviceStatus('{{$vo->id}}', 1)">启用</button>
@@ -90,10 +98,8 @@
                         </div>
                     </div>
                 </div>
-                <!-- END EXAMPLE TABLE PORTLET-->
             </div>
         </div>
-        <!-- END PAGE BASE CONTENT -->
     </div>
     <!-- END CONTENT BODY -->
 @endsection

+ 1 - 0
routes/web.php

@@ -90,6 +90,7 @@ Route::group(['middleware' => ['isForbidden', 'isLogin', 'isAdmin']], function (
     Route::get("marketing/emailList", "MarketingController@emailList"); // 邮件消息列表
     Route::get("marketing/pushList", "MarketingController@pushList"); // 推送消息列表
     Route::post("marketing/addPushMarketing", "MarketingController@addPushMarketing"); // 推送消息
+    Route::get("admin/onlineIPMonitor", "AdminController@onlineIPMonitor"); // 在线IP监控
     Route::any("admin/decompile", "AdminController@decompile"); // SS(R)链接反解析
     Route::get('admin/download', 'AdminController@download'); // 下载转换过的JSON配置
     Route::any('admin/convert', 'AdminController@convert'); // 格式转换

+ 25 - 4
sql/db.sql

@@ -1178,10 +1178,11 @@ CREATE TABLE `ss_node_deny` (
 -- ----------------------------
 CREATE TABLE `device` (
 	`id` INT(11) NOT NULL AUTO_INCREMENT,
-	`type` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '类型:1-Shadowsocks(R)、2-V2Ray',
+	`type` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '类型:0-兼容、1-Shadowsocks(R)、2-V2Ray',
 	`platform` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '所属平台:0-其他、1-iOS、2-Android、3-Mac、4-Windows、5-Linux',
 	`name` VARCHAR(50) NOT NULL COMMENT '设备名称',
 	`status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '状态:0-禁止订阅、1-允许订阅',
+	`header` VARCHAR(100) NOT NULL COMMENT '请求时头部的识别特征码',
 	PRIMARY KEY (`id`)
 ) COMMENT='设备型号表' ENGINE=MyISAM;
 
@@ -1189,9 +1190,29 @@ CREATE TABLE `device` (
 -- ----------------------------
 -- Records of `device`
 -- ----------------------------
-INSERT INTO `device` VALUES ('1', '1', '1', 'Quantumult', 1);
-INSERT INTO `device` VALUES ('1', '1', '1', 'Shadowrocket', 1);
-INSERT INTO `device` VALUES ('1', '1', '1', 'ShadowsocksX-NG-R', 1);
+INSERT INTO `device` (`id`, `type`, `platform`, `name`, `status`, `header`) VALUES
+	(1, 1, 1, 'Quantumult', 1, 'Quantumult'),
+	(2, 1, 1, 'Shadowrocket', 1, 'Shadowrocket'),
+	(3, 1, 3, 'ShadowsocksX-NG-R', 1, 'ShadowsocksX-NG-R'),
+	(4, 1, 1, 'Pepi', 1, 'Pepi'),
+	(5, 1, 1, 'Potatso 2', 1, 'Potatso'),
+	(6, 1, 1, 'Potatso Lite', 1, 'Potatso'),
+	(7, 1, 4, 'ShadowsocksR', 1, 'ShadowsocksR'),
+	(8, 2, 4, 'V2RayW', 1, 'V2RayW'),
+	(9, 2, 4, 'V2RayN', 1, 'V2RayN'),
+	(10, 2, 4, 'V2RayS', 1, 'V2RayS'),
+	(11, 2, 4, 'Clash for Windows', 1, 'Clash'),
+	(12, 2, 3, 'V2RayX', 1, 'V2RayX'),
+	(13, 2, 3, 'V2RayU', 1, 'V2RayU'),
+	(14, 2, 3, 'V2RayC', 1, 'V2RayC'),
+	(15, 2, 3, 'ClashX', 1, 'ClashX'),
+	(16, 2, 1, 'Kitsunebi', 1, 'Kitsunebi'),
+	(17, 2, 1, 'Kitsunebi Lite', 1, 'Kitsunebi'),
+	(18, 2, 1, 'i2Ray', 1, 'i2Ray'),
+	(19, 2, 2, 'BifrostV', 1, 'BifrostV'),
+	(20, 2, 2, 'V2RayNG', 1, 'V2RayNG'),
+	(21, 2, 2, 'ShadowsocksR', 1, 'okhttp'),
+	(22, 2, 2, 'SSRR', 1, 'okhttp');
 
 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
 /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;

+ 2 - 2
sql/update/20190129.sql

@@ -1,7 +1,7 @@
 -- 加入订阅设备表
 CREATE TABLE `device` (
 	`id` INT(11) NOT NULL AUTO_INCREMENT,
-	`type` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '类型:1-Shadowsocks(R)、2-V2Ray',
+	`type` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '类型:0-兼容、1-Shadowsocks(R)、2-V2Ray',
 	`platform` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '所属平台:0-其他、1-iOS、2-Android、3-Mac、4-Windows、5-Linux',
 	`name` VARCHAR(50) NOT NULL COMMENT '设备名称',
 	`status` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '状态:0-禁止订阅、1-允许订阅',
@@ -10,4 +10,4 @@ CREATE TABLE `device` (
 
 INSERT INTO `device` VALUES ('1', '1', '1', 'Quantumult', 1);
 INSERT INTO `device` VALUES ('2', '1', '1', 'Shadowrocket', 1);
-INSERT INTO `device` VALUES ('3', '1', '1', 'ShadowsocksX-NG-R', 1);
+INSERT INTO `device` VALUES ('3', '1', '3', 'ShadowsocksX-NG-R', 1);

+ 31 - 0
sql/update/20190131.sql

@@ -0,0 +1,31 @@
+-- 设备表加入 请求时头部的识别特征码 字段
+ALTER TABLE `device`
+	CHANGE COLUMN `platform` `platform` TINYINT(4) NOT NULL DEFAULT '1' COMMENT '所属平台:0-其他、1-iOS、2-Android、3-Mac、4-Windows、5-Linux' AFTER `type`,
+	ADD COLUMN `header` VARCHAR(100) NOT NULL COMMENT '请求时头部的识别特征码' AFTER `status`;
+
+-- 重新初始化设备表数据
+TRUNCATE TABLE `device`;
+INSERT INTO `device` (`id`, `type`, `platform`, `name`, `status`, `header`) VALUES
+	(1, 1, 1, 'Quantumult', 1, 'Quantumult'),
+	(2, 1, 1, 'Shadowrocket', 1, 'Shadowrocket'),
+	(3, 1, 3, 'ShadowsocksX-NG-R', 1, 'ShadowsocksX-NG-R'),
+	(4, 1, 1, 'Pepi', 1, 'Pepi'),
+	(5, 1, 1, 'Potatso 2', 1, 'Potatso'),
+	(6, 1, 1, 'Potatso Lite', 1, 'Potatso'),
+	(7, 1, 4, 'ShadowsocksR', 1, 'ShadowsocksR'),
+	(8, 2, 4, 'V2RayW', 1, 'V2RayW'),
+	(9, 2, 4, 'V2RayN', 1, 'V2RayN'),
+	(10, 2, 4, 'V2RayS', 1, 'V2RayS'),
+	(11, 2, 4, 'Clash for Windows', 1, 'Clash'),
+	(12, 2, 3, 'V2RayX', 1, 'V2RayX'),
+	(13, 2, 3, 'V2RayU', 1, 'V2RayU'),
+	(14, 2, 3, 'V2RayC', 1, 'V2RayC'),
+	(15, 2, 3, 'ClashX', 1, 'ClashX'),
+	(16, 2, 1, 'Kitsunebi', 1, 'Kitsunebi'),
+	(17, 2, 1, 'Kitsunebi Lite', 1, 'Kitsunebi'),
+	(18, 2, 1, 'i2Ray', 1, 'i2Ray'),
+	(19, 2, 2, 'BifrostV', 1, 'BifrostV'),
+	(20, 2, 2, 'V2RayNG', 1, 'V2RayNG'),
+	(21, 2, 2, 'ShadowsocksR', 1, 'okhttp'),
+	(22, 2, 2, 'SSRR', 1, 'okhttp');
+