Reinstate patch to prevent Kick during Handshake

Remove redundant patch from fire-pit
This commit is contained in:
Jamie Mansfield 2016-12-04 16:42:27 +00:00
parent 3a62539bb1
commit cbe6a1b3f5
No known key found for this signature in database
GPG Key ID: 27F6918C0D47DF94
10 changed files with 35 additions and 274 deletions

View File

@ -1,4 +1,4 @@
From b184d9c318f57c05d28cca0ce8724be2c3dd8187 Mon Sep 17 00:00:00 2001 From f2d863aa87a12f7611d7d1910597e41b89ce8c85 Mon Sep 17 00:00:00 2001
From: Tux <write@imaginarycode.com> From: Tux <write@imaginarycode.com>
Date: Thu, 19 May 2016 11:28:45 -0700 Date: Thu, 19 May 2016 11:28:45 -0700
Subject: [PATCH] Rename references from BungeeCord to Waterfall Subject: [PATCH] Rename references from BungeeCord to Waterfall
@ -114,5 +114,5 @@ index c7547c7..82ff91a 100644
InetSocketAddress address = Util.getAddr( addr ); InetSocketAddress address = Util.getAddr( addr );
ServerInfo info = ProxyServer.getInstance().constructServerInfo( name, address, motd, restricted ); ServerInfo info = ProxyServer.getInstance().constructServerInfo( name, address, motd, restricted );
-- --
2.7.4 (Apple Git-66) 2.10.0

View File

@ -0,0 +1,22 @@
From b3e9c9b6ba4a0bba0e697782a5412499909216dd Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@techcable.net>
Date: Mon, 6 Jun 2016 13:36:10 -0600
Subject: [PATCH] Don't send KICK packets while in HANDSHAKE state
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index bbad8dd..6ba098a 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -551,7 +551,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Override
public void run()
{
- if ( thisState != State.STATUS && thisState != State.PING )
+ if ( thisState != State.STATUS && thisState != State.PING && thisState != State.HANDSHAKE ) // Waterfall: Don't kick during handshake
{
unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
}
--
2.10.0

View File

@ -1,4 +1,4 @@
From 9f641cadaeec788313843c830cc4c2643b183316 Mon Sep 17 00:00:00 2001 From e072edbf35417eacae29526145e965f92db35ff6 Mon Sep 17 00:00:00 2001
From: Nathan Poirier <nathan@poirier.io> From: Nathan Poirier <nathan@poirier.io>
Date: Tue, 28 Jun 2016 23:00:49 -0500 Date: Tue, 28 Jun 2016 23:00:49 -0500
Subject: [PATCH] Improve ServerKickEvent Subject: [PATCH] Improve ServerKickEvent

View File

@ -1,4 +1,4 @@
From 167338d235ef25f4c143f6b26348485ef90ea9c6 Mon Sep 17 00:00:00 2001 From ef40f84049f7b8e335ca901484d48940b1894b56 Mon Sep 17 00:00:00 2001
From: Troy Frew <fuzzy_bot@arenaga.me> From: Troy Frew <fuzzy_bot@arenaga.me>
Date: Wed, 29 Jun 2016 13:56:57 -0500 Date: Wed, 29 Jun 2016 13:56:57 -0500
Subject: [PATCH] Configurable server version in ping response Subject: [PATCH] Configurable server version in ping response

View File

@ -1,4 +1,4 @@
From 8db3af1afef62b24256ad9d49dce060333b67a9d Mon Sep 17 00:00:00 2001 From 30ba27e5de5a18b6dada9d3b2591966ef0e3e1a4 Mon Sep 17 00:00:00 2001
From: Ichbinjoe <joe@ibj.io> From: Ichbinjoe <joe@ibj.io>
Date: Sat, 16 Jul 2016 20:44:01 -0400 Date: Sat, 16 Jul 2016 20:44:01 -0400
Subject: [PATCH] Add timeout variant to connect methods Subject: [PATCH] Add timeout variant to connect methods
@ -49,7 +49,7 @@ index 375815c..c49e900 100644
* Gets the server this player is connected to. * Gets the server this player is connected to.
* *
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index 81c2376..424830e 100644 index a5f0e15..bbe4f15 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -248,6 +248,12 @@ public final class UserConnection implements ProxiedPlayer @@ -248,6 +248,12 @@ public final class UserConnection implements ProxiedPlayer
@ -84,5 +84,5 @@ index 81c2376..424830e 100644
// Windows is bugged, multi homed users will just have to live with random connecting IPs // Windows is bugged, multi homed users will just have to live with random connecting IPs
if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() ) if ( getPendingConnection().getListener().isSetLocalAddress() && !PlatformDependent.isWindows() )
-- --
2.10.2 2.10.0

