ktor forwarded headers, etag, more complete logging

This commit is contained in:
creeper123123321 2021-02-22 10:07:15 -03:00
parent 169125137d
commit 94cfd7fb1d
4 changed files with 18 additions and 8 deletions

View File

@ -9,6 +9,7 @@ plugins {
application {
mainClassName = "com.github.creeper123123321.viaaas.VIAaaSKt"
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
}
java {

View File

@ -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") {

View File

@ -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
}
}
}

View File

@ -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