Update UncivServer.kt (#9742)

* Update UncivServer.kt

Add display operator IP mode to help game match referees query operators

* Update UncivServer.kt

* Update UncivServer.kt
This commit is contained in:
xk730 2023-07-05 01:14:45 +08:00 committed by GitHub
parent ad0af51020
commit 478fb35e57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,6 +50,13 @@ private class UncivServerRunner : CliktCommand() {
help = "Enable Authentication"
).flag("-no-auth", default = false)
private val IdentifyOperators by option(
"-i", "-Identify",
envvar = "UncivServerIdentify",
help = "Display each operation archive request IP to assist management personnel"
).flag("-no-Identify", default = false)
override fun run() {
serverRun(port, folder)
}
@ -125,7 +132,14 @@ private class UncivServerRunner : CliktCommand() {
}
put("/files/{fileName}") {
val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
log.info("Receiving file: $fileName")
// If IdentifyOperators is enabled a Operator IP is displayed
if (IdentifyOperators) {
log.info("Receiving file: ${fileName} --Operation sourced from ${call.request.local.remoteHost}")
}else{
log.info("Receiving file: ${fileName}")
}
val file = File(fileFolderName, fileName)
if (!validateGameAccess(file, call.request.headers["Authorization"])) {
@ -142,10 +156,23 @@ private class UncivServerRunner : CliktCommand() {
}
get("/files/{fileName}") {
val fileName = call.parameters["fileName"] ?: throw Exception("No fileName!")
log.info("File requested: $fileName")
// If IdentifyOperators is enabled a Operator IP is displayed
if (IdentifyOperators) {
log.info("File requested: ${fileName} --Operation sourced from ${call.request.local.remoteHost}")
}else{
log.info("File requested: $fileName")
}
val file = File(fileFolderName, fileName)
if (!file.exists()) {
log.info("File $fileName not found")
// If IdentifyOperators is enabled a Operator IP is displayed
if (IdentifyOperators) {
log.info("File ${fileName} not found --Operation sourced from ${call.request.local.remoteHost}")
}else{
log.info("File $fileName not found")
}
call.respond(HttpStatusCode.NotFound, "File does not exist")
return@get
}