geforkt von Mirrors/Velocity
Fix modern forwarding if a user connects over IPv6(?!?)
You don't see this every day...
Dieser Commit ist enthalten in:
Ursprung
f58b78e896
Commit
7fea1c4cb2
@ -20,6 +20,7 @@ import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
|||||||
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
import com.velocitypowered.proxy.util.except.QuietRuntimeException;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@ -58,7 +59,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && packet
|
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && packet
|
||||||
.getChannel().equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) {
|
.getChannel().equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) {
|
||||||
ByteBuf forwardingData = createForwardingData(configuration.getForwardingSecret(),
|
ByteBuf forwardingData = createForwardingData(configuration.getForwardingSecret(),
|
||||||
serverConn.getPlayer().getRemoteAddress().getHostString(),
|
cleanRemoteAddress(serverConn.getPlayer().getRemoteAddress()),
|
||||||
serverConn.getPlayer().getGameProfile());
|
serverConn.getPlayer().getGameProfile());
|
||||||
LoginPluginResponse response = new LoginPluginResponse(packet.getId(), true, forwardingData);
|
LoginPluginResponse response = new LoginPluginResponse(packet.getId(), true, forwardingData);
|
||||||
mc.write(response);
|
mc.write(response);
|
||||||
@ -127,6 +128,16 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String cleanRemoteAddress(InetSocketAddress address) {
|
||||||
|
String addressString = address.getAddress().getHostAddress();
|
||||||
|
int ipv6ScopeIdx = addressString.indexOf('%');
|
||||||
|
if (ipv6ScopeIdx == -1) {
|
||||||
|
return addressString;
|
||||||
|
} else {
|
||||||
|
return addressString.substring(0, ipv6ScopeIdx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static ByteBuf createForwardingData(byte[] hmacSecret, String address,
|
private static ByteBuf createForwardingData(byte[] hmacSecret, String address,
|
||||||
GameProfile profile) {
|
GameProfile profile) {
|
||||||
ByteBuf forwarded = Unpooled.buffer(2048);
|
ByteBuf forwarded = Unpooled.buffer(2048);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren