Nan1t / NanoLimbo

The lightweight, high performance Minecraft limbo server
https://www.spigotmc.org/resources/86198/
GNU General Public License v3.0
262 stars 54 forks source link

[Bug] Error with a connection below 1.7 occurs #67

Open Finoway opened 1 year ago

Finoway commented 1 year ago

Hello, I've just found on NanoLimbo version 1.5.2 that if a client lower than 1.7 connects (tested in 1.6.4) it causes an error in the console and the client remains on "Logging in". Would it be possible to refuse the connection directly? As for 1.7/1.7.1, where it replies "Unsupported client version" or not to answer the client ?

What's more, if you read nanolimbo's README, you might think that it supports versions 1.7-1.7.1, but this is not the case.

Here's the error in the NanoLimbo console:


[09:39:26] [ERROR]: Unhandled exception: 
java.lang.NullPointerException: Cannot read field "serverBound" because "state" is null
        at ua.nanit.limbo.connection.pipeline.PacketDecoder.updateState(PacketDecoder.java:68)
        at ua.nanit.limbo.connection.ClientConnection.updateState(ClientConnection.java:225)
        at ua.nanit.limbo.connection.PacketHandler.handle(PacketHandler.java:45)
        at ua.nanit.limbo.protocol.packets.PacketHandshake.handle(PacketHandshake.java:70)
        at ua.nanit.limbo.connection.ClientConnection.handlePacket(ClientConnection.java:117)
        at ua.nanit.limbo.connection.ClientConnection.channelRead(ClientConnection.java:112)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at ua.nanit.limbo.connection.pipeline.PacketDecoder.decode(PacketDecoder.java:57)
        at ua.nanit.limbo.connection.pipeline.PacketDecoder.decode(PacketDecoder.java:31)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:88)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
        at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:333)
        at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:454)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800)
        at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:499)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:397)
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.base/java.lang.Thread.run(Thread.java:833)
Nan1t commented 1 year ago

Yes, it supports 1.7.2+ as the first full version (1.7 and 1.7.1 are pre-release). 1.6.4 and below use different protocol format, so we can't just check its protocol version number and say that this version is unsupported. You should prevent it on the proxy server side.