View File

@ -1,4 +1,4 @@
From dff3f58774e79f8e655813e21b0ea0d7c724e15b Mon Sep 17 00:00:00 2001 From 525fdfdfc386c3fb335f162ad1c665bd8406669d Mon Sep 17 00:00:00 2001
From: minecrafter <unknown@unknown> From: minecrafter <unknown@unknown>
Date: Sun, 3 Jul 2016 04:03:21 -0400 Date: Sun, 3 Jul 2016 04:03:21 -0400
Subject: [PATCH] Proxy query event Subject: [PATCH] Proxy query event

View File

@ -1,4 +1,4 @@
From e4d11ee967d8c4ece85697de3d5fb93de0358b37 Mon Sep 17 00:00:00 2001 From b3db0f96024f1974630abef51a25175b3c975027 Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@techcable.net> From: Techcable <Techcable@techcable.net>
Date: Thu, 4 Aug 2016 19:30:49 -0700 Date: Thu, 4 Aug 2016 19:30:49 -0700
Subject: [PATCH] Dump the raw hex of a packet on a decoding error Subject: [PATCH] Dump the raw hex of a packet on a decoding error

View File

@ -1,4 +1,4 @@
From 340eedc8b19ec16f1178d048dac9c866cb604616 Mon Sep 17 00:00:00 2001 From 9ff87b6b5620691cb02d7c1310209d3ead3f9eaf Mon Sep 17 00:00:00 2001
From: Aaron Hill <aa1ronham@gmail.com> From: Aaron Hill <aa1ronham@gmail.com>
Date: Thu, 15 Sep 2016 16:38:37 -0400 Date: Thu, 15 Sep 2016 16:38:37 -0400
Subject: [PATCH] Fix potion race condition on Forge 1.8.9 Subject: [PATCH] Fix potion race condition on Forge 1.8.9
@ -32,7 +32,7 @@ index 6f782c8..2d5fc48 100644
+ // Waterfall end + // Waterfall end
} }
diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java diff --git a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
index 4decbb2..f45737a 100644 index 8a857ad..741166d 100644
--- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java --- a/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
+++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java +++ b/protocol/src/main/java/net/md_5/bungee/protocol/Protocol.java
@@ -16,6 +16,8 @@ import net.md_5.bungee.protocol.packet.Chat; @@ -16,6 +16,8 @@ import net.md_5.bungee.protocol.packet.Chat;
@ -160,7 +160,7 @@ index 0000000..7ed2dc3
+ } + }
+} +}
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index 7e934ef..3f1b133 100644 index bbe4f15..9cc7f3f 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java --- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java +++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -2,7 +2,9 @@ package net.md_5.bungee; @@ -2,7 +2,9 @@ package net.md_5.bungee;
@ -185,7 +185,7 @@ index 7e934ef..3f1b133 100644
@Getter @Getter
private String displayName; private String displayName;
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java diff --git a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
index 2a1a719..4ce0e12 100644 index 356cf4f..cb0f08c 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java --- a/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java +++ b/proxy/src/main/java/net/md_5/bungee/connection/DownstreamBridge.java
@@ -31,6 +31,8 @@ import net.md_5.bungee.netty.PacketHandler; @@ -31,6 +31,8 @@ import net.md_5.bungee.netty.PacketHandler;

View File

