Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Fix IPv6 scope issue in legacy forwarding too
Dieser Commit ist enthalten in:
Ursprung
484687522d
Commit
0097359a99
@ -73,10 +73,10 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
public boolean handle(LoginPluginMessage packet) {
|
||||
MinecraftConnection mc = serverConn.ensureConnected();
|
||||
VelocityConfiguration configuration = server.getConfiguration();
|
||||
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN && packet
|
||||
.getChannel().equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) {
|
||||
if (configuration.getPlayerInfoForwardingMode() == PlayerInfoForwarding.MODERN
|
||||
&& packet.getChannel().equals(VelocityConstants.VELOCITY_IP_FORWARDING_CHANNEL)) {
|
||||
ByteBuf forwardingData = createForwardingData(configuration.getForwardingSecret(),
|
||||
cleanRemoteAddress(serverConn.getPlayer().getRemoteAddress()),
|
||||
serverConn.getPlayerRemoteAddressAsString(),
|
||||
serverConn.getPlayer().getGameProfile());
|
||||
LoginPluginResponse response = new LoginPluginResponse(packet.getId(), true, forwardingData);
|
||||
mc.write(response);
|
||||
@ -145,16 +145,6 @@ 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,
|
||||
GameProfile profile) {
|
||||
ByteBuf forwarded = Unpooled.buffer(2048);
|
||||
|
@ -113,6 +113,16 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
return result;
|
||||
}
|
||||
|
||||
String getPlayerRemoteAddressAsString() {
|
||||
final String addr = proxyPlayer.getRemoteAddress().getAddress().getHostAddress();
|
||||
int ipv6ScopeIdx = addr.indexOf('%');
|
||||
if (ipv6ScopeIdx == -1) {
|
||||
return addr;
|
||||
} else {
|
||||
return addr.substring(0, ipv6ScopeIdx);
|
||||
}
|
||||
}
|
||||
|
||||
private String createLegacyForwardingAddress(UnaryOperator<List<Property>> propertiesTransform) {
|
||||
// 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
|
||||
@ -122,7 +132,7 @@ public class VelocityServerConnection implements MinecraftConnectionAssociation,
|
||||
.orElseGet(() -> registeredServer.getServerInfo().getAddress())
|
||||
.getHostString())
|
||||
.append('\0')
|
||||
.append(proxyPlayer.getRemoteAddress().getAddress().getHostAddress())
|
||||
.append(getPlayerRemoteAddressAsString())
|
||||
.append('\0')
|
||||
.append(proxyPlayer.getGameProfile().getUndashedId())
|
||||
.append('\0');
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren