This commit is contained in:
Harmonic 2023-01-04 18:43:32 -08:00
commit 4340261506
3 changed files with 64 additions and 12 deletions

View File

@ -118,10 +118,17 @@ public class Habbo implements Runnable {
public boolean connect() { public boolean connect() {
String ip = ""; String ip = "";
String ProxyIP = "";
if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) { if (!Emulator.getConfig().getBoolean("networking.tcp.proxy") && this.client.getChannel().remoteAddress() != null) {
SocketAddress address = this.client.getChannel().remoteAddress(); SocketAddress address = this.client.getChannel().remoteAddress();
ip = ((InetSocketAddress) address).getAddress().getHostAddress(); 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)) { if (Emulator.getPluginManager().isRegistered(UserGetIPAddressEvent.class, true)) {
@ -149,7 +156,7 @@ public class Habbo implements Runnable {
this.messenger.connectionChanged(this, true, false); this.messenger.connectionChanged(this, true, false);
Emulator.getGameEnvironment().getRoomManager().loadRoomsForHabbo(this); 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; return true;
} }

View File

@ -11,6 +11,9 @@ import gnu.trove.procedure.TIntObjectProcedure;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays;
import java.util.List;
public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure<HabboItem> { public class InventoryItemsComposer extends MessageComposer implements TIntObjectProcedure<HabboItem> {
private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class); private static final Logger LOGGER = LoggerFactory.getLogger(InventoryItemsComposer.class);
@ -48,7 +51,7 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
this.response.appendInt(habboItem.getId()); this.response.appendInt(habboItem.getId());
this.response.appendInt(habboItem.getBaseItem().getSpriteId()); this.response.appendInt(habboItem.getBaseItem().getSpriteId());
if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) { if (habboItem.getBaseItem().getName().equals("floor") || habboItem.getBaseItem().getName().equals("landscape") || habboItem.getBaseItem().getName().equals("song_disk") || habboItem.getBaseItem().getName().equals("wallpaper") || habboItem.getBaseItem().getName().equals("poster")) {
switch (habboItem.getBaseItem().getName()) { switch (habboItem.getBaseItem().getName()) {
case "landscape": case "landscape":
this.response.appendInt(4); this.response.appendInt(4);
@ -62,10 +65,11 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
case "poster": case "poster":
this.response.appendInt(6); this.response.appendInt(6);
break; break;
case "song_disk":
this.response.appendInt(8);
break;
} }
this.addExtraDataToResponse(habboItem);
this.response.appendInt(0);
this.response.appendString(habboItem.getExtradata());
} else { } else {
if (habboItem.getBaseItem().getName().equals("gnome_box")) if (habboItem.getBaseItem().getName().equals("gnome_box"))
this.response.appendInt(13); this.response.appendInt(13);
@ -82,12 +86,25 @@ public class InventoryItemsComposer extends MessageComposer implements TIntObjec
this.response.appendBoolean(true); this.response.appendBoolean(true);
this.response.appendInt(-1); this.response.appendInt(-1);
if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) { if (habboItem.getBaseItem().getType() == FurnitureType.FLOOR) {
this.response.appendString(""); this.response.appendString("");
if(habboItem.getBaseItem().getName().equals("song_disk")) {
List<String> extraDataAsList = Arrays.asList(habboItem.getExtradata().split("\n"));
this.response.appendInt(Integer.valueOf(extraDataAsList.get(extraDataAsList.size() - 1)));
return true;
}
this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1); this.response.appendInt(habboItem instanceof InteractionGift ? ((((InteractionGift) habboItem).getColorId() * 1000) + ((InteractionGift) habboItem).getRibbonId()) : 1);
} }
return true; return true;
} }
} public void addExtraDataToResponse(HabboItem habboItem) {
this.response.appendInt(0);
this.response.appendString(habboItem.getExtradata());
}
}

View File

@ -7,11 +7,18 @@ import com.eu.habbo.threading.runnables.ChannelReadHandler;
import io.netty.channel.ChannelHandler; import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.net.ssl.SSLException;
import javax.net.ssl.SSLHandshakeException;
import java.io.IOException; import java.io.IOException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
@ChannelHandler.Sharable @ChannelHandler.Sharable
public class GameMessageHandler extends ChannelInboundHandlerAdapter { public class GameMessageHandler extends ChannelInboundHandlerAdapter {
@ -60,13 +67,34 @@ public class GameMessageHandler extends ChannelInboundHandlerAdapter {
return; return;
} }
if (Emulator.getConfig().getBoolean("debug.mode")) { if (Emulator.getConfig().getBoolean("debug.mode")) {
if (cause instanceof TooLongFrameException) { if (cause instanceof NotSslRecordException) {
LOGGER.error("Disconnecting client, reason: \"" + cause.getMessage() + "\"."); LOGGER.error("Plaintext received instead of ssl, closing channel");
} else { }
LOGGER.error("Disconnecting client, exception in GameMessageHander.", cause); 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(); ctx.channel().close();
} }
}
}