From 478fb35e574d15ef9630196c7543174d88d8c626 Mon Sep 17 00:00:00 2001 From: xk730 <40309144+xk730@users.noreply.github.com> Date: Wed, 5 Jul 2023 01:14:45 +0800 Subject: [PATCH] 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 --- .../src/com/unciv/app/server/UncivServer.kt | 33 +++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/server/src/com/unciv/app/server/UncivServer.kt b/server/src/com/unciv/app/server/UncivServer.kt index c14c3ec3f6..055b360d1f 100644 --- a/server/src/com/unciv/app/server/UncivServer.kt +++ b/server/src/com/unciv/app/server/UncivServer.kt @@ -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 }