Done with the proxy to client part. Now we just need the proxy to server part.

This commit is contained in:
md_5 2013-10-11 21:40:23 +11:00
parent dbdae87ec6
commit b358fd25f5

View File

@ -1,8 +1,6 @@
package net.md_5.bungee.connection; package net.md_5.bungee.connection;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -40,7 +38,6 @@ import net.md_5.bungee.netty.PipelineUtils;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.packet.Login; import net.md_5.bungee.protocol.packet.Login;
import net.md_5.bungee.protocol.packet.Handshake; import net.md_5.bungee.protocol.packet.Handshake;
import net.md_5.bungee.protocol.packet.ClientStatus;
import net.md_5.bungee.protocol.packet.PluginMessage; import net.md_5.bungee.protocol.packet.PluginMessage;
import net.md_5.bungee.protocol.packet.EncryptionResponse; import net.md_5.bungee.protocol.packet.EncryptionResponse;
import net.md_5.bungee.protocol.packet.EncryptionRequest; import net.md_5.bungee.protocol.packet.EncryptionRequest;
@ -93,7 +90,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
private enum State private enum State
{ {
HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, LOGIN, FINISHED; HANDSHAKE, STATUS, PING, USERNAME, ENCRYPT, FINISHED;
} }
@Override @Override
@ -320,7 +317,6 @@ public class InitialHandler extends PacketHandler implements PendingConnection
{ {
return; return;
} }
thisState = InitialHandler.State.LOGIN;
ch.getHandle().eventLoop().execute( new Runnable() ch.getHandle().eventLoop().execute( new Runnable()
{ {
@ -332,7 +328,7 @@ public class InitialHandler extends PacketHandler implements PendingConnection
if ( onlineMode ) if ( onlineMode )
{ {
unsafe().sendPacket( new EncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) ); // unsafe().sendPacket( new EncryptionResponse( new byte[ 0 ], new byte[ 0 ] ) );
try try
{ {
Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey ); Cipher encrypt = EncryptionUtil.getCipher( Cipher.ENCRYPT_MODE, sharedKey );
@ -349,22 +345,8 @@ public class InitialHandler extends PacketHandler implements PendingConnection
} }
unsafe.sendPacket( new LoginSuccess( BungeeCord.getInstance().gson.toJson( new LoginResult( UUID ) ) ) ); unsafe.sendPacket( new LoginSuccess( BungeeCord.getInstance().gson.toJson( new LoginResult( UUID ) ) ) );
ch.setProtocol( Protocol.GAME ); ch.setProtocol( Protocol.GAME );
}
}
} );
}
};
// fire login event UserConnection userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
}
@Override
public void handle(ClientStatus clientStatus) throws Exception
{
Preconditions.checkState( thisState == State.LOGIN, "Not expecting LOGIN" );
UserConnection userCon = new UserConnection( bungee, ch, getName(), this );
userCon.init(); userCon.init();
bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) ); bungee.getPluginManager().callEvent( new PostLoginEvent( userCon ) );
@ -377,12 +359,19 @@ public class InitialHandler extends PacketHandler implements PendingConnection
server = bungee.getReconnectHandler().getServer( userCon ); server = bungee.getReconnectHandler().getServer( userCon );
} else } else
{ {
server = AbstractReconnectHandler.getForcedHost( this ); server = AbstractReconnectHandler.getForcedHost( InitialHandler.this );
} }
userCon.connect( server, true ); userCon.connect( server, true );
thisState = State.FINISHED; thisState = State.FINISHED;
throw new CancelSendSignal(); }
}
} );
}
};
// fire login event
bungee.getPluginManager().callEvent( new LoginEvent( InitialHandler.this, complete ) );
} }
@Override @Override