From c1fc7cef49c349fdfd2864322ae8d7a70bda763c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 4 Jun 2021 12:08:20 +0200 Subject: [PATCH] Return an IP address in Session::getIpAddress() --- .../install/files/lib/system/session/Session.class.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/session/Session.class.php b/wcfsetup/install/files/lib/system/session/Session.class.php index 9fe824431d..2de66d50cd 100644 --- a/wcfsetup/install/files/lib/system/session/Session.class.php +++ b/wcfsetup/install/files/lib/system/session/Session.class.php @@ -2,8 +2,8 @@ namespace wcf\system\session; +use wcf\util\IpAddress; use wcf\util\UserAgent; -use wcf\util\UserUtil; /** * Represents a session. @@ -84,11 +84,13 @@ final class Session } /** - * Returns the converted ip address of the session. + * Returns the last used ip address of the session. */ - public function getIpAddress(): string + public function getIpAddress(): IpAddress { - return UserUtil::convertIPv6To4($this->data['ipAddress']); + $ipAddress = new IpAddress($this->data['ipAddress']); + + return $ipAddress->asV4() ?: $ipAddress; } /** -- 2.20.1