3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

expose raw vhost

Dieser Commit ist enthalten in:
Isaac - The456 2024-09-01 23:07:46 +01:00
Ursprung 46f29480bd
Commit 4da28a167a
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 57A848D2F87C14EF
6 geänderte Dateien mit 34 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -26,11 +26,20 @@ public interface InboundConnection {
/**
* Returns the hostname that the user entered into the client, if applicable.
*
* <br/>
* This is partially processed, including removing a trailing dot, and discarding data after a null byte.
* @return the hostname from the client
*/
Optional<InetSocketAddress> getVirtualHost();
/**
* Returns the raw hostname that the client sent, if applicable.
*
* @return the raw hostname from the client
*/
Optional<String> getRawVirtualHost();
/**
* Determine whether or not the player remains online.
*

Datei anzeigen

@ -96,7 +96,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
// Initiate a regular connection and move over to it.
ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(),
mcConnection, inbound.getVirtualHost().orElse(null), onlineMode,
mcConnection, inbound.getVirtualHost().orElse(null), inbound.getRawVirtualHost().orElse(null), onlineMode,
inbound.getIdentifiedKey());
this.connectedPlayer = player;
if (!server.canRegisterConnection(player)) {

Datei anzeigen

@ -155,6 +155,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
*/
private final MinecraftConnection connection;
private final @Nullable InetSocketAddress virtualHost;
private final @Nullable String rawVirtualHost;
private GameProfile profile;
private PermissionFunction permissionFunction;
private int tryIndex = 0;
@ -191,12 +192,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
private final ChatBuilderFactory chatBuilderFactory;
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
@Nullable InetSocketAddress virtualHost, boolean onlineMode,
@Nullable InetSocketAddress virtualHost, @Nullable String rawVirtualHost, boolean onlineMode,
@Nullable IdentifiedKey playerKey) {
this.server = server;
this.profile = profile;
this.connection = connection;
this.virtualHost = virtualHost;
this.rawVirtualHost = rawVirtualHost;
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
this.connectionPhase = connection.getType().getInitialClientPhase();
this.onlineMode = onlineMode;
@ -356,6 +358,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
return Optional.ofNullable(virtualHost);
}
@Override
public Optional<String> getRawVirtualHost() {
return Optional.ofNullable(rawVirtualHost);
}
void setPermissionFunction(PermissionFunction permissionFunction) {
this.permissionFunction = permissionFunction;
}

Datei anzeigen

@ -243,6 +243,11 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
return Optional.ofNullable(ping.getVhost());
}
@Override
public Optional<String> getRawVirtualHost() {
return getVirtualHost().map(InetSocketAddress::getHostName);
}
@Override
public boolean isActive() {
return !connection.isClosed();

Datei anzeigen

@ -63,6 +63,11 @@ public final class InitialInboundConnection implements VelocityInboundConnection
return Optional.of(InetSocketAddress.createUnresolved(cleanedAddress, handshake.getPort()));
}
@Override
public Optional<String> getRawVirtualHost() {
return Optional.of(handshake.getServerAddress());
}
@Override
public boolean isActive() {
return connection.getChannel().isActive();

Datei anzeigen

@ -71,6 +71,11 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
return delegate.getVirtualHost();
}
@Override
public Optional<String> getRawVirtualHost() {
return delegate.getRawVirtualHost();
}
@Override
public boolean isActive() {
return delegate.isActive();