diff --git a/build.gradle.kts b/build.gradle.kts index 18b217e..243d044 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,6 +9,7 @@ plugins { application { mainClassName = "com.github.creeper123123321.viaaas.VIAaaSKt" + applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true") } java { diff --git a/src/main/kotlin/com/github/creeper123123321/viaaas/web/ViaWebApp.kt b/src/main/kotlin/com/github/creeper123123321/viaaas/web/ViaWebApp.kt index aabf584..760a6fb 100644 --- a/src/main/kotlin/com/github/creeper123123321/viaaas/web/ViaWebApp.kt +++ b/src/main/kotlin/com/github/creeper123123321/viaaas/web/ViaWebApp.kt @@ -16,14 +16,21 @@ import java.time.Duration class ViaWebApp { fun Application.main() { install(DefaultHeaders) + install(ConditionalHeaders) install(CallLogging) { level = Level.INFO + this.format { + "${it.request.local.method.value} ${it.response.status()?.value} ${it.request.local.remoteHost} (O: ${it.request.origin.remoteHost}) " + + "${it.request.local.scheme}://${it.request.local.host}:${it.request.local.port}${it.request.local.uri}" + } } install(WebSockets) { maxFrameSize = Short.MAX_VALUE.toLong() pingPeriod = Duration.ofSeconds(60) timeout = Duration.ofSeconds(15) } + install(XForwardedHeaderSupport) + install(ForwardedHeaderSupport) routing { webSocket("/ws") { diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index b5d7179..d52b7f6 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -9,11 +9,11 @@ ktor { } security { - ssl { - keyStore = config/https.jks - keyAlias = mykey - keyStorePassword = changeit - privateKeyPassword = changeit - } + ssl { + keyStore = config/https.jks + keyAlias = mykey + keyStorePassword = changeit + privateKeyPassword = changeit } + } } diff --git a/src/main/resources/viaaas.yml b/src/main/resources/viaaas.yml index 3c52e4a..4434e65 100644 --- a/src/main/resources/viaaas.yml +++ b/src/main/resources/viaaas.yml @@ -1,6 +1,8 @@ +####################### ## CHANGING THIS CONFIG AT RUNTIME ISN'T SUPPORTED -## See application.conf in resources for https interface options +## See https://ktor.io/docs/configurations.html#command-line for https interface options # Port used for binding Minecraft port +####################### port: 25565 # Address to bind bind-address: localhost @@ -37,4 +39,4 @@ rate-limit-ws: 1.5 # Rate limits new front-end connections per second per ip. Will disconnect when hit rate-limit-connection-mc: 10.0 # Limits how many usernames a websocket connection can listen to. -listening-ws-limit: 10 +listening-ws-limit: 10 \ No newline at end of file