Browse Source

update: custom v2ray alter id

Tokumeikoi 4 years ago
parent
commit
fb9465b5a6

+ 1 - 1
app/Http/Controllers/Client/AppController.php

@@ -87,7 +87,7 @@ class AppController extends Controller
         $json->outbound->settings->vnext[0]->address = (string)$server->host;
         $json->outbound->settings->vnext[0]->port = (int)$server->port;
         $json->outbound->settings->vnext[0]->users[0]->id = (string)$user->uuid;
-        $json->outbound->settings->vnext[0]->users[0]->alterId = (int)$user->v2ray_alter_id;
+        $json->outbound->settings->vnext[0]->users[0]->alterId = (int)$server->alter_id;
         $json->outbound->settings->vnext[0]->remark = (string)$server->name;
         $json->outbound->streamSettings->network = $server->network;
         if ($server->networkSettings) {

+ 3 - 4
app/Http/Controllers/Server/DeepbworkController.php

@@ -47,12 +47,11 @@ class DeepbworkController extends Controller
             $user->v2ray_user = [
                 "uuid" => $user->uuid,
                 "email" => sprintf("%s@v2board.user", $user->uuid),
-                "alter_id" => $user->v2ray_alter_id,
-                "level" => $user->v2ray_level,
+                "alter_id" => $server->alter_id,
+                "level" => 0,
             ];
             unset($user['uuid']);
-            unset($user['v2ray_alter_id']);
-            unset($user['v2ray_level']);
+            unset($user['email']);
             array_push($result, $user);
         }
         return response([

+ 1 - 2
app/Http/Controllers/Server/TrojanTidalabController.php

@@ -48,8 +48,7 @@ class TrojanTidalabController extends Controller
                 "password" => $user->uuid,
             ];
             unset($user['uuid']);
-            unset($user['v2ray_alter_id']);
-            unset($user['v2ray_level']);
+            unset($user['email']);
             array_push($result, $user);
         }
         return response([

+ 1 - 0
app/Http/Requests/Admin/ServerV2raySave.php

@@ -24,6 +24,7 @@ class ServerV2raySave extends FormRequest
             'tls' => 'required',
             'tags' => 'nullable|array',
             'rate' => 'required|numeric',
+            'alert_id' => 'required|integer',
             'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic',
             'networkSettings' => '',
             'ruleSettings' => '',

+ 1 - 3
app/Services/ServerService.php

@@ -121,9 +121,7 @@ class ServerService
                 'u',
                 'd',
                 'transfer_enable',
-                'uuid',
-                'v2ray_alter_id',
-                'v2ray_level'
+                'uuid'
             ])
             ->get();
     }

+ 2 - 3
database/install.sql

@@ -152,6 +152,7 @@ CREATE TABLE `v2_server` (
   `tags` varchar(255) DEFAULT NULL,
   `rate` varchar(11) NOT NULL,
   `network` text NOT NULL,
+  `alter_id` int(11) NOT NULL DEFAULT '1',
   `settings` text,
   `rules` text,
   `networkSettings` text,
@@ -296,8 +297,6 @@ CREATE TABLE `v2_user` (
   `last_login_at` int(11) DEFAULT NULL,
   `last_login_ip` int(11) DEFAULT NULL,
   `uuid` varchar(36) NOT NULL,
-  `v2ray_alter_id` tinyint(4) NOT NULL DEFAULT '2',
-  `v2ray_level` tinyint(4) NOT NULL DEFAULT '0',
   `group_id` int(11) DEFAULT NULL,
   `plan_id` int(11) DEFAULT NULL,
   `remind_expire` tinyint(4) DEFAULT '1',
@@ -311,4 +310,4 @@ CREATE TABLE `v2_user` (
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 
--- 2020-11-17 08:48:00
+-- 2020-11-17 10:46:49

+ 7 - 0
database/update.sql

@@ -345,3 +345,10 @@ ADD `coupon_id` int(11) NULL AFTER `plan_id`;
 
 ALTER TABLE `v2_server_stat`
 ADD `method` varchar(255) NOT NULL AFTER `server_id`;
+
+ALTER TABLE `v2_server`
+ADD `alter_id` int(11) NOT NULL DEFAULT '1' AFTER `network`;
+
+ALTER TABLE `v2_user`
+DROP `v2ray_alter_id`,
+DROP `v2ray_level`;