Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Backport IPv6 modern forwarding fix to Velocity 1.0.x
Dieser Commit ist enthalten in:
Ursprung
8238865bbe
Commit
b14e7e651e
@ -21,6 +21,7 @@ import com.velocitypowered.proxy.protocol.packet.SetCompression;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@ -62,7 +63,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
response.setSuccess(true);
|
||||
response.setId(packet.getId());
|
||||
response.setData(createForwardingData(configuration.getForwardingSecret(),
|
||||
serverConn.getPlayer().getRemoteAddress().getHostString(),
|
||||
cleanRemoteAddress(serverConn.getPlayer().getRemoteAddress()),
|
||||
serverConn.getPlayer().getGameProfile()));
|
||||
mc.write(response);
|
||||
informationForwarded = true;
|
||||
@ -123,6 +124,16 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
||||
.completeExceptionally(new IOException("Unexpectedly disconnected from remote server"));
|
||||
}
|
||||
|
||||
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 dataToForward = Unpooled.buffer();
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren