Add pending connects for bad plugin message based connects

This commit is contained in:
md_5 2013-04-13 09:49:08 +10:00
parent a57ae83d62
commit dac259933b
2 changed files with 14 additions and 1 deletions

View File

@ -131,6 +131,7 @@ public class ServerConnector extends PacketHandler
// Remove from old servers // Remove from old servers
user.getServer().setObsolete( true ); user.getServer().setObsolete( true );
user.getServer().disconnect( "Quitting" ); user.getServer().disconnect( "Quitting" );
user.pendingConnects.remove( target );
} }
// TODO: Fix this? // TODO: Fix this?

View File

@ -12,8 +12,10 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
@ -65,6 +67,7 @@ public final class UserConnection implements ProxiedPlayer
private final Object switchMutex = new Object(); private final Object switchMutex = new Object();
public PacketCCSettings settings; public PacketCCSettings settings;
public final Scoreboard serverSentScoreboard = new Scoreboard(); public final Scoreboard serverSentScoreboard = new Scoreboard();
public final Set<ServerInfo> pendingConnects = new HashSet<>();
public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages) public UserConnection(BungeeCord bungee, Channel channel, PendingConnection pendingConnection, Packet2Handshake handshake, Packet1Login forgeLogin, List<PacketFAPluginMessage> loginMessages)
{ {
@ -121,6 +124,13 @@ public final class UserConnection implements ProxiedPlayer
sendMessage( ChatColor.RED + "Cannot connect to server you are already on!" ); sendMessage( ChatColor.RED + "Cannot connect to server you are already on!" );
return; return;
} }
if ( pendingConnects.contains( target ) )
{
sendMessage( ChatColor.RED + "Already connecting to this server!" );
return;
}
pendingConnects.add( target );
new Bootstrap() new Bootstrap()
.channel( NioSocketChannel.class ) .channel( NioSocketChannel.class )
@ -144,6 +154,8 @@ public final class UserConnection implements ProxiedPlayer
if ( !future.isSuccess() ) if ( !future.isSuccess() )
{ {
future.channel().close(); future.channel().close();
pendingConnects.remove( target );
ServerInfo def = ProxyServer.getInstance().getServers().get( getPendingConnection().getListener().getFallbackServer() ); ServerInfo def = ProxyServer.getInstance().getServers().get( getPendingConnection().getListener().getFallbackServer() );
if ( retry & target != def && ( getServer() == null || def != getServer().getInfo() ) ) if ( retry & target != def && ( getServer() == null || def != getServer().getInfo() ) )
{ {