mirror of
https://github.com/SpigotMC/BungeeCord.git
synced 2024-12-25 10:07:38 +01:00
Stab in dark at forge + more client mod support.
This commit is contained in:
parent
6b984e052d
commit
96a5287e5b
@ -3,6 +3,8 @@ package net.md_5.bungee;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Socket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.crypto.SecretKey;
|
||||
import net.md_5.bungee.packet.Packet2Handshake;
|
||||
import net.md_5.bungee.packet.PacketFCEncryptionResponse;
|
||||
@ -66,14 +68,14 @@ public class InitialHandler implements Runnable
|
||||
out.write(new PacketFCEncryptionResponse().getPacket());
|
||||
in = new PacketInputStream(new CipherInputStream(socket.getInputStream(), EncryptionUtil.getCipher(false, shared)));
|
||||
out = new CipherOutputStream(socket.getOutputStream(), EncryptionUtil.getCipher(true, shared));
|
||||
|
||||
int ciphId = Util.getId(in.readPacket());
|
||||
if (ciphId != 0xCD)
|
||||
List<byte[]> customPackets = new ArrayList<>();
|
||||
byte[] custom;
|
||||
while (Util.getId((custom = in.readPacket())) != 0xCD)
|
||||
{
|
||||
throw new KickException("Unable to receive encrypted client status");
|
||||
customPackets.add(custom);
|
||||
}
|
||||
|
||||
UserConnection userCon = new UserConnection(socket, in, out, handshake);
|
||||
UserConnection userCon = new UserConnection(socket, in, out, handshake, customPackets);
|
||||
userCon.connect(BungeeCord.instance.config.getServer(handshake.username, handshake.host));
|
||||
break;
|
||||
case 0xFE:
|
||||
|
@ -32,7 +32,7 @@ public class ServerConnection extends GenericConnection
|
||||
this.loginPacket = loginPacket;
|
||||
}
|
||||
|
||||
public static ServerConnection connect(String name, InetSocketAddress address, Packet2Handshake handshake, boolean retry)
|
||||
public static ServerConnection connect(UserConnection user, String name, InetSocketAddress address, Packet2Handshake handshake, boolean retry)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -61,6 +61,11 @@ public class ServerConnection extends GenericConnection
|
||||
in = new PacketInputStream(new CipherInputStream(socket.getInputStream(), EncryptionUtil.getCipher(false, myKey)));
|
||||
out = new CipherOutputStream(out, EncryptionUtil.getCipher(true, myKey));
|
||||
|
||||
for (byte[] custom : user.loginPackets)
|
||||
{
|
||||
out.write(custom);
|
||||
}
|
||||
|
||||
out.write(new PacketCDClientStatus((byte) 0).getPacket());
|
||||
byte[] loginResponse = in.readPacket();
|
||||
if (Util.getId(loginResponse) == 0xFF)
|
||||
@ -79,7 +84,7 @@ public class ServerConnection extends GenericConnection
|
||||
InetSocketAddress def = BungeeCord.instance.config.getServer(null);
|
||||
if (retry && !address.equals(def))
|
||||
{
|
||||
return connect(name, def, handshake, false);
|
||||
return connect(user, name, def, handshake, false);
|
||||
} else
|
||||
{
|
||||
throw new RuntimeException("Could not connect to target server");
|
||||
|
@ -5,6 +5,8 @@ import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import net.md_5.bungee.command.CommandSender;
|
||||
@ -24,6 +26,7 @@ public class UserConnection extends GenericConnection implements CommandSender
|
||||
|
||||
public final Packet2Handshake handshake;
|
||||
public Queue<DefinedPacket> packetQueue = new ConcurrentLinkedQueue<>();
|
||||
public List<byte[]> loginPackets = new ArrayList<>();
|
||||
private ServerConnection server;
|
||||
private UpstreamBridge upBridge;
|
||||
private DownstreamBridge downBridge;
|
||||
@ -36,11 +39,12 @@ public class UserConnection extends GenericConnection implements CommandSender
|
||||
private long pingTime;
|
||||
private int ping;
|
||||
|
||||
public UserConnection(Socket socket, PacketInputStream in, OutputStream out, Packet2Handshake handshake)
|
||||
public UserConnection(Socket socket, PacketInputStream in, OutputStream out, Packet2Handshake handshake, List<byte[]> loginPackets)
|
||||
{
|
||||
super(socket, in, out);
|
||||
this.handshake = handshake;
|
||||
username = handshake.username;
|
||||
this.loginPackets = loginPackets;
|
||||
BungeeCord.instance.connections.put(username, this);
|
||||
BungeeCord.instance.tabListHandler.onJoin(this);
|
||||
}
|
||||
@ -81,7 +85,7 @@ public class UserConnection extends GenericConnection implements CommandSender
|
||||
out.write(new Packet9Respawn((byte) -1, (byte) 0, (byte) 0, (short) 256, "DEFAULT").getPacket());
|
||||
}
|
||||
|
||||
ServerConnection newServer = ServerConnection.connect(name, serverAddr, handshake, server == null);
|
||||
ServerConnection newServer = ServerConnection.connect(this, name, serverAddr, handshake, server == null);
|
||||
if (server == null)
|
||||
{
|
||||
clientEntityId = newServer.loginPacket.entityId;
|
||||
|
Loading…
Reference in New Issue
Block a user