mirror of
https://github.com/v2board/v2board.git
synced 2025-01-11 00:29:09 +08:00
add: server name check
This commit is contained in:
parent
11b6c8448a
commit
58a63ae819
@ -2,13 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Admin\Server;
|
namespace App\Http\Controllers\Admin\Server;
|
||||||
|
|
||||||
use App\Http\Requests\Admin\ServerTrojanSort;
|
|
||||||
use App\Models\Plan;
|
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use App\Models\ServerGroup;
|
|
||||||
use App\Models\ServerShadowsocks;
|
use App\Models\ServerShadowsocks;
|
||||||
use App\Models\ServerTrojan;
|
use App\Models\ServerTrojan;
|
||||||
use App\Models\User;
|
|
||||||
use App\Services\ServerService;
|
use App\Services\ServerService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
@ -3,21 +3,19 @@
|
|||||||
namespace App\Http\Controllers\Admin\Server;
|
namespace App\Http\Controllers\Admin\Server;
|
||||||
|
|
||||||
use App\Http\Requests\Admin\ServerShadowsocksSave;
|
use App\Http\Requests\Admin\ServerShadowsocksSave;
|
||||||
use App\Http\Requests\Admin\ServerShadowsocksSort;
|
|
||||||
use App\Http\Requests\Admin\ServerShadowsocksUpdate;
|
use App\Http\Requests\Admin\ServerShadowsocksUpdate;
|
||||||
use App\Models\ServerShadowsocks;
|
use App\Models\ServerShadowsocks;
|
||||||
use App\Utils\CacheKey;
|
use App\Services\ServerService;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Server;
|
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class ShadowsocksController extends Controller
|
class ShadowsocksController extends Controller
|
||||||
{
|
{
|
||||||
public function save(ServerShadowsocksSave $request)
|
public function save(ServerShadowsocksSave $request)
|
||||||
{
|
{
|
||||||
$params = $request->validated();
|
$params = $request->validated();
|
||||||
|
$serverService = new ServerService();
|
||||||
|
if ($serverService->serverIsExist($params['name'])) abort(500, '节点名称已存在,请更换名称再试');
|
||||||
$params['group_id'] = json_encode($params['group_id']);
|
$params['group_id'] = json_encode($params['group_id']);
|
||||||
if (isset($params['tags'])) {
|
if (isset($params['tags'])) {
|
||||||
$params['tags'] = json_encode($params['tags']);
|
$params['tags'] = json_encode($params['tags']);
|
||||||
|
@ -3,21 +3,19 @@
|
|||||||
namespace App\Http\Controllers\Admin\Server;
|
namespace App\Http\Controllers\Admin\Server;
|
||||||
|
|
||||||
use App\Http\Requests\Admin\ServerTrojanSave;
|
use App\Http\Requests\Admin\ServerTrojanSave;
|
||||||
use App\Http\Requests\Admin\ServerTrojanSort;
|
|
||||||
use App\Http\Requests\Admin\ServerTrojanUpdate;
|
use App\Http\Requests\Admin\ServerTrojanUpdate;
|
||||||
use App\Services\ServerService;
|
use App\Services\ServerService;
|
||||||
use App\Utils\CacheKey;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\ServerTrojan;
|
use App\Models\ServerTrojan;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class TrojanController extends Controller
|
class TrojanController extends Controller
|
||||||
{
|
{
|
||||||
public function save(ServerTrojanSave $request)
|
public function save(ServerTrojanSave $request)
|
||||||
{
|
{
|
||||||
$params = $request->validated();
|
$params = $request->validated();
|
||||||
|
$serverService = new ServerService();
|
||||||
|
if ($serverService->serverIsExist($params['name'])) abort(500, '节点名称已存在,请更换名称再试');
|
||||||
$params['group_id'] = json_encode($params['group_id']);
|
$params['group_id'] = json_encode($params['group_id']);
|
||||||
if (isset($params['tags'])) {
|
if (isset($params['tags'])) {
|
||||||
$params['tags'] = json_encode($params['tags']);
|
$params['tags'] = json_encode($params['tags']);
|
||||||
|
@ -3,21 +3,20 @@
|
|||||||
namespace App\Http\Controllers\Admin\Server;
|
namespace App\Http\Controllers\Admin\Server;
|
||||||
|
|
||||||
use App\Http\Requests\Admin\ServerV2raySave;
|
use App\Http\Requests\Admin\ServerV2raySave;
|
||||||
use App\Http\Requests\Admin\ServerV2raySort;
|
|
||||||
use App\Http\Requests\Admin\ServerV2rayUpdate;
|
use App\Http\Requests\Admin\ServerV2rayUpdate;
|
||||||
use App\Services\ServerService;
|
use App\Services\ServerService;
|
||||||
use App\Utils\CacheKey;
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Illuminate\Support\Facades\Cache;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
|
|
||||||
class V2rayController extends Controller
|
class V2rayController extends Controller
|
||||||
{
|
{
|
||||||
public function save(ServerV2raySave $request)
|
public function save(ServerV2raySave $request)
|
||||||
{
|
{
|
||||||
$params = $request->validated();
|
$params = $request->validated();
|
||||||
|
$serverService = new ServerService();
|
||||||
|
if ($serverService->serverIsExist($params['name'])) abort(500, '节点名称已存在,请更换名称再试');
|
||||||
|
|
||||||
$params['group_id'] = json_encode($params['group_id']);
|
$params['group_id'] = json_encode($params['group_id']);
|
||||||
if (isset($params['tags'])) {
|
if (isset($params['tags'])) {
|
||||||
$params['tags'] = json_encode($params['tags']);
|
$params['tags'] = json_encode($params['tags']);
|
||||||
|
@ -357,4 +357,18 @@ class ServerService
|
|||||||
}
|
}
|
||||||
return $server->toArray();
|
return $server->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function serverIsExist($name):bool
|
||||||
|
{
|
||||||
|
if (ServerShadowsocks::where('name', $name)->first()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (ServerTrojan::where('name', $name)->first()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (Server::where('name', $name)->first()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user