diff --git a/app/Http/Controllers/Admin/ServerController.php b/app/Http/Controllers/Admin/ServerController.php index e21e943ae..f97733d24 100644 --- a/app/Http/Controllers/Admin/ServerController.php +++ b/app/Http/Controllers/Admin/ServerController.php @@ -72,11 +72,12 @@ public function index() ->allowedSorts(['id', 'name', 'hostname', 'ip_address', 'join_port', 'query_port', 'webquery_port', 'type', 'minecraft_version', 'order', 'country_id', 'last_scanned_at', 'created_at']) ->defaultSort('-order') ->paginate($perPage) + ->through(fn($server) => $server->append('masked_ip_address')->makeHidden('ip_address')) ->withQueryString(); return Inertia::render('Admin/Server/IndexServer', [ 'servers' => $servers, - 'canCreateBungeeServer' => ! $canCreateBungeeServer, + 'canCreateBungeeServer' => !$canCreateBungeeServer, 'filters' => request()->all(['perPage', 'sort', 'filter']), ]); } @@ -177,7 +178,7 @@ public function storeBungee(Request $request, GeolocationService $geolocationSer 'order' => $request->order, ]); - if (! $request->webquery_port) { + if (!$request->webquery_port) { return redirect()->route('admin.server.index') ->with(['toast' => ['type' => 'success', 'title' => __('Created Successfully'), 'body' => __('Proxy server added successfully')]]); } @@ -306,9 +307,9 @@ public function updateBungee(Request $request, Server $server, GeolocationServic $server->save(); // We forget the cached result so that new data will be shown instantly and not redundant data. - Cache::forget('server:ping:'.$server->id); - Cache::forget('server:query:'.$server->id); - Cache::forget('server:webquery:'.$server->id); + Cache::forget('server:ping:' . $server->id); + Cache::forget('server:query:' . $server->id); + Cache::forget('server:webquery:' . $server->id); return redirect()->route('admin.server.index') ->with(['toast' => ['type' => 'success', 'title' => __('Updated Successfully'), 'body' => __('Server updated successfully')]]); @@ -338,9 +339,9 @@ public function update(UpdateServerRequest $request, Server $server, Geolocation $server->save(); // We forget the cached result so that new data will be shown instantly and not redundant data. - Cache::forget('server:ping:'.$server->id); - Cache::forget('server:query:'.$server->id); - Cache::forget('server:webquery:'.$server->id); + Cache::forget('server:ping:' . $server->id); + Cache::forget('server:query:' . $server->id); + Cache::forget('server:webquery:' . $server->id); return redirect()->route('admin.server.index') ->with(['toast' => ['type' => 'success', 'title' => __('Updated Successfully'), 'body' => __('Server updated successfully')]]); diff --git a/app/Models/Server.php b/app/Models/Server.php index 347e98cce..c1ac0818e 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -117,4 +117,9 @@ public function getSettingsKey($key, $default = null) { return Arr::dot($this->settings)[$key] ?? $default; } + + public function getMaskedIpAddressAttribute() + { + return preg_replace('/(\d{1,3})\.\d{1,3}\.\d{1,3}\.\d{1,3}/', '$1.xx.xx.xx', $this->ip_address); + } } diff --git a/resources/default/js/Pages/Admin/Server/IndexServer.vue b/resources/default/js/Pages/Admin/Server/IndexServer.vue index 49f57e646..67fab0e11 100644 --- a/resources/default/js/Pages/Admin/Server/IndexServer.vue +++ b/resources/default/js/Pages/Admin/Server/IndexServer.vue @@ -239,7 +239,7 @@ function getServerWebQueryStatus(serverId) {
- {{ item.ip_address }} : {{ item.join_port }} + {{ item.masked_ip_address }} : {{ item.join_port }}
{{