Check connected state before handling packets.

This commit is contained in:
md_5 2013-03-26 12:09:44 +11:00
parent dda49a9d05
commit 4044f7b7e0

View file

@ -1,4 +1,4 @@
From 6e754817948c35099c0c044f050fba777cb3efce Mon Sep 17 00:00:00 2001 From 02c3ccb6b9e24a0367962e7581015fc28fd5f053 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Thu, 14 Feb 2013 17:32:20 +1100 Date: Thu, 14 Feb 2013 17:32:20 +1100
Subject: [PATCH] Netty Subject: [PATCH] Netty
@ -42,14 +42,14 @@ Subject: [PATCH] Netty
.../net/minecraft/server/ThreadLoginVerifier.java | 1 + .../net/minecraft/server/ThreadLoginVerifier.java | 1 +
.../craftbukkit/scheduler/CraftScheduler.java | 2 +- .../craftbukkit/scheduler/CraftScheduler.java | 2 +-
src/main/java/org/spigotmc/netty/CipherCodec.java | 49 ++++ src/main/java/org/spigotmc/netty/CipherCodec.java | 49 ++++
.../org/spigotmc/netty/NettyNetworkManager.java | 233 +++++++++++++++++++ .../org/spigotmc/netty/NettyNetworkManager.java | 235 +++++++++++++++++++
.../org/spigotmc/netty/NettyServerConnection.java | 109 +++++++++ .../org/spigotmc/netty/NettyServerConnection.java | 109 +++++++++
.../org/spigotmc/netty/NettySocketAdaptor.java | 248 +++++++++++++++++++++ .../org/spigotmc/netty/NettySocketAdaptor.java | 248 +++++++++++++++++++++
.../java/org/spigotmc/netty/PacketDecoder.java | 64 ++++++ .../java/org/spigotmc/netty/PacketDecoder.java | 64 ++++++
.../java/org/spigotmc/netty/PacketEncoder.java | 43 ++++ .../java/org/spigotmc/netty/PacketEncoder.java | 43 ++++
.../java/org/spigotmc/netty/PacketListener.java | 100 +++++++++ .../java/org/spigotmc/netty/PacketListener.java | 100 +++++++++
src/main/java/org/spigotmc/netty/ReadState.java | 16 ++ src/main/java/org/spigotmc/netty/ReadState.java | 16 ++
18 files changed, 915 insertions(+), 9 deletions(-) 18 files changed, 917 insertions(+), 9 deletions(-)
create mode 100644 src/main/java/net/minecraft/server/INetworkManager.java create mode 100644 src/main/java/net/minecraft/server/INetworkManager.java
create mode 100644 src/main/java/org/spigotmc/netty/CipherCodec.java create mode 100644 src/main/java/org/spigotmc/netty/CipherCodec.java
create mode 100644 src/main/java/org/spigotmc/netty/NettyNetworkManager.java create mode 100644 src/main/java/org/spigotmc/netty/NettyNetworkManager.java
@ -313,10 +313,10 @@ index 0000000..54928b4
+} +}
diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
new file mode 100644 new file mode 100644
index 0000000..17776e6 index 0000000..f551bbe
--- /dev/null --- /dev/null
+++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java +++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
@@ -0,0 +1,233 @@ @@ -0,0 +1,235 @@
+package org.spigotmc.netty; +package org.spigotmc.netty;
+ +
+import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.google.common.util.concurrent.ThreadFactoryBuilder;
@ -412,21 +412,23 @@ index 0000000..17776e6
+ +
+ @Override + @Override
+ public void messageReceived(ChannelHandlerContext ctx, final Packet msg) throws Exception { + public void messageReceived(ChannelHandlerContext ctx, final Packet msg) throws Exception {
+ if (msg instanceof Packet252KeyResponse) { + if (connected) {
+ secret = ((Packet252KeyResponse) msg).a(key); + if (msg instanceof Packet252KeyResponse) {
+ } + secret = ((Packet252KeyResponse) msg).a(key);
+ }
+ +
+ if (msg.a_()) { + if (msg.a_()) {
+ threadPool.submit(new Runnable() { + threadPool.submit(new Runnable() {
+ public void run() { + public void run() {
+ Packet packet = PacketListener.callReceived(NettyNetworkManager.this, connection, msg); + Packet packet = PacketListener.callReceived(NettyNetworkManager.this, connection, msg);
+ if (packet != null) { + if (packet != null) {
+ packet.handle(connection); + packet.handle(connection);
+ }
+ } + }
+ } + });
+ }); + } else {
+ } else { + syncPackets.add(msg);
+ syncPackets.add(msg); + }
+ } + }
+ } + }
+ +