diff --git a/app/Http/Controllers/Admin/Server/GroupController.php b/app/Http/Controllers/Admin/Server/GroupController.php index 9e10e224..0d50077c 100644 --- a/app/Http/Controllers/Admin/Server/GroupController.php +++ b/app/Http/Controllers/Admin/Server/GroupController.php @@ -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, '该组已被节点所使用,无法删除'); diff --git a/app/Http/Controllers/Admin/Server/ManageController.php b/app/Http/Controllers/Admin/Server/ManageController.php index d9d1841c..7e2d622e 100644 --- a/app/Http/Controllers/Admin/Server/ManageController.php +++ b/app/Http/Controllers/Admin/Server/ManageController.php @@ -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, '保存失败'); } diff --git a/app/Http/Controllers/Admin/Server/V2rayController.php b/app/Http/Controllers/Admin/Server/VmessController.php similarity index 72% rename from app/Http/Controllers/Admin/Server/V2rayController.php rename to app/Http/Controllers/Admin/Server/VmessController.php index 3837e56b..f09565eb 100644 --- a/app/Http/Controllers/Admin/Server/V2rayController.php +++ b/app/Http/Controllers/Admin/Server/VmessController.php @@ -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, '复制失败'); } diff --git a/app/Http/Controllers/Admin/StatController.php b/app/Http/Controllers/Admin/StatController.php index 0449e2df..a76f906c 100644 --- a/app/Http/Controllers/Admin/StatController.php +++ b/app/Http/Controllers/Admin/StatController.php @@ -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')); diff --git a/app/Http/Controllers/Admin/SystemController.php b/app/Http/Controllers/Admin/SystemController.php index 2a5c7157..32f21323 100644 --- a/app/Http/Controllers/Admin/SystemController.php +++ b/app/Http/Controllers/Admin/SystemController.php @@ -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; diff --git a/app/Http/Controllers/Client/AppController.php b/app/Http/Controllers/Client/AppController.php index b193429b..1ad40d41 100644 --- a/app/Http/Controllers/Client/AppController.php +++ b/app/Http/Controllers/Client/AppController.php @@ -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']); } diff --git a/app/Http/Controllers/Client/Protocols/Clash.php b/app/Http/Controllers/Client/Protocols/Clash.php index e4396642..a131cfe0 100644 --- a/app/Http/Controllers/Client/Protocols/Clash.php +++ b/app/Http/Controllers/Client/Protocols/Clash.php @@ -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']); } diff --git a/app/Http/Controllers/Client/Protocols/ClashMeta.php b/app/Http/Controllers/Client/Protocols/ClashMeta.php index 673d50c3..e9e2ca7a 100644 --- a/app/Http/Controllers/Client/Protocols/ClashMeta.php +++ b/app/Http/Controllers/Client/Protocols/ClashMeta.php @@ -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']); } diff --git a/app/Http/Controllers/Client/Protocols/Passwall.php b/app/Http/Controllers/Client/Protocols/Passwall.php index 4b191adf..25a42dd1 100644 --- a/app/Http/Controllers/Client/Protocols/Passwall.php +++ b/app/Http/Controllers/Client/Protocols/Passwall.php @@ -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') { diff --git a/app/Http/Controllers/Client/Protocols/QuantumultX.php b/app/Http/Controllers/Client/Protocols/QuantumultX.php index a4dfa41b..61bab749 100644 --- a/app/Http/Controllers/Client/Protocols/QuantumultX.php +++ b/app/Http/Controllers/Client/Protocols/QuantumultX.php @@ -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') { diff --git a/app/Http/Controllers/Client/Protocols/SSRPlus.php b/app/Http/Controllers/Client/Protocols/SSRPlus.php index bf5ab830..fd88a750 100644 --- a/app/Http/Controllers/Client/Protocols/SSRPlus.php +++ b/app/Http/Controllers/Client/Protocols/SSRPlus.php @@ -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') { diff --git a/app/Http/Controllers/Client/Protocols/SagerNet.php b/app/Http/Controllers/Client/Protocols/SagerNet.php index 87ac1681..1a6aa819 100644 --- a/app/Http/Controllers/Client/Protocols/SagerNet.php +++ b/app/Http/Controllers/Client/Protocols/SagerNet.php @@ -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') { diff --git a/app/Http/Controllers/Client/Protocols/Shadowrocket.php b/app/Http/Controllers/Client/Protocols/Shadowrocket.php index 12d9e455..edbfd62a 100644 --- a/app/Http/Controllers/Client/Protocols/Shadowrocket.php +++ b/app/Http/Controllers/Client/Protocols/Shadowrocket.php @@ -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') { diff --git a/app/Http/Controllers/Client/Protocols/Stash.php b/app/Http/Controllers/Client/Protocols/Stash.php index ca659911..2ac494b8 100644 --- a/app/Http/Controllers/Client/Protocols/Stash.php +++ b/app/Http/Controllers/Client/Protocols/Stash.php @@ -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']); } diff --git a/app/Http/Controllers/Client/Protocols/Surfboard.php b/app/Http/Controllers/Client/Protocols/Surfboard.php index 4a2c17bb..cdaf7b88 100644 --- a/app/Http/Controllers/Client/Protocols/Surfboard.php +++ b/app/Http/Controllers/Client/Protocols/Surfboard.php @@ -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] diff --git a/app/Http/Controllers/Client/Protocols/Surge.php b/app/Http/Controllers/Client/Protocols/Surge.php index edb49dda..ca7cd1b3 100644 --- a/app/Http/Controllers/Client/Protocols/Surge.php +++ b/app/Http/Controllers/Client/Protocols/Surge.php @@ -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] diff --git a/app/Http/Controllers/Client/Protocols/V2rayN.php b/app/Http/Controllers/Client/Protocols/V2rayN.php index a7648706..d5e1c00b 100644 --- a/app/Http/Controllers/Client/Protocols/V2rayN.php +++ b/app/Http/Controllers/Client/Protocols/V2rayN.php @@ -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') { diff --git a/app/Http/Controllers/Client/Protocols/V2rayNG.php b/app/Http/Controllers/Client/Protocols/V2rayNG.php index c7ab6bfd..0be4005f 100644 --- a/app/Http/Controllers/Client/Protocols/V2rayNG.php +++ b/app/Http/Controllers/Client/Protocols/V2rayNG.php @@ -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') { diff --git a/app/Http/Controllers/Server/DeepbworkController.php b/app/Http/Controllers/Server/DeepbworkController.php index 30c2874f..5db797e7 100644 --- a/app/Http/Controllers/Server/DeepbworkController.php +++ b/app/Http/Controllers/Server/DeepbworkController.php @@ -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; diff --git a/app/Http/Controllers/Server/UniProxyController.php b/app/Http/Controllers/Server/UniProxyController.php index edc5c50a..75d95b3b 100644 --- a/app/Http/Controllers/Server/UniProxyController.php +++ b/app/Http/Controllers/Server/UniProxyController.php @@ -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, diff --git a/app/Http/Controllers/User/ServerController.php b/app/Http/Controllers/User/ServerController.php index 2ad3d322..49313835 100644 --- a/app/Http/Controllers/User/ServerController.php +++ b/app/Http/Controllers/User/ServerController.php @@ -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; diff --git a/app/Http/Requests/Admin/ServerV2raySave.php b/app/Http/Requests/Admin/ServerVmessSave.php similarity index 98% rename from app/Http/Requests/Admin/ServerV2raySave.php rename to app/Http/Requests/Admin/ServerVmessSave.php index 3ef6327a..3f053783 100755 --- a/app/Http/Requests/Admin/ServerV2raySave.php +++ b/app/Http/Requests/Admin/ServerVmessSave.php @@ -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. diff --git a/app/Http/Requests/Admin/ServerV2rayUpdate.php b/app/Http/Requests/Admin/ServerVmessUpdate.php similarity index 90% rename from app/Http/Requests/Admin/ServerV2rayUpdate.php rename to app/Http/Requests/Admin/ServerVmessUpdate.php index 7650cec5..607d74d5 100755 --- a/app/Http/Requests/Admin/ServerV2rayUpdate.php +++ b/app/Http/Requests/Admin/ServerVmessUpdate.php @@ -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. diff --git a/app/Http/Routes/AdminRoute.php b/app/Http/Routes/AdminRoute.php index ab3ec7e4..7f6bbbe1 100644 --- a/app/Http/Routes/AdminRoute.php +++ b/app/Http/Routes/AdminRoute.php @@ -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' diff --git a/app/Models/ServerV2ray.php b/app/Models/ServerVmess.php similarity index 94% rename from app/Models/ServerV2ray.php rename to app/Models/ServerVmess.php index 08ef0424..76dcccb2 100755 --- a/app/Models/ServerV2ray.php +++ b/app/Models/ServerVmess.php @@ -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'; diff --git a/app/Services/ServerService.php b/app/Services/ServerService.php index 60d6c310..5aa1ba1c 100644 --- a/app/Services/ServerService.php +++ b/app/Services/ServerService.php @@ -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': diff --git a/app/Utils/CacheKey.php b/app/Utils/CacheKey.php index c7a775c9..afb37410 100644 --- a/app/Utils/CacheKey.php +++ b/app/Utils/CacheKey.php @@ -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节点最后推送时间', diff --git a/app/Utils/Helper.php b/app/Utils/Helper.php index f3e79b0c..960058ab 100644 --- a/app/Utils/Helper.php +++ b/app/Utils/Helper.php @@ -30,7 +30,7 @@ class Helper public static function generateOrderNo(): string { - $randomChar = rand(10000, 99999); + $randomChar = mt_rand(10000, 99999); return date('YmdHms') . $randomChar; } diff --git a/database/install.sql b/database/install.sql index 5f103d48..0192b067 100644 --- a/database/install.sql +++ b/database/install.sql @@ -134,7 +134,8 @@ CREATE TABLE `v2_order` ( `paid_at` int(11) DEFAULT NULL, `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + UNIQUE KEY `trade_no` (`trade_no`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -163,11 +164,11 @@ CREATE TABLE `v2_plan` ( `group_id` int(11) NOT NULL, `transfer_enable` int(11) NOT NULL, `speed_limit` int(11) DEFAULT NULL, - `name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, + `name` varchar(255) NOT NULL, `show` tinyint(1) NOT NULL DEFAULT '0', `sort` int(11) DEFAULT NULL, `renew` tinyint(1) NOT NULL DEFAULT '1', - `content` text CHARACTER SET utf8mb4, + `content` text, `month_price` int(11) DEFAULT NULL, `quarter_price` int(11) DEFAULT NULL, `half_year_price` int(11) DEFAULT NULL, @@ -181,7 +182,7 @@ CREATE TABLE `v2_plan` ( `created_at` int(11) NOT NULL, `updated_at` int(11) NOT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; DROP TABLE IF EXISTS `v2_server_group`; @@ -397,4 +398,4 @@ CREATE TABLE `v2_user` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- 2022-12-15 05:24:08 +-- 2023-02-15 06:46:53 diff --git a/database/update.sql b/database/update.sql index 9f3b57cc..b09b8534 100644 --- a/database/update.sql +++ b/database/update.sql @@ -642,3 +642,12 @@ CREATE TABLE `v2_server_route` ( ALTER TABLE `v2_server_route` CHANGE `match` `match` text COLLATE 'utf8mb4_general_ci' NOT NULL AFTER `remarks`; + +ALTER TABLE `v2_order` + ADD UNIQUE `trade_no` (`trade_no`); + +ALTER TABLE `v2_plan` + CHANGE `content` `content` text COLLATE 'utf8mb4_general_ci' NULL AFTER `renew`; + +ALTER TABLE `v2_plan` + COLLATE 'utf8mb4_general_ci';