update: new feature route manage

This commit is contained in:
tokumeikoi
2022-11-27 15:11:10 +08:00
parent f9e2afe9d1
commit 16693b94bf
13 changed files with 157 additions and 31 deletions

View File

@ -3,6 +3,7 @@
namespace App\Services;
use App\Models\ServerLog;
use App\Models\ServerRoute;
use App\Models\ServerShadowsocks;
use App\Models\User;
use App\Models\ServerV2ray;
@ -107,7 +108,6 @@ class ServerService
return $servers;
}
public function getAvailableUsers($groupId)
{
return User::whereIn('group_id', $groupId)
@ -183,7 +183,7 @@ class ServerService
return $server->toArray();
}
public function mergeData(&$servers)
private function mergeData(&$servers)
{
foreach ($servers as $k => $v) {
$serverType = strtoupper($servers[$k]['type']);
@ -217,4 +217,23 @@ class ServerService
array_multisort($tmp, SORT_ASC, $servers);
return $servers;
}
public function getRoutes(array $routeIds)
{
return ServerRoute::select(['id', 'match', 'action', 'action_value'])->whereIn('id', $routeIds)->get();
}
public function getServer($serverId, $serverType)
{
switch ($serverType) {
case 'v2ray':
return ServerV2ray::find($serverId);
case 'shadowsocks':
return ServerShadowsocks::find($serverId);
case 'trojan':
return ServerTrojan::find($serverId);
default:
return false;
}
}
}