13
0
geforkt von Mirrors/Velocity

Clean up FML/handshake stuff from virtual host.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-10-13 02:34:53 -04:00
Ursprung 2f0ba42fa0
Commit 33f333d8cc
2 geänderte Dateien mit 10 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -61,7 +61,7 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
@Override @Override
public boolean handle(Handshake handshake) { public boolean handle(Handshake handshake) {
InitialInboundConnection ic = new InitialInboundConnection(connection, handshake); InitialInboundConnection ic = new InitialInboundConnection(connection, cleanVhost(handshake.getServerAddress()), handshake);
switch (handshake.getNextStatus()) { switch (handshake.getNextStatus()) {
case StateRegistry.STATUS_ID: case StateRegistry.STATUS_ID:
connection.setState(StateRegistry.STATUS); connection.setState(StateRegistry.STATUS);
@ -109,6 +109,11 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
} }
} }
private String cleanVhost(String hostname) {
int zeroIdx = hostname.indexOf('\0');
return zeroIdx == -1 ? hostname : hostname.substring(0, zeroIdx);
}
@Override @Override
public void handleGeneric(MinecraftPacket packet) { public void handleGeneric(MinecraftPacket packet) {

Datei anzeigen

@ -9,10 +9,12 @@ import java.util.Optional;
class InitialInboundConnection implements InboundConnection { class InitialInboundConnection implements InboundConnection {
private final MinecraftConnection connection; private final MinecraftConnection connection;
private final String cleanedAddress;
private final Handshake handshake; private final Handshake handshake;
InitialInboundConnection(MinecraftConnection connection, Handshake handshake) { InitialInboundConnection(MinecraftConnection connection, String cleanedAddress, Handshake handshake) {
this.connection = connection; this.connection = connection;
this.cleanedAddress = cleanedAddress;
this.handshake = handshake; this.handshake = handshake;
} }
@ -23,7 +25,7 @@ class InitialInboundConnection implements InboundConnection {
@Override @Override
public Optional<InetSocketAddress> getVirtualHost() { public Optional<InetSocketAddress> getVirtualHost() {
return Optional.of(InetSocketAddress.createUnresolved(handshake.getServerAddress(), handshake.getPort())); return Optional.of(InetSocketAddress.createUnresolved(cleanedAddress, handshake.getPort()));
} }
@Override @Override