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
|
@Override
|
||||||
public boolean getLogDc() {
|
public boolean getLogDcInfo() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +36,9 @@ class MinecraftHandler(
|
|||||||
|
|
||||||
override fun channelInactive(ctx: ChannelHandlerContext) {
|
override fun channelInactive(ctx: ChannelHandlerContext) {
|
||||||
if (!failedProxy(ctx)) {
|
if (!failedProxy(ctx)) {
|
||||||
other?.close()
|
|
||||||
data.state.onInactivated(this)
|
data.state.onInactivated(this)
|
||||||
}
|
}
|
||||||
coroutineScope.cancel()
|
ctx.executor().execute(coroutineScope::cancel) // wait a bit... cancelexception spam...
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun channelReadComplete(ctx: ChannelHandlerContext?) {
|
override fun channelReadComplete(ctx: ChannelHandlerContext?) {
|
||||||
|
@ -12,16 +12,24 @@ interface ConnectionState {
|
|||||||
handler: MinecraftHandler, ctx: ChannelHandlerContext,
|
handler: MinecraftHandler, ctx: ChannelHandlerContext,
|
||||||
packet: Packet
|
packet: Packet
|
||||||
)
|
)
|
||||||
val logDc: Boolean get() = false
|
val logDcInfo: Boolean get() = false
|
||||||
|
|
||||||
|
private fun logDisconnect(handler: MinecraftHandler, msg: String) {
|
||||||
|
val formatted = "- ${handler.endRemoteAddress}: $msg"
|
||||||
|
if (logDcInfo && !handler.loggedDc) {
|
||||||
|
handler.loggedDc = true
|
||||||
|
mcLogger.info(formatted)
|
||||||
|
} else {
|
||||||
|
mcLogger.debug(formatted)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun disconnect(handler: MinecraftHandler, msg: String) {
|
fun disconnect(handler: MinecraftHandler, msg: String) {
|
||||||
if (logDc && !handler.loggedDc) {
|
logDisconnect(handler, msg)
|
||||||
handler.loggedDc = true
|
|
||||||
mcLogger.info("DC ${handler.endRemoteAddress}: $msg")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onInactivated(handler: MinecraftHandler) {
|
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
|
val playerAddr = handler.data.frontHandler.endRemoteAddress
|
||||||
mcLogger.info(
|
mcLogger.debug(
|
||||||
"HS: $playerAddr ${handler.data.state.state.toString().substring(0, 1)} " +
|
"HS: $playerAddr ${handler.data.state.state.toString().substring(0, 1)} " +
|
||||||
"$virtualHostNoExtra $virtualPort v${handler.data.frontVer}"
|
"$virtualHostNoExtra $virtualPort v${handler.data.frontVer}"
|
||||||
)
|
)
|
||||||
@ -123,8 +123,4 @@ class HandshakeState : ConnectionState {
|
|||||||
super.disconnect(handler, msg)
|
super.disconnect(handler, msg)
|
||||||
handler.data.frontChannel.close() // Not worth logging
|
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
|
var started = false
|
||||||
override val state: State
|
override val state: State
|
||||||
get() = State.LOGIN
|
get() = State.LOGIN
|
||||||
override val logDc: Boolean
|
override val logDcInfo: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
var callbackPluginReauth = CompletableFuture<Boolean>()
|
var callbackPluginReauth = CompletableFuture<Boolean>()
|
||||||
var pendingReauth: Int? = null
|
var pendingReauth: Int? = null
|
||||||
|
@ -17,7 +17,7 @@ import io.netty.util.ReferenceCountUtil
|
|||||||
object PlayState : ConnectionState {
|
object PlayState : ConnectionState {
|
||||||
override val state: State
|
override val state: State
|
||||||
get() = State.PLAY
|
get() = State.PLAY
|
||||||
override val logDc: Boolean
|
override val logDcInfo: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
|
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
|
||||||
|
@ -20,8 +20,6 @@ import java.util.*
|
|||||||
object StatusState : ConnectionState {
|
object StatusState : ConnectionState {
|
||||||
override val state: State
|
override val state: State
|
||||||
get() = State.STATUS
|
get() = State.STATUS
|
||||||
override val logDc: Boolean
|
|
||||||
get() = true
|
|
||||||
|
|
||||||
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
|
override fun handlePacket(handler: MinecraftHandler, ctx: ChannelHandlerContext, packet: Packet) {
|
||||||
if (packet is UnknownPacket) throw StacklessException("Invalid packet")
|
if (packet is UnknownPacket) throw StacklessException("Invalid packet")
|
||||||
|
@ -47,7 +47,7 @@ private suspend fun createBackChannel(
|
|||||||
.channel()
|
.channel()
|
||||||
(channel.pipeline().get("proxy") as? ProxyHandler)?.connectFuture()?.suspendAwait()
|
(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
|
handler.data.backChannel = channel as SocketChannel
|
||||||
|
|
||||||
autoDetectVersion(handler, socketAddr)
|
autoDetectVersion(handler, socketAddr)
|
||||||
@ -102,7 +102,7 @@ private suspend fun tryBackAddresses(
|
|||||||
|| matchesAddress(socketAddr, VIAaaSConfig.blockedBackAddresses)
|
|| matchesAddress(socketAddr, VIAaaSConfig.blockedBackAddresses)
|
||||||
|| !matchesAddress(socketAddr, VIAaaSConfig.allowedBackAddresses)
|
|| !matchesAddress(socketAddr, VIAaaSConfig.allowedBackAddresses)
|
||||||
) {
|
) {
|
||||||
throw StacklessException("Not allowed")
|
throw StacklessException("Address not allowed")
|
||||||
}
|
}
|
||||||
|
|
||||||
val proxyUri = VIAaaSConfig.backendProxy
|
val proxyUri = VIAaaSConfig.backendProxy
|
||||||
@ -144,13 +144,9 @@ suspend fun connectBack(
|
|||||||
state: State,
|
state: State,
|
||||||
extraData: String? = null
|
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)
|
tryBackAddresses(handler, addresses, state, extraData)
|
||||||
} catch (e: Exception) {
|
|
||||||
throw StacklessException("Connect: $e", e)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user