Skip to content

Commit

Permalink
KTOR-4834 Fix startup message on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
e5l committed Sep 6, 2022
1 parent 60b9269 commit c459bfe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
@@ -0,0 +1,15 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.engine.internal

private val OS_NAME = System.getProperty("os.name", "")
.lowercase()

internal actual fun escapeHostname(value: String): String {
if (!OS_NAME.contains("windows")) return value
if (value != "0.0.0.0") return value

return "127.0.0.1"
}
Expand Up @@ -72,8 +72,9 @@ public abstract class BaseApplicationEngine(
val log = environment.log
CoroutineScope(environment.application.coroutineContext).launch {
connectors.await().forEach {
val host = escapeHostname(it.host)
log.info(
"Responding at ${it.type.name.lowercase()}://${it.host}:${it.port}"
"Responding at ${it.type.name.lowercase()}://$host:${it.port}"
)
}
}
Expand Down
@@ -0,0 +1,7 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.engine.internal

internal expect fun escapeHostname(value: String): String
@@ -0,0 +1,7 @@
/*
* Copyright 2014-2022 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
*/

package io.ktor.server.engine.internal

internal actual fun escapeHostname(value: String): String = value

0 comments on commit c459bfe

Please sign in to comment.