From dca6fbadfa1e07e33d99c355024e0587fab382f0 Mon Sep 17 00:00:00 2001 From: DuckieTM Date: Thu, 5 Jan 2023 02:42:05 +0000 Subject: [PATCH] SSL Error handeling & Proxy information in connection --- .../com/eu/habbo/habbohotel/users/Habbo.java | 9 ++++- .../decoders/GameMessageHandler.java | 40 ++++++++++++++++--- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java index f867a8a2..6e6029f2 100644 --- a/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java +++ b/src/main/java/com/eu/habbo/habbohotel/users/Habbo.java @@ -118,10 +118,17 @@ public class Habbo implements Runnable { public boolean connect() { String ip = ""; + String ProxyIP = ""; if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) { SocketAddress address = this.client.getChannel().remoteAddress(); ip = ((InetSocketAddress) address).getAddress().getHostAddress(); + ProxyIP = "- no proxy server used"; + } + else + { + SocketAddress address = this.client.getChannel().remoteAddress(); + ProxyIP = ((InetSocketAddress) address).getAddress().getHostAddress(); } if (Emulator.getPluginManager().isRegistered(UserGetIPAddressEvent.class, true)) { @@ -149,7 +156,7 @@ public class Habbo implements Runnable { this.messenger.connectionChanged(this, true, false); Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); - LOGGER.info("{} logged in from IP {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin()); + LOGGER.info("{} logged in from IP {} using proxyserver {}", this.habboInfo.getUsername(), this.habboInfo.getIpLogin(), ProxyIP); return true; } diff --git a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java index c85f3315..e5936002 100644 --- a/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java +++ b/src/main/java/com/eu/habbo/networking/gameserver/decoders/GameMessageHandler.java @@ -7,11 +7,18 @@ import com.eu.habbo.threading.runnables.ChannelReadHandler; import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelInboundHandlerAdapter; +import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.TooLongFrameException; +import io.netty.handler.codec.UnsupportedMessageTypeException; +import io.netty.handler.ssl.NotSslRecordException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.net.ssl.SSLException; +import javax.net.ssl.SSLHandshakeException; import java.io.IOException; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; @ChannelHandler.Sharable public class GameMessageHandler extends ChannelInboundHandlerAdapter { @@ -60,13 +67,34 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter { return; } if (Emulator.getConfig().getBoolean("debug.mode")) { - if (cause instanceof TooLongFrameException) { - LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); - } else { - LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); + if (cause instanceof NotSslRecordException) { + LOGGER.error("Plaintext received instead of ssl, closing channel"); + } + else if (cause instanceof DecoderException) { + LOGGER.error("Plaintext received instead of ssl, closing channel"); + } + else if (cause instanceof TooLongFrameException) { + LOGGER.error("Disconnecting client, reason " + cause.getMessage()); + } + else if (cause instanceof SSLHandshakeException) { + LOGGER.error("URL Request error from source " + ctx.channel().remoteAddress()); + } + else if (cause instanceof NoSuchAlgorithmException) { + LOGGER.error("Invalid SSL algorithm, only TLSv1.2 supported in the request"); + } + else if (cause instanceof KeyManagementException) { + LOGGER.error("Invalid SSL algorithm, only TLSv1.2 supported in the request"); + } + else if (cause instanceof UnsupportedMessageTypeException) { + LOGGER.error("There was an illegal SSL request from (X-forwarded-for/CF-Connecting-IP has not being injected yet!) " + ctx.channel().remoteAddress()); + } + else if (cause instanceof SSLException) { + LOGGER.error("SSL Problem: "+ cause.getMessage() + cause); + } + else { + LOGGER.error("Disconnecting client, exception in GameMessageHandler.", cause); } } ctx.channel().close(); } - -} \ No newline at end of file +}