From e436348dd19e3cbb461b2146680caaa7c56a79c6 Mon Sep 17 00:00:00 2001 From: alexmerlin Date: Wed, 11 Dec 2024 12:13:04 +0200 Subject: [PATCH] Revert masking Signed-off-by: alexmerlin --- src/Admin/src/Service/AdminService.php | 2 +- src/App/src/Service/IpService.php | 16 ---------------- 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/src/Admin/src/Service/AdminService.php b/src/Admin/src/Service/AdminService.php index 49342da..e63f537 100644 --- a/src/Admin/src/Service/AdminService.php +++ b/src/Admin/src/Service/AdminService.php @@ -205,7 +205,7 @@ public function logAdminVisit(array $serverParams, string $name, string $status) $organization = $this->locationService->getOrganization($ipAddress)->getName(); $adminLogin = (new AdminLogin()) - ->setAdminIp(IpService::obfuscateIpAddress($ipAddress)) + ->setAdminIp($this->locationService->obfuscateIpAddress($ipAddress)) ->setContinent($continent) ->setCountry($country) ->setOrganization($organization) diff --git a/src/App/src/Service/IpService.php b/src/App/src/Service/IpService.php index 53276c4..fa694fe 100644 --- a/src/App/src/Service/IpService.php +++ b/src/App/src/Service/IpService.php @@ -6,9 +6,6 @@ use function filter_var; use function getenv; -use function preg_replace_callback; -use function str_repeat; -use function strlen; use const FILTER_FLAG_IPV4; use const FILTER_FLAG_IPV6; @@ -56,17 +53,4 @@ public static function isPublicIp(string $ipAddress): bool FILTER_FLAG_NO_RES_RANGE ) === $ipAddress; } - - public static function obfuscateIpAddress(string $ipAddress, string $mask = 'x'): string - { - if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) { - $pattern = '/\d+$/'; - } elseif (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) { - $pattern = '/[a-z0-9]+$/i'; - } else { - return $ipAddress; - } - - return preg_replace_callback($pattern, fn (array $last) => str_repeat($mask, strlen($last[0])), $ipAddress); - } }