mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-23 01:04:24 +07:00
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:
parent
ad0af51020
commit
478fb35e57
@ -50,6 +50,13 @@ private class UncivServerRunner : CliktCommand() {
|
|||||||
help = "Enable Authentication"
|
help = "Enable Authentication"
|
||||||
).flag("-no-auth", default = false)
|
).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() {
|
override fun run() {
|
||||||
serverRun(port, folder)
|
serverRun(port, folder)
|
||||||
}
|
}
|
||||||
@ -125,7 +132,14 @@ private class UncivServerRunner : CliktCommand() {
|
|||||||
}
|
}
|
||||||
put("/files/{fileName}") {
|
put("/files/{fileName}") {
|
||||||
val fileName = call.parameters["fileName"] ?: throw Exception("No 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)
|
val file = File(fileFolderName, fileName)
|
||||||
|
|
||||||
if (!validateGameAccess(file, call.request.headers["Authorization"])) {
|
if (!validateGameAccess(file, call.request.headers["Authorization"])) {
|
||||||
@ -142,10 +156,23 @@ private class UncivServerRunner : CliktCommand() {
|
|||||||
}
|
}
|
||||||
get("/files/{fileName}") {
|
get("/files/{fileName}") {
|
||||||
val fileName = call.parameters["fileName"] ?: throw Exception("No 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)
|
val file = File(fileFolderName, fileName)
|
||||||
if (!file.exists()) {
|
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")
|
call.respond(HttpStatusCode.NotFound, "File does not exist")
|
||||||
return@get
|
return@get
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user