mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 01:11:46 +08:00 
			
		
		
		
	update: v2ray char to vmess
This commit is contained in:
		| @@ -5,7 +5,7 @@ namespace App\Http\Controllers\Admin\Server; | ||||
| use App\Models\Plan; | ||||
| use App\Models\ServerShadowsocks; | ||||
| use App\Models\ServerTrojan; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\ServerGroup; | ||||
| use App\Models\User; | ||||
| use App\Services\ServerService; | ||||
| @@ -65,7 +65,7 @@ class GroupController extends Controller | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         $servers = ServerV2ray::all(); | ||||
|         $servers = ServerVmess::all(); | ||||
|         foreach ($servers as $server) { | ||||
|             if (in_array($request->input('id'), $server->group_id)) { | ||||
|                 abort(500, '该组已被节点所使用,无法删除'); | ||||
|   | ||||
| @@ -2,7 +2,7 @@ | ||||
|  | ||||
| namespace App\Http\Controllers\Admin\Server; | ||||
|  | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\ServerShadowsocks; | ||||
| use App\Models\ServerTrojan; | ||||
| use App\Services\ServerService; | ||||
| @@ -32,8 +32,8 @@ class ManageController extends Controller | ||||
|                         abort(500, '保存失败'); | ||||
|                     } | ||||
|                     break; | ||||
|                 case 'v2ray': | ||||
|                     if (!ServerV2ray::find($v['value'])->update(['sort' => $v['sort']])) { | ||||
|                 case 'vmess': | ||||
|                     if (!ServerVmess::find($v['value'])->update(['sort' => $v['sort']])) { | ||||
|                         DB::rollBack(); | ||||
|                         abort(500, '保存失败'); | ||||
|                     } | ||||
|   | ||||
| @@ -2,21 +2,21 @@ | ||||
| 
 | ||||
| namespace App\Http\Controllers\Admin\Server; | ||||
| 
 | ||||
| use App\Http\Requests\Admin\ServerV2raySave; | ||||
| use App\Http\Requests\Admin\ServerV2rayUpdate; | ||||
| use App\Http\Requests\Admin\ServerVmessSave; | ||||
| use App\Http\Requests\Admin\ServerVmessUpdate; | ||||
| use App\Services\ServerService; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| 
 | ||||
| class V2rayController extends Controller | ||||
| class VmessController extends Controller | ||||
| { | ||||
|     public function save(ServerV2raySave $request) | ||||
|     public function save(ServerVmessSave $request) | ||||
|     { | ||||
|         $params = $request->validated(); | ||||
| 
 | ||||
|         if ($request->input('id')) { | ||||
|             $server = ServerV2ray::find($request->input('id')); | ||||
|             $server = ServerVmess::find($request->input('id')); | ||||
|             if (!$server) { | ||||
|                 abort(500, '服务器不存在'); | ||||
|             } | ||||
| @@ -30,7 +30,7 @@ class V2rayController extends Controller | ||||
|             ]); | ||||
|         } | ||||
| 
 | ||||
|         if (!ServerV2ray::create($params)) { | ||||
|         if (!ServerVmess::create($params)) { | ||||
|             abort(500, '创建失败'); | ||||
|         } | ||||
| 
 | ||||
| @@ -42,7 +42,7 @@ class V2rayController extends Controller | ||||
|     public function drop(Request $request) | ||||
|     { | ||||
|         if ($request->input('id')) { | ||||
|             $server = ServerV2ray::find($request->input('id')); | ||||
|             $server = ServerVmess::find($request->input('id')); | ||||
|             if (!$server) { | ||||
|                 abort(500, '节点ID不存在'); | ||||
|             } | ||||
| @@ -52,13 +52,13 @@ class V2rayController extends Controller | ||||
|         ]); | ||||
|     } | ||||
| 
 | ||||
|     public function update(ServerV2rayUpdate $request) | ||||
|     public function update(ServerVmessUpdate $request) | ||||
|     { | ||||
|         $params = $request->only([ | ||||
|             'show', | ||||
|         ]); | ||||
| 
 | ||||
|         $server = ServerV2ray::find($request->input('id')); | ||||
|         $server = ServerVmess::find($request->input('id')); | ||||
| 
 | ||||
|         if (!$server) { | ||||
|             abort(500, '该服务器不存在'); | ||||
| @@ -76,12 +76,12 @@ class V2rayController extends Controller | ||||
| 
 | ||||
|     public function copy(Request $request) | ||||
|     { | ||||
|         $server = ServerV2ray::find($request->input('id')); | ||||
|         $server = ServerVmess::find($request->input('id')); | ||||
|         $server->show = 0; | ||||
|         if (!$server) { | ||||
|             abort(500, '服务器不存在'); | ||||
|         } | ||||
|         if (!ServerV2ray::create($server->toArray())) { | ||||
|         if (!ServerVmess::create($server->toArray())) { | ||||
|             abort(500, '复制失败'); | ||||
|         } | ||||
| 
 | ||||
| @@ -10,7 +10,7 @@ use App\Services\ServerService; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Models\ServerGroup; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\Plan; | ||||
| use App\Models\User; | ||||
| use App\Models\Ticket; | ||||
| @@ -99,8 +99,9 @@ class StatController extends Controller | ||||
|     { | ||||
|         $servers = [ | ||||
|             'shadowsocks' => ServerShadowsocks::where('parent_id', null)->get()->toArray(), | ||||
|             'v2ray' => ServerV2ray::where('parent_id', null)->get()->toArray(), | ||||
|             'trojan' => ServerTrojan::where('parent_id', null)->get()->toArray() | ||||
|             'v2ray' => ServerVmess::where('parent_id', null)->get()->toArray(), | ||||
|             'trojan' => ServerTrojan::where('parent_id', null)->get()->toArray(), | ||||
|             'vmess' => ServerVmess::where('parent_id', null)->get()->toArray() | ||||
|         ]; | ||||
|         $startAt = strtotime('-1 day', strtotime(date('Y-m-d'))); | ||||
|         $endAt = strtotime(date('Y-m-d')); | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use App\Utils\CacheKey; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Models\ServerGroup; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\Plan; | ||||
| use App\Models\User; | ||||
| use App\Models\Ticket; | ||||
|   | ||||
| @@ -42,7 +42,7 @@ class AppController extends Controller | ||||
|                 array_push($proxy, Protocols\Clash::buildShadowsocks($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 array_push($proxy, Protocols\Clash::buildVmess($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|   | ||||
| @@ -49,7 +49,7 @@ class Clash | ||||
|                 array_push($proxy, self::buildShadowsocks($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 array_push($proxy, self::buildVmess($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|   | ||||
| @@ -40,7 +40,7 @@ class ClashMeta | ||||
|                 array_push($proxy, self::buildShadowsocks($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 array_push($proxy, self::buildVmess($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|   | ||||
| @@ -22,7 +22,7 @@ class Passwall | ||||
|         $uri = ''; | ||||
|  | ||||
|         foreach ($servers as $item) { | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|   | ||||
| @@ -25,7 +25,7 @@ class QuantumultX | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|                 $uri .= self::buildShadowsocks($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'trojan') { | ||||
|   | ||||
| @@ -22,7 +22,7 @@ class SSRPlus | ||||
|         $uri = ''; | ||||
|  | ||||
|         foreach ($servers as $item) { | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|   | ||||
| @@ -21,7 +21,7 @@ class SagerNet | ||||
|         $uri = ''; | ||||
|  | ||||
|         foreach ($servers as $item) { | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|   | ||||
| @@ -32,7 +32,7 @@ class Shadowrocket | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|                 $uri .= self::buildShadowsocks($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'trojan') { | ||||
|   | ||||
| @@ -47,7 +47,7 @@ class Stash | ||||
|                 array_push($proxy, self::buildShadowsocks($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 array_push($proxy, self::buildVmess($user['uuid'], $item)); | ||||
|                 array_push($proxies, $item['name']); | ||||
|             } | ||||
|   | ||||
| @@ -41,7 +41,7 @@ class Surfboard | ||||
|                 // [Proxy Group] | ||||
|                 $proxyGroup .= $item['name'] . ', '; | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 // [Proxy] | ||||
|                 $proxies .= self::buildVmess($user['uuid'], $item); | ||||
|                 // [Proxy Group] | ||||
|   | ||||
| @@ -41,7 +41,7 @@ class Surge | ||||
|                 // [Proxy Group] | ||||
|                 $proxyGroup .= $item['name'] . ', '; | ||||
|             } | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 // [Proxy] | ||||
|                 $proxies .= self::buildVmess($user['uuid'], $item); | ||||
|                 // [Proxy Group] | ||||
|   | ||||
| @@ -24,7 +24,7 @@ class V2rayN | ||||
|         $uri = ''; | ||||
|  | ||||
|         foreach ($servers as $item) { | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|   | ||||
| @@ -22,7 +22,7 @@ class V2rayNG | ||||
|         $uri = ''; | ||||
|  | ||||
|         foreach ($servers as $item) { | ||||
|             if ($item['type'] === 'v2ray') { | ||||
|             if ($item['type'] === 'vmess') { | ||||
|                 $uri .= self::buildVmess($user['uuid'], $item); | ||||
|             } | ||||
|             if ($item['type'] === 'shadowsocks') { | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use App\Utils\CacheKey; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Models\User; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\ServerLog; | ||||
| use Illuminate\Support\Facades\DB; | ||||
| use Illuminate\Support\Facades\Log; | ||||
| @@ -37,11 +37,11 @@ class DeepbworkController extends Controller | ||||
|     { | ||||
|         ini_set('memory_limit', -1); | ||||
|         $nodeId = $request->input('node_id'); | ||||
|         $server = ServerV2ray::find($nodeId); | ||||
|         $server = ServerVmess::find($nodeId); | ||||
|         if (!$server) { | ||||
|             abort(500, 'fail'); | ||||
|         } | ||||
|         Cache::put(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $server->id), time(), 3600); | ||||
|         Cache::put(CacheKey::get('SERVER_VMESS_LAST_CHECK_AT', $server->id), time(), 3600); | ||||
|         $serverService = new ServerService(); | ||||
|         $users = $serverService->getAvailableUsers($server->group_id); | ||||
|         $result = []; | ||||
| @@ -69,7 +69,7 @@ class DeepbworkController extends Controller | ||||
|     public function submit(Request $request) | ||||
|     { | ||||
| //         Log::info('serverSubmitData:' . $request->input('node_id') . ':' . file_get_contents('php://input')); | ||||
|         $server = ServerV2ray::find($request->input('node_id')); | ||||
|         $server = ServerVmess::find($request->input('node_id')); | ||||
|         if (!$server) { | ||||
|             return response([ | ||||
|                 'ret' => 0, | ||||
| @@ -78,13 +78,13 @@ class DeepbworkController extends Controller | ||||
|         } | ||||
|         $data = file_get_contents('php://input'); | ||||
|         $data = json_decode($data, true); | ||||
|         Cache::put(CacheKey::get('SERVER_V2RAY_ONLINE_USER', $server->id), count($data), 3600); | ||||
|         Cache::put(CacheKey::get('SERVER_V2RAY_LAST_PUSH_AT', $server->id), time(), 3600); | ||||
|         Cache::put(CacheKey::get('SERVER_VMESS_ONLINE_USER', $server->id), count($data), 3600); | ||||
|         Cache::put(CacheKey::get('SERVER_VMESS_LAST_PUSH_AT', $server->id), time(), 3600); | ||||
|         $userService = new UserService(); | ||||
|         foreach ($data as $item) { | ||||
|             $u = $item['u']; | ||||
|             $d = $item['d']; | ||||
|             $userService->trafficFetch($u, $d, $item['user_id'], $server->toArray(), 'v2ray'); | ||||
|             $userService->trafficFetch($u, $d, $item['user_id'], $server->toArray(), 'vmess'); | ||||
|         } | ||||
|  | ||||
|         return response([ | ||||
| @@ -112,7 +112,7 @@ class DeepbworkController extends Controller | ||||
|  | ||||
|     private function getV2RayConfig(int $nodeId, int $localPort) | ||||
|     { | ||||
|         $server = ServerV2ray::find($nodeId); | ||||
|         $server = ServerVmess::find($nodeId); | ||||
|         if (!$server) { | ||||
|             abort(500, '节点不存在'); | ||||
|         } | ||||
| @@ -129,7 +129,7 @@ class DeepbworkController extends Controller | ||||
|         return $json; | ||||
|     } | ||||
|  | ||||
|     private function setDns(ServerV2ray $server, object $json) | ||||
|     private function setDns(ServerVmess $server, object $json) | ||||
|     { | ||||
|         if ($server->dnsSettings) { | ||||
|             $dns = $server->dnsSettings; | ||||
| @@ -142,7 +142,7 @@ class DeepbworkController extends Controller | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function setNetwork(ServerV2ray $server, object $json) | ||||
|     private function setNetwork(ServerVmess $server, object $json) | ||||
|     { | ||||
|         if ($server->networkSettings) { | ||||
|             switch ($server->network) { | ||||
| @@ -171,7 +171,7 @@ class DeepbworkController extends Controller | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function setRule(ServerV2ray $server, object $json) | ||||
|     private function setRule(ServerVmess $server, object $json) | ||||
|     { | ||||
|         $domainRules = array_filter(explode(PHP_EOL, config('v2board.server_v2ray_domain'))); | ||||
|         $protocolRules = array_filter(explode(PHP_EOL, config('v2board.server_v2ray_protocol'))); | ||||
| @@ -211,7 +211,7 @@ class DeepbworkController extends Controller | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function setTls(ServerV2ray $server, object $json) | ||||
|     private function setTls(ServerVMess $server, object $json) | ||||
|     { | ||||
|         if ((int)$server->tls) { | ||||
|             $tlsSettings = $server->tlsSettings; | ||||
|   | ||||
| @@ -9,7 +9,7 @@ use App\Utils\Helper; | ||||
| use Illuminate\Http\Request; | ||||
| use App\Http\Controllers\Controller; | ||||
| use App\Models\ServerShadowsocks; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\ServerTrojan; | ||||
| use Illuminate\Support\Facades\Cache; | ||||
|  | ||||
| @@ -30,6 +30,7 @@ class UniProxyController extends Controller | ||||
|             abort(500, 'token is error'); | ||||
|         } | ||||
|         $this->nodeType = $request->input('node_type'); | ||||
|         if ($this->nodeType === 'v2ray') $this->nodeType = 'vmess'; | ||||
|         $this->nodeId = $request->input('node_id'); | ||||
|         $this->serverService = new ServerService(); | ||||
|         $this->nodeInfo = $this->serverService->getServer($this->nodeId, $this->nodeType); | ||||
| @@ -92,7 +93,7 @@ class UniProxyController extends Controller | ||||
|                     $response['server_key'] = Helper::getShadowsocksServerKey($this->nodeInfo->created_at, 32); | ||||
|                 } | ||||
|                 break; | ||||
|             case 'v2ray': | ||||
|             case 'vmess': | ||||
|                 $response = [ | ||||
|                     'server_port' => $this->nodeInfo->server_port, | ||||
|                     'network' => $this->nodeInfo->network, | ||||
|   | ||||
| @@ -8,7 +8,7 @@ use App\Services\UserService; | ||||
| use App\Utils\CacheKey; | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Support\Facades\Cache; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\ServerLog; | ||||
| use App\Models\User; | ||||
|  | ||||
|   | ||||
| @@ -4,7 +4,7 @@ namespace App\Http\Requests\Admin; | ||||
| 
 | ||||
| use Illuminate\Foundation\Http\FormRequest; | ||||
| 
 | ||||
| class ServerV2raySave extends FormRequest | ||||
| class ServerVmessSave extends FormRequest | ||||
| { | ||||
|     /** | ||||
|      * Get the validation rules that apply to the request. | ||||
| @@ -4,7 +4,7 @@ namespace App\Http\Requests\Admin; | ||||
| 
 | ||||
| use Illuminate\Foundation\Http\FormRequest; | ||||
| 
 | ||||
| class ServerV2rayUpdate extends FormRequest | ||||
| class ServerVmessUpdate extends FormRequest | ||||
| { | ||||
|     /** | ||||
|      * Get the validation rules that apply to the request. | ||||
| @@ -45,14 +45,14 @@ class AdminRoute | ||||
|                 $router->post('viewConfig', 'Admin\\Server\\TrojanController@viewConfig'); | ||||
|             }); | ||||
|             $router->group([ | ||||
|                 'prefix' => 'server/v2ray' | ||||
|                 'prefix' => 'server/vmess' | ||||
|             ], function ($router) { | ||||
|                 $router->get ('fetch', 'Admin\\Server\\V2rayController@fetch'); | ||||
|                 $router->post('save', 'Admin\\Server\\V2rayController@save'); | ||||
|                 $router->post('drop', 'Admin\\Server\\V2rayController@drop'); | ||||
|                 $router->post('update', 'Admin\\Server\\V2rayController@update'); | ||||
|                 $router->post('copy', 'Admin\\Server\\V2rayController@copy'); | ||||
|                 $router->post('sort', 'Admin\\Server\\V2rayController@sort'); | ||||
|                 $router->get ('fetch', 'Admin\\Server\\VmessController@fetch'); | ||||
|                 $router->post('save', 'Admin\\Server\\VmessController@save'); | ||||
|                 $router->post('drop', 'Admin\\Server\\VmessController@drop'); | ||||
|                 $router->post('update', 'Admin\\Server\\VmessController@update'); | ||||
|                 $router->post('copy', 'Admin\\Server\\VmessController@copy'); | ||||
|                 $router->post('sort', 'Admin\\Server\\VmessController@sort'); | ||||
|             }); | ||||
|             $router->group([ | ||||
|                 'prefix' => 'server/shadowsocks' | ||||
|   | ||||
| @@ -4,7 +4,7 @@ namespace App\Models; | ||||
| 
 | ||||
| use Illuminate\Database\Eloquent\Model; | ||||
| 
 | ||||
| class ServerV2ray extends Model | ||||
| class ServerVmess extends Model | ||||
| { | ||||
|     protected $table = 'v2_server_v2ray'; | ||||
|     protected $dateFormat = 'U'; | ||||
| @@ -6,7 +6,7 @@ use App\Models\ServerLog; | ||||
| use App\Models\ServerRoute; | ||||
| use App\Models\ServerShadowsocks; | ||||
| use App\Models\User; | ||||
| use App\Models\ServerV2ray; | ||||
| use App\Models\ServerVmess; | ||||
| use App\Models\ServerTrojan; | ||||
| use App\Utils\CacheKey; | ||||
| use App\Utils\Helper; | ||||
| @@ -15,24 +15,24 @@ use Illuminate\Support\Facades\Cache; | ||||
| class ServerService | ||||
| { | ||||
|  | ||||
|     public function getAvailableV2ray(User $user):array | ||||
|     public function getAvailableVmess(User $user):array | ||||
|     { | ||||
|         $servers = []; | ||||
|         $model = ServerV2ray::orderBy('sort', 'ASC'); | ||||
|         $v2ray = $model->get(); | ||||
|         foreach ($v2ray as $key => $v) { | ||||
|         $model = ServerVmess::orderBy('sort', 'ASC'); | ||||
|         $vmess = $model->get(); | ||||
|         foreach ($vmess as $key => $v) { | ||||
|             if (!$v['show']) continue; | ||||
|             $v2ray[$key]['type'] = 'v2ray'; | ||||
|             if (!in_array($user->group_id, $v2ray[$key]['group_id'])) continue; | ||||
|             if (strpos($v2ray[$key]['port'], '-') !== false) { | ||||
|                 $v2ray[$key]['port'] = Helper::randomPort($v2ray[$key]['port']); | ||||
|             $vmess[$key]['type'] = 'vmess'; | ||||
|             if (!in_array($user->group_id, $vmess[$key]['group_id'])) continue; | ||||
|             if (strpos($vmess[$key]['port'], '-') !== false) { | ||||
|                 $vmess[$key]['port'] = Helper::randomPort($vmess[$key]['port']); | ||||
|             } | ||||
|             if ($v2ray[$key]['parent_id']) { | ||||
|                 $v2ray[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$key]['parent_id'])); | ||||
|             if ($vmess[$key]['parent_id']) { | ||||
|                 $vmess[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_VMESS_LAST_CHECK_AT', $vmess[$key]['parent_id'])); | ||||
|             } else { | ||||
|                 $v2ray[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_V2RAY_LAST_CHECK_AT', $v2ray[$key]['id'])); | ||||
|                 $vmess[$key]['last_check_at'] = Cache::get(CacheKey::get('SERVER_VMESS_LAST_CHECK_AT', $vmess[$key]['id'])); | ||||
|             } | ||||
|             $servers[] = $v2ray[$key]->toArray(); | ||||
|             $servers[] = $vmess[$key]->toArray(); | ||||
|         } | ||||
|  | ||||
|  | ||||
| @@ -87,7 +87,7 @@ class ServerService | ||||
|     { | ||||
|         $servers = array_merge( | ||||
|             $this->getAvailableShadowsocks($user), | ||||
|             $this->getAvailableV2ray($user), | ||||
|             $this->getAvailableVmess($user), | ||||
|             $this->getAvailableTrojan($user) | ||||
|         ); | ||||
|         $tmp = array_column($servers, 'sort'); | ||||
| @@ -160,13 +160,13 @@ class ServerService | ||||
|         return $servers; | ||||
|     } | ||||
|  | ||||
|     public function getAllV2ray() | ||||
|     public function getAllVMess() | ||||
|     { | ||||
|         $servers = ServerV2ray::orderBy('sort', 'ASC') | ||||
|         $servers = ServerVmess::orderBy('sort', 'ASC') | ||||
|             ->get() | ||||
|             ->toArray(); | ||||
|         foreach ($servers as $k => $v) { | ||||
|             $servers[$k]['type'] = 'v2ray'; | ||||
|             $servers[$k]['type'] = 'vmess'; | ||||
|         } | ||||
|         return $servers; | ||||
|     } | ||||
| @@ -203,7 +203,7 @@ class ServerService | ||||
|     { | ||||
|         $servers = array_merge( | ||||
|             $this->getAllShadowsocks(), | ||||
|             $this->getAllV2ray(), | ||||
|             $this->getAllVMess(), | ||||
|             $this->getAllTrojan() | ||||
|         ); | ||||
|         $this->mergeData($servers); | ||||
| @@ -227,8 +227,8 @@ class ServerService | ||||
|     public function getServer($serverId, $serverType) | ||||
|     { | ||||
|         switch ($serverType) { | ||||
|             case 'v2ray': | ||||
|                 return ServerV2ray::find($serverId); | ||||
|             case 'vmess': | ||||
|                 return ServerVmess::find($serverId); | ||||
|             case 'shadowsocks': | ||||
|                 return ServerShadowsocks::find($serverId); | ||||
|             case 'trojan': | ||||
|   | ||||
| @@ -7,9 +7,9 @@ class CacheKey | ||||
|     CONST KEYS = [ | ||||
|         'EMAIL_VERIFY_CODE' => '邮箱验证码', | ||||
|         'LAST_SEND_EMAIL_VERIFY_TIMESTAMP' => '最后一次发送邮箱验证码时间', | ||||
|         'SERVER_V2RAY_ONLINE_USER' => '节点在线用户', | ||||
|         'SERVER_V2RAY_LAST_CHECK_AT' => '节点最后检查时间', | ||||
|         'SERVER_V2RAY_LAST_PUSH_AT' => '节点最后推送时间', | ||||
|         'SERVER_VMESS_ONLINE_USER' => '节点在线用户', | ||||
|         'SERVER_VMESS_LAST_CHECK_AT' => '节点最后检查时间', | ||||
|         'SERVER_VMESS_LAST_PUSH_AT' => '节点最后推送时间', | ||||
|         'SERVER_TROJAN_ONLINE_USER' => 'trojan节点在线用户', | ||||
|         'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间', | ||||
|         'SERVER_TROJAN_LAST_PUSH_AT' => 'trojan节点最后推送时间', | ||||
|   | ||||
| @@ -30,7 +30,7 @@ class Helper | ||||
|  | ||||
|     public static function generateOrderNo(): string | ||||
|     { | ||||
|         $randomChar = rand(10000, 99999); | ||||
|         $randomChar = mt_rand(10000, 99999); | ||||
|         return date('YmdHms') . $randomChar; | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user