log status proxying as debug

This commit is contained in:
creeper123123321 2022-08-13 11:46:58 -03:00
parent b60c7b043d
commit c4d12ae085
10 changed files with 35 additions and 25 deletions

View File

@ -127,9 +127,13 @@ object AspirinServer {
ktorServer = embeddedServer(Netty, commandLineEnvironment(args)) {}.start(false)
viaaasLogger.info("Using compression: ${Natives.compress.loadedVariant}, crypto: ${Natives.cipher.loadedVariant}")
viaaasLogger.info(
"Using compression: {}, crypto: {}",
Natives.compress.loadedVariant,
Natives.cipher.loadedVariant
)
chFutures.forEach {
viaaasLogger.info("Binded minecraft into " + it.sync().channel().localAddress())
viaaasLogger.info("Binded minecraft into {}", it.sync().channel().localAddress())
}
viaaasLogger.info(
"Application started in " + ManagementFactory.getRuntimeMXBean().uptime

View File

@ -21,7 +21,7 @@ fun main(args: Array<String>) {
try {
setupSystem()
printSplash()
CoroutineScope(Job()).launch { viaaasLogger.info(AspirinServer.updaterCheckMessage()) }
CoroutineScope(Job()).launch { viaaasLogger.info("{}", AspirinServer.updaterCheckMessage()) }
AspirinServer.generateCert()
initVia()
AspirinServer.listenPorts(args)

View File

@ -64,7 +64,7 @@ class MinecraftHandler(
if (cause is CancelCodecException) return
if (cause is ClosedChannelException) return
val exceptionId = ThreadLocalRandom.current().nextInt().toUInt().toString(36)
mcLogger.debug("Exception $exceptionId: ", cause)
mcLogger.debug("Exception {}: ", exceptionId, cause)
disconnect("$cause #$exceptionId")
}

View File

@ -23,7 +23,7 @@ class ProtocolDetectionState(val future: CompletableFuture<ProtocolVersion>) : C
val ver = JsonParser.parseString(packet.msg).asJsonObject
.getAsJsonObject("version")["protocol"].asInt.parseProtocol()
future.complete(ver)
mcLogger.info("A.D.: ${handler.endRemoteAddress} $ver")
mcLogger.info("A.D.: {} {}", handler.endRemoteAddress, ver)
}
override fun disconnect(handler: MinecraftHandler, msg: String) {

View File

@ -17,12 +17,11 @@ interface ConnectionState {
private fun logDisconnect(handler: MinecraftHandler, msg: String?) {
val reason = msg ?: if (handler.backEnd && kickedByServer) "kicked" else "-"
val formatted = "- ${handler.endRemoteAddress}: $reason"
if (logDcInfo && !handler.loggedDc) {
handler.loggedDc = true
mcLogger.info(formatted)
mcLogger.info("- {}: {}", handler.endRemoteAddress, reason)
} else {
mcLogger.debug(formatted)
mcLogger.debug("- {}: {}", handler.endRemoteAddress, reason)
}
}

View File

@ -99,8 +99,8 @@ class HandshakeState : ConnectionState {
val playerAddr = handler.data.frontHandler.endRemoteAddress
mcLogger.debug(
"HS: $playerAddr ${handler.data.state.state.name[0]} " +
"$virtualHostNoExtra $virtualPort v${handler.data.frontVer}"
"HS: {} {} {} {} v{}",
playerAddr, handler.data.state.state.name, virtualHostNoExtra, virtualPort, handler.data.frontVer
)
if (!usedDefault && !hadHostname && VIAaaSConfig.requireHostName && !addressFromWeb

View File

@ -178,7 +178,10 @@ class LoginState : ConnectionState {
val backKey = generate128Bits()
val backHash = generateServerHash(backServerId, backKey, backPublicKey)
mcLogger.info("Session req: ${handler.data.frontHandler.endRemoteAddress} ($playerId $frontName) $backName")
mcLogger.info(
"Session req: {} ({} {}) {}",
handler.data.frontHandler.endRemoteAddress, playerId, frontName, backName
)
val pluginReauthed = reauthMessage(handler, backName!!, backHash).await()
if (!pluginReauthed) {
AspirinServer.viaWebServer.requestSessionJoin(
@ -258,7 +261,7 @@ class LoginState : ConnectionState {
handler.coroutineScope.launch(Dispatchers.IO) {
try {
if (backAddress == null) {
mcLogger.info("Requesting address info from web for $frontName")
mcLogger.info("Requesting address info from web for {}", frontName)
val info = AspirinServer.viaWebServer.requestAddressInfo(frontName).await()
backAddress = info.backHostAndPort
handler.data.backServerVer = info.backVersion
@ -273,7 +276,7 @@ class LoginState : ConnectionState {
else -> {}
}
val id = callbackPlayerId.await()
mcLogger.info("Login: ${handler.endRemoteAddress} $frontName $id")
mcLogger.info("Login: {} {} {}", handler.endRemoteAddress, frontName, id)
}
connectBack(
handler,

View File

@ -51,7 +51,11 @@ private suspend fun createBackChannel(
.channel()
(channel.pipeline()["proxy"] as? ProxyHandler)?.connectFuture()?.suspendAwait()
mcLogger.info("+ ${state.name[0]} ${handler.endRemoteAddress} -> $socketAddr")
if (state == State.LOGIN) {
mcLogger.info("+ L {} -> {}", handler.endRemoteAddress, socketAddr)
} else {
mcLogger.debug("+ {} {} -> {}", state.name[0], handler.endRemoteAddress, socketAddr)
}
handler.data.backChannel = channel as SocketChannel
autoDetectVersion(handler, socketAddr)
@ -77,7 +81,7 @@ private suspend fun autoDetectVersion(handler: MinecraftHandler, socketAddr: Ine
ProtocolDetector.detectVersion(socketAddr).await()
}
} catch (e: Exception) {
mcLogger.warn("Failed to detect version of $socketAddr: $e")
mcLogger.warn("Failed to detect version of {}: {}", socketAddr, e.toString())
mcLogger.debug("Stacktrace: ", e)
}

View File

@ -81,7 +81,7 @@ class WebLogin : WebState {
val token = webClient.server.generateToken(uuid, username)
webClient.ws.sendSerialized(loginSuccessJson(username, uuid, token))
webLogger.info("Token gen: ${webClient.id}: offline $username $uuid")
webLogger.info("Token gen: {}: offline {} {}", webClient.id, username, uuid)
}
private suspend fun handleMcIdLogin(webClient: WebClient, obj: JsonObject) {
@ -102,10 +102,10 @@ class WebLogin : WebState {
val token = webClient.server.generateToken(uuid, mcIdUser)
webClient.ws.sendSerialized(loginSuccessJson(mcIdUser, uuid, token))
webLogger.info("Token gen: ${webClient.id}: $mcIdUser $uuid")
webLogger.info("Token gen: {}: {} {}", webClient.id, mcIdUser, uuid)
} else {
webClient.ws.sendSerialized(loginNotSuccess())
webLogger.info("Token gen fail: ${webClient.id}: $username")
webLogger.info("Token gen fail: {}: {}", webClient.id, username)
}
}
@ -120,17 +120,17 @@ class WebLogin : WebState {
response.addProperty("success", true)
response.addProperty("user", user.id.toString())
response.addProperty("username", user.name)
webLogger.info("Listen: ${webClient.id}: $user")
webLogger.info("Listen: {}: {}", webClient.id, user)
} else {
response.addProperty("success", false)
webLogger.info("Listen fail: ${webClient.id}")
webLogger.info("Listen fail: {}", webClient.id)
}
webClient.ws.sendSerialized(response)
}
private suspend fun handleUnlisten(webClient: WebClient, obj: JsonObject) {
val uuid = UUID.fromString(obj["uuid"].asString)
webLogger.info("Unlisten: ${webClient.id}: $uuid")
webLogger.info("Unlisten: {}: {}", webClient.id, uuid)
val response = JsonObject().also {
it.addProperty("action", "unlisten_login_requests_result")
it.addProperty("uuid", uuid.toString())

View File

@ -119,7 +119,7 @@ class WebServer {
try {
onlineId = usernameToIdCache[frontName].await()
} catch (e: java.lang.Exception) {
webLogger.debug("Couldn't get online uuid for $frontName", e)
webLogger.debug("Couldn't get online uuid for {}", frontName, e)
}
val offlineId = generateOfflinePlayerUuid(frontName)
@ -233,7 +233,7 @@ class WebServer {
suspend fun connected(ws: WebSocketServerSession) {
val loginState = WebLogin()
val client = WebClient(this, ws, loginState)
webLogger.info("+ WS: ${client.id}")
webLogger.info("+ WS: {}", client.id)
clients[ws] = client
loginState.start(client)
}
@ -248,14 +248,14 @@ class WebServer {
suspend fun disconnected(ws: WebSocketServerSession) {
val client = clients[ws]!!
webLogger.info("- WS: ${client.id}")
webLogger.info("- WS: {}", client.id)
client.state.disconnected(client)
clients.remove(ws)
}
suspend fun onException(ws: WebSocketServerSession, exception: Throwable) {
val client = clients[ws]!!
webLogger.info("WS Error: ${client.id} $exception")
webLogger.info("WS Error: {} {}", client.id, exception.toString())
webLogger.debug("Ws exception: ", exception)
client.state.onException(client, exception)
}