geforkt von Mirrors/Velocity
Merge branch 'dev/1.1.0' into decode-multiple
Dieser Commit ist enthalten in:
Commit
042a9df4f1
@ -3,5 +3,6 @@ package com.velocitypowered.proxy.config;
|
|||||||
public enum PlayerInfoForwarding {
|
public enum PlayerInfoForwarding {
|
||||||
NONE,
|
NONE,
|
||||||
LEGACY,
|
LEGACY,
|
||||||
|
BUNGEEGUARD,
|
||||||
MODERN
|
MODERN
|
||||||
}
|
}
|
||||||
|
@ -65,18 +65,21 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
|
|||||||
@Comment({
|
@Comment({
|
||||||
"Should we forward IP addresses and other data to backend servers?",
|
"Should we forward IP addresses and other data to backend servers?",
|
||||||
"Available options:",
|
"Available options:",
|
||||||
"- \"none\": No forwarding will be done. All players will appear to be connecting from the",
|
"- \"none\": No forwarding will be done. All players will appear to be connecting",
|
||||||
" proxy and will have offline-mode UUIDs.",
|
" from the proxy and will have offline-mode UUIDs.",
|
||||||
"- \"legacy\": Forward player IPs and UUIDs in a BungeeCord-compatible format. Use this if",
|
"- \"legacy\": Forward player IPs and UUIDs in a BungeeCord-compatible format. Use this",
|
||||||
" you run servers using Minecraft 1.12 or lower.",
|
" if you run servers using Minecraft 1.12 or lower.",
|
||||||
"- \"modern\": Forward player IPs and UUIDs as part of the login process using Velocity's ",
|
"- \"bungeeguard\": Forward player IPs and UUIDs in a format supported by the BungeeGuard",
|
||||||
" native forwarding. Only applicable for Minecraft 1.13 or higher."
|
" plugin. Use this if you run servers using Minecraft 1.12 or lower, and are",
|
||||||
|
" unable to implement network level firewalling (on a shared host).",
|
||||||
|
"- \"modern\": Forward player IPs and UUIDs as part of the login process using",
|
||||||
|
" Velocity's native forwarding. Only applicable for Minecraft 1.13 or higher."
|
||||||
})
|
})
|
||||||
@ConfigKey("player-info-forwarding-mode")
|
@ConfigKey("player-info-forwarding-mode")
|
||||||
private PlayerInfoForwarding playerInfoForwardingMode = PlayerInfoForwarding.NONE;
|
private PlayerInfoForwarding playerInfoForwardingMode = PlayerInfoForwarding.NONE;
|
||||||
|
|
||||||
@StringAsBytes
|
@StringAsBytes
|
||||||
@Comment("If you are using modern IP forwarding, configure an unique secret here.")
|
@Comment("If you are using modern or BungeeGuard IP forwarding, configure an unique secret here.")
|
||||||
@ConfigKey("forwarding-secret")
|
@ConfigKey("forwarding-secret")
|
||||||
private byte[] forwardingSecret = generateRandomString(12).getBytes(StandardCharsets.UTF_8);
|
private byte[] forwardingSecret = generateRandomString(12).getBytes(StandardCharsets.UTF_8);
|
||||||
|
|
||||||
@ -193,6 +196,7 @@ public class VelocityConfiguration extends AnnotatedConfig implements ProxyConfi
|
|||||||
+ "from the proxy and will have offline-mode UUIDs.");
|
+ "from the proxy and will have offline-mode UUIDs.");
|
||||||
break;
|
break;
|
||||||
case MODERN:
|
case MODERN:
|
||||||
|
case BUNGEEGUARD:
|
||||||
if (forwardingSecret == null || forwardingSecret.length == 0) {
|
if (forwardingSecret == null || forwardingSecret.length == 0) {
|
||||||
logger.error("You don't have a forwarding secret set. This is required for security.");
|
logger.error("You don't have a forwarding secret set. This is required for security.");
|
||||||
valid = false;
|
valid = false;
|
||||||
|
@ -5,10 +5,12 @@ import static com.velocitypowered.proxy.connection.forge.legacy.LegacyForgeConst
|
|||||||
import static com.velocitypowered.proxy.network.Connections.HANDLER;
|
import static com.velocitypowered.proxy.network.Connections.HANDLER;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
import com.velocitypowered.api.proxy.server.ServerInfo;
|
import com.velocitypowered.api.proxy.server.ServerInfo;
|
||||||
|
import com.velocitypowered.api.util.GameProfile.Property;
|
||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
import com.velocitypowered.proxy.config.PlayerInfoForwarding;
|
||||||
import com.velocitypowered.proxy.connection.ConnectionTypes;
|
import com.velocitypowered.proxy.connection.ConnectionTypes;
|
||||||
@ -24,7 +26,10 @@ import com.velocitypowered.proxy.server.VelocityRegisteredServer;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.UnaryOperator;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
public class VelocityServerConnection implements MinecraftConnectionAssociation, ServerConnection {
|
public class VelocityServerConnection implements MinecraftConnectionAssociation, ServerConnection {
|
||||||
@ -88,7 +93,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createLegacyForwardingAddress() {
|
private String createLegacyForwardingAddress(UnaryOperator<List<Property>> propertiesTransform) {
|
||||||
// BungeeCord IP forwarding is simply a special injection after the "address" in the handshake,
|
// BungeeCord IP forwarding is simply a special injection after the "address" in the handshake,
|
||||||
// separated by \0 (the null byte). In order, you send the original host, the player's IP, their
|
// separated by \0 (the null byte). In order, you send the original host, the player's IP, their
|
||||||
// UUID (undashed), and if you are in online-mode, their login properties (from Mojang).
|
// UUID (undashed), and if you are in online-mode, their login properties (from Mojang).
|
||||||
@ -99,10 +104,24 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
.append('\0')
|
.append('\0')
|
||||||
.append(proxyPlayer.getGameProfile().getUndashedId())
|
.append(proxyPlayer.getGameProfile().getUndashedId())
|
||||||
.append('\0');
|
.append('\0');
|
||||||
GSON.toJson(proxyPlayer.getGameProfile().getProperties(), data);
|
GSON.toJson(propertiesTransform.apply(proxyPlayer.getGameProfile().getProperties()), data);
|
||||||
return data.toString();
|
return data.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String createLegacyForwardingAddress() {
|
||||||
|
return createLegacyForwardingAddress(UnaryOperator.identity());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String createBungeeGuardForwardingAddress(byte[] forwardingSecret) {
|
||||||
|
// Append forwarding secret as a BungeeGuard token.
|
||||||
|
Property property = new Property("bungeeguard-token",
|
||||||
|
new String(forwardingSecret, StandardCharsets.UTF_8), "");
|
||||||
|
return createLegacyForwardingAddress(properties -> ImmutableList.<Property>builder()
|
||||||
|
.addAll(properties)
|
||||||
|
.add(property)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
private void startHandshake() {
|
private void startHandshake() {
|
||||||
final MinecraftConnection mc = ensureConnected();
|
final MinecraftConnection mc = ensureConnected();
|
||||||
PlayerInfoForwarding forwardingMode = server.getConfiguration().getPlayerInfoForwardingMode();
|
PlayerInfoForwarding forwardingMode = server.getConfiguration().getPlayerInfoForwardingMode();
|
||||||
@ -114,6 +133,9 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
|||||||
handshake.setProtocolVersion(protocolVersion);
|
handshake.setProtocolVersion(protocolVersion);
|
||||||
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
|
if (forwardingMode == PlayerInfoForwarding.LEGACY) {
|
||||||
handshake.setServerAddress(createLegacyForwardingAddress());
|
handshake.setServerAddress(createLegacyForwardingAddress());
|
||||||
|
} else if (forwardingMode == PlayerInfoForwarding.BUNGEEGUARD) {
|
||||||
|
byte[] secret = server.getConfiguration().getForwardingSecret();
|
||||||
|
handshake.setServerAddress(createBungeeGuardForwardingAddress(secret));
|
||||||
} else if (proxyPlayer.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
|
} else if (proxyPlayer.getConnection().getType() == ConnectionTypes.LEGACY_FORGE) {
|
||||||
handshake.setServerAddress(handshake.getServerAddress() + HANDSHAKE_HOSTNAME_TOKEN);
|
handshake.setServerAddress(handshake.getServerAddress() + HANDSHAKE_HOSTNAME_TOKEN);
|
||||||
} else {
|
} else {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren