13
0
geforkt von Mirrors/Velocity
Dieser Commit ist enthalten in:
Andrew Steinborn 2018-12-30 03:57:05 -05:00
Ursprung 9ce4294e6e
Commit 5bf936d1b9
2 geänderte Dateien mit 40 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -138,8 +138,15 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
}
}
private String cleanVhost(String hostname) {
// Clean out any anything after any zero byte
/**
* Cleans the specified virtual host hostname.
*
* @param hostname the host name to clean
* @return the cleaned hostname
*/
static String cleanVhost(String hostname) {
// Clean out any anything after any zero bytes (this includes BungeeCord forwarding and the
// legacy Forge handshake indicator).
String cleaned = hostname;
int zeroIdx = cleaned.indexOf('\0');
if (zeroIdx > -1) {

Datei anzeigen

@ -0,0 +1,31 @@
package com.velocitypowered.proxy.connection.client;
import static com.velocitypowered.proxy.connection.client.HandshakeSessionHandler.cleanVhost;
import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants.*;
import static org.junit.jupiter.api.Assertions.*;
import com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConstants;
import org.junit.jupiter.api.Test;
class HandshakeSessionHandlerTest {
@Test
void cleanVhostHandlesGoodHostname() {
assertEquals("localhost", cleanVhost("localhost"));
}
@Test
void cleanVhostHandlesTrailingOctet() {
assertEquals("localhost", cleanVhost("localhost."));
}
@Test
void cleanVhostHandlesForge() {
assertEquals("localhost", cleanVhost("localhost" + HANDSHAKE_HOSTNAME_TOKEN));
}
@Test
void cleanVhostHandlesOctetsAndForge() {
assertEquals("localhost", cleanVhost("localhost." + HANDSHAKE_HOSTNAME_TOKEN));
}
}