mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-15 10:55:27 +01:00
parent
16ed806b8b
commit
188b6e5cc1
@ -28,7 +28,7 @@ public class StatusKicked implements ConnectionState {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getLogDc() {
|
||||
public boolean getLogDcInfo() {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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?) {
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user