From bb5169e8139c919e3f36436c6784bce80f080dbe Mon Sep 17 00:00:00 2001 From: Suqatri Date: Sat, 6 Apr 2024 18:25:04 +0200 Subject: [PATCH] fix: ipv6 --- .../dev/redicloud/repository/service/CloudService.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/repositories/service-repository/src/main/kotlin/dev/redicloud/repository/service/CloudService.kt b/repositories/service-repository/src/main/kotlin/dev/redicloud/repository/service/CloudService.kt index ccb69e5d..3f44ed8d 100644 --- a/repositories/service-repository/src/main/kotlin/dev/redicloud/repository/service/CloudService.kt +++ b/repositories/service-repository/src/main/kotlin/dev/redicloud/repository/service/CloudService.kt @@ -51,14 +51,14 @@ abstract class CloudService( } override fun startSession(ipAddress: String): ServiceSession { - var parsedHostname = ipAddress - if (isIpv6(ipAddress) && !ipAddress.startsWith("[")) { - parsedHostname = "[$ipAddress]" - } if (!isIpv4(ipAddress) && !isIpv6(ipAddress)) { throw IllegalArgumentException("Invalid IP address: $ipAddress") } - val session = ServiceSession(this.serviceId, System.currentTimeMillis(), ipAddress) + var hostname = ipAddress + if (isIpv6(ipAddress) && !ipAddress.startsWith("[")) { + hostname = "[$ipAddress]" + } + val session = ServiceSession(this.serviceId, System.currentTimeMillis(), hostname) sessions.currentSession = session if (registrationSession == null) { sessions.registrationSession = session