Clean up FML/handshake stuff from virtual host.
This commit is contained in:
@@ -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) {
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user