reduce INFO log spam

closes #172
This commit is contained in:
creeper123123321 2021-07-16 08:06:26 -03:00
parent 16ed806b8b
commit 188b6e5cc1
8 changed files with 23 additions and 26 deletions

View File

@ -28,7 +28,7 @@ public class StatusKicked implements ConnectionState {
}
@Override
public boolean getLogDc() {
public boolean getLogDcInfo() {
return false;
}

View File

@ -36,10 +36,9 @@ class MinecraftHandler(
override fun channelInactive(ctx: ChannelHandlerContext) {
if (!failedProxy(ctx)) {
other?.close()
data.state.onInactivated(this)
}
coroutineScope.cancel()
ctx.executor().execute(coroutineScope::cancel) // wait a bit... cancelexception spam...
}
override fun channelReadComplete(ctx: ChannelHandlerContext?) {

View File

@ -12,16 +12,24 @@ interface ConnectionState {
handler: MinecraftHandler, ctx: ChannelHandlerContext,
packet: Packet
)
val logDc: Boolean get() = false
val logDcInfo: Boolean get() = false
fun disconnect(handler: MinecraftHandler, msg: String) {
if (logDc && !handler.loggedDc) {
private fun logDisconnect(handler: MinecraftHandler, msg: String) {
val formatted = "- ${handler.endRemoteAddress}: $msg"
if (logDcInfo && !handler.loggedDc) {
handler.loggedDc = true
mcLogger.info("DC ${handler.endRemoteAddress}: $msg")
mcLogger.info(formatted)
} else {
mcLogger.debug(formatted)
}
}
fun disconnect(handler: MinecraftHandler, msg: String) {
logDisconnect(handler, msg)
}
fun onInactivated(handler: MinecraftHandler) {
mcLogger.info("- ${handler.endRemoteAddress}")
logDisconnect(handler, "-")
handler.other?.close()
}
}

View File

@ -86,7 +86,7 @@ class HandshakeState : ConnectionState {
}
val playerAddr = handler.data.frontHandler.endRemoteAddress
mcLogger.info(
mcLogger.debug(
"HS: $playerAddr ${handler.data.state.state.toString().substring(0, 1)} " +
"$virtualHostNoExtra $virtualPort v${handler.data.frontVer}"
)
@ -123,8 +123,4 @@ class HandshakeState : ConnectionState {
super.disconnect(handler, msg)
handler.data.frontChannel.close() // Not worth logging
}
override fun onInactivated(handler: MinecraftHandler) {
// Not worth logging
}
}

View File

@ -36,7 +36,7 @@ class LoginState : ConnectionState {
var started = false
override val state: State
get() = State.LOGIN
override val logDc: Boolean
override val logDcInfo: Boolean
get() = true
var callbackPluginReauth = CompletableFuture<Boolean>()
var pendingReauth: Int? = null

View File

@ -17,7 +17,7 @@ import io.netty.util.ReferenceCountUtil
object PlayState : ConnectionState {
override val state: State
get() = State.PLAY
override val logDc: Boolean
override val logDcInfo: Boolean
get() = true
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {

View File

@ -20,8 +20,6 @@ import java.util.*
object StatusState : ConnectionState {
override val state: State
get() = State.STATUS
override val logDc: Boolean
get() = true
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
if (packet is UnknownPacket) throw StacklessException("Invalid packet")

View File

@ -47,7 +47,7 @@ private suspend fun createBackChannel(
.channel()
(channel.pipeline().get("proxy") as? ProxyHandler)?.connectFuture()?.suspendAwait()
mcLogger.info("+ ${handler.endRemoteAddress} -> $socketAddr")
mcLogger.info("+ ${state.name.substring(0, 1)} ${handler.endRemoteAddress} -> $socketAddr")
handler.data.backChannel = channel as SocketChannel
autoDetectVersion(handler, socketAddr)
@ -102,7 +102,7 @@ private suspend fun tryBackAddresses(
|| matchesAddress(socketAddr, VIAaaSConfig.blockedBackAddresses)
|| !matchesAddress(socketAddr, VIAaaSConfig.allowedBackAddresses)
) {
throw StacklessException("Not allowed")
throw StacklessException("Address not allowed")
}
val proxyUri = VIAaaSConfig.backendProxy
@ -144,13 +144,9 @@ suspend fun connectBack(
state: State,
extraData: String? = null
) {
try {
val addresses = resolveBackendAddresses(HostAndPort.fromParts(address, port))
val addresses = resolveBackendAddresses(HostAndPort.fromParts(address, port))
if (addresses.isEmpty()) throw StacklessException("Hostname has no IP addresses")
if (addresses.isEmpty()) throw StacklessException("Hostname has no IP addresses")
tryBackAddresses(handler, addresses, state, extraData)
} catch (e: Exception) {
throw StacklessException("Connect: $e", e)
}
tryBackAddresses(handler, addresses, state, extraData)
}