@ -1,227 +0,0 @@
From 5ba2cf71ab80ed6699273c5124299e03effbbacf Mon Sep 17 00:00:00 2001
From: kamcio96 <k.nadworski@icloud.com>
Date: Mon, 14 Mar 2016 15:59:52 -0700
Subject: [PATCH] Improve connection closing, fixing the kick delay.
Merges some of https://github.com/SpigotMC/BungeeCord/pull/1706 by @kamcio96
@kamcio96 claims that these channel closing changes are removing the need of delayed kick packets
@Janmm14 can confirm this (at login state) on a no-latency and low-latency connection (<1ms; ~16ms), high-latency connection was not tested, but it should work on these too.
diff --git a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java
index 8c1260a..a7dfd1f 100644
--- a/proxy/src/main/java/net/md_5/bungee/ServerConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/ServerConnection.java
@@ -59,7 +59,7 @@ public class ServerConnection implements Server
@Override
public void run()
{
- ch.getHandle().close();
+ ch.close();
}
}, 100, TimeUnit.MILLISECONDS );
}
diff --git a/proxy/src/main/java/net/md_5/bungee/UserConnection.java b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
index c88ab49..9a13f5c 100644
--- a/proxy/src/main/java/net/md_5/bungee/UserConnection.java
+++ b/proxy/src/main/java/net/md_5/bungee/UserConnection.java
@@ -379,21 +379,7 @@ public final class UserConnection implements ProxiedPlayer
getName(), BaseComponent.toLegacyText( reason )
} );
- // Why do we have to delay this you might ask? Well the simple reason is MOJANG.
- // Despite many a bug report posted, ever since the 1.7 protocol rewrite, the client STILL has a race condition upon switching protocols.
- // As such, despite the protocol switch packets already having been sent, there is the possibility of a client side exception
- // To help combat this we will wait half a second before actually sending the disconnected packet so that whoever is on the other
- // end has a somewhat better chance of receiving the proper packet.
- ch.getHandle().eventLoop().schedule( new Runnable()
- {
-
- @Override
- public void run()
- {
- unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
- ch.close();
- }
- }, 500, TimeUnit.MILLISECONDS );
+ ch.close(new Kick(ComponentSerializer.toString( reason )));
if ( server != null )
{
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 323428b..9d139c6 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -8,6 +8,7 @@ import java.net.URLEncoder;
import java.security.MessageDigest;
import java.util.List;
import java.util.UUID;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import javax.crypto.SecretKey;
import com.google.gson.Gson;
@@ -96,12 +97,11 @@ public class InitialHandler extends PacketHandler implements PendingConnection
private boolean legacy;
@Getter
private String extraDataInHandshake = "";
- private boolean disconnecting;
+ private final AtomicBoolean disconnecting = new AtomicBoolean(false);
- @Override
public boolean shouldHandle(PacketWrapper packet) throws Exception
{
- return !disconnecting;
+ return !disconnecting.get();
}
private enum State
@@ -136,8 +136,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
public void handle(LegacyHandshake legacyHandshake) throws Exception
{
this.legacy = true;
- ch.getHandle().writeAndFlush( bungee.getTranslation( "outdated_client" ) );
- ch.close();
+ ch.close( bungee.getTranslation( "outdated_client" ) );
}
@Override
@@ -179,8 +178,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
+ '\u00a7' + legacy.getPlayers().getMax();
}
- ch.getHandle().writeAndFlush( kickMessage );
- ch.close();
+ ch.close( kickMessage );
}
};
@@ -251,8 +249,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if (!ACCEPT_INVALID_PACKETS) {
Preconditions.checkState(thisState == State.PING, "Not expecting PING");
}
- unsafe.sendPacket( ping );
- disconnect( "" );
+ ch.close( ping );
}
@Override
@@ -541,27 +538,13 @@ public class InitialHandler extends PacketHandler implements PendingConnection
@Override
public void disconnect(final BaseComponent... reason)
{
- if ( !disconnecting || !ch.isClosed() )
+ if ( !ch.isClosed() && disconnecting.compareAndSet(false, true) )
{
- disconnecting = true;
- // Why do we have to delay this you might ask? Well the simple reason is MOJANG.
- // Despite many a bug report posted, ever since the 1.7 protocol rewrite, the client STILL has a race condition upon switching protocols.
- // As such, despite the protocol switch packets already having been sent, there is the possibility of a client side exception
- // To help combat this we will wait half a second before actually sending the disconnected packet so that whoever is on the other
- // end has a somewhat better chance of receiving the proper packet.
- ch.getHandle().eventLoop().schedule( new Runnable()
- {
-
- @Override
- public void run()
- {
- if ( thisState != State.STATUS && thisState != State.PING )
- {
- unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
- }
- ch.close();
- }
- }, 500, TimeUnit.MILLISECONDS );
+ if ( thisState != State.STATUS && thisState != State.PING ) {
+ ch.close( new Kick( ComponentSerializer.toString( reason ) ) );
+ } else {
+ ch.close();
+ }
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
index 7439bbc..61be441 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/UpstreamBridge.java
@@ -78,6 +78,7 @@ public class UpstreamBridge extends PacketHandler
{
player.unsafe().sendPacket( packet );
}
+ con.getServer().setObsolete(true);
con.getServer().disconnect( "Quitting" );
}
}
diff --git a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
index 06d19c3..76bdff2 100644
--- a/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
+++ b/proxy/src/main/java/net/md_5/bungee/netty/ChannelWrapper.java
@@ -5,6 +5,7 @@ import net.md_5.bungee.compress.PacketDecompressor;
import net.md_5.bungee.protocol.PacketWrapper;
import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import lombok.Getter;
@@ -16,7 +17,6 @@ public class ChannelWrapper
{
private final Channel ch;
- @Getter
private volatile boolean closed;
public ChannelWrapper(ChannelHandlerContext ctx)
@@ -38,23 +38,22 @@ public class ChannelWrapper
public void write(Object packet)
{
- if ( !closed )
+ if ( !isClosed() )
{
if ( packet instanceof PacketWrapper )
{
( (PacketWrapper) packet ).setReleased( true );
- ch.write( ( (PacketWrapper) packet ).buf, ch.voidPromise() );
+ ch.writeAndFlush( ( (PacketWrapper) packet ).buf, ch.voidPromise() );
} else
{
- ch.write( packet, ch.voidPromise() );
+ ch.writeAndFlush( packet, ch.voidPromise() );
}
- ch.flush();
}
}
public void close()
{
- if ( !closed )
+ if ( !isClosed() )
{
closed = true;
ch.flush();
@@ -62,6 +61,22 @@ public class ChannelWrapper
}
}
+ /**
+ * Send the given packet, then close the connection
+ *
+ * @param packet the packet to send before closing
+ */
+ public void close(Object packet) {
+ if (!isClosed()) {
+ closed = true;
+ ch.writeAndFlush(packet).addListeners(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE, ChannelFutureListener.CLOSE);
+ }
+ }
+
+ public boolean isClosed() {
+ return closed || !ch.isActive();
+ }
+
public void addBefore(String baseName, String name, ChannelHandler handler)
{
Preconditions.checkState( ch.eventLoop().inEventLoop(), "cannot add handler outside of event loop" );
--
2.7.4

View File

@ -1,34 +0,0 @@
From 4167f0bdc2fc9c5937241e90f1e748d9af493f21 Mon Sep 17 00:00:00 2001
From: Techcable <Techcable@techcable.net>
Date: Mon, 6 Jun 2016 13:36:10 -0600
Subject: [PATCH] Don't send KICK packets while in HANDSHAKE state
Use a switch statement for checking the state (best practice when you have lots of cases)
diff --git a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
index 9d139c6..7a4c392 100644
--- a/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
+++ b/proxy/src/main/java/net/md_5/bungee/connection/InitialHandler.java
@@ -540,10 +540,15 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{
if ( !ch.isClosed() && disconnecting.compareAndSet(false, true) )
{
- if ( thisState != State.STATUS && thisState != State.PING ) {
- ch.close( new Kick( ComponentSerializer.toString( reason ) ) );
- } else {
- ch.close();
+ switch (thisState) {
+ default:
+ ch.close(new Kick(ComponentSerializer.toString(reason)));
+ break;
+ case STATUS:
+ case PING:
+ case HANDSHAKE:
+ ch.close();
+ break;
}
}
}
--
2.7.4