Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-06 08:10:12 +01:00
expose raw vhost (#1423)
Dieser Commit ist enthalten in:
Ursprung
ef1f5009d3
Commit
99aaf3ce4e
@ -26,11 +26,20 @@ public interface InboundConnection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the hostname that the user entered into the client, if applicable.
|
* 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
|
* @return the hostname from the client
|
||||||
*/
|
*/
|
||||||
Optional<InetSocketAddress> getVirtualHost();
|
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.
|
* Determine whether or not the player remains online.
|
||||||
*
|
*
|
||||||
|
@ -96,7 +96,7 @@ public class AuthSessionHandler implements MinecraftSessionHandler {
|
|||||||
|
|
||||||
// Initiate a regular connection and move over to it.
|
// Initiate a regular connection and move over to it.
|
||||||
ConnectedPlayer player = new ConnectedPlayer(server, profileEvent.getGameProfile(),
|
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());
|
inbound.getIdentifiedKey());
|
||||||
this.connectedPlayer = player;
|
this.connectedPlayer = player;
|
||||||
if (!server.canRegisterConnection(player)) {
|
if (!server.canRegisterConnection(player)) {
|
||||||
|
@ -155,6 +155,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
*/
|
*/
|
||||||
private final MinecraftConnection connection;
|
private final MinecraftConnection connection;
|
||||||
private final @Nullable InetSocketAddress virtualHost;
|
private final @Nullable InetSocketAddress virtualHost;
|
||||||
|
private final @Nullable String rawVirtualHost;
|
||||||
private GameProfile profile;
|
private GameProfile profile;
|
||||||
private PermissionFunction permissionFunction;
|
private PermissionFunction permissionFunction;
|
||||||
private int tryIndex = 0;
|
private int tryIndex = 0;
|
||||||
@ -191,12 +192,13 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
private final ChatBuilderFactory chatBuilderFactory;
|
private final ChatBuilderFactory chatBuilderFactory;
|
||||||
|
|
||||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
||||||
@Nullable InetSocketAddress virtualHost, boolean onlineMode,
|
@Nullable InetSocketAddress virtualHost, @Nullable String rawVirtualHost, boolean onlineMode,
|
||||||
@Nullable IdentifiedKey playerKey) {
|
@Nullable IdentifiedKey playerKey) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
this.virtualHost = virtualHost;
|
this.virtualHost = virtualHost;
|
||||||
|
this.rawVirtualHost = rawVirtualHost;
|
||||||
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
|
this.permissionFunction = PermissionFunction.ALWAYS_UNDEFINED;
|
||||||
this.connectionPhase = connection.getType().getInitialClientPhase();
|
this.connectionPhase = connection.getType().getInitialClientPhase();
|
||||||
this.onlineMode = onlineMode;
|
this.onlineMode = onlineMode;
|
||||||
@ -356,6 +358,11 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player,
|
|||||||
return Optional.ofNullable(virtualHost);
|
return Optional.ofNullable(virtualHost);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> getRawVirtualHost() {
|
||||||
|
return Optional.ofNullable(rawVirtualHost);
|
||||||
|
}
|
||||||
|
|
||||||
void setPermissionFunction(PermissionFunction permissionFunction) {
|
void setPermissionFunction(PermissionFunction permissionFunction) {
|
||||||
this.permissionFunction = permissionFunction;
|
this.permissionFunction = permissionFunction;
|
||||||
}
|
}
|
||||||
|
@ -243,6 +243,11 @@ public class HandshakeSessionHandler implements MinecraftSessionHandler {
|
|||||||
return Optional.ofNullable(ping.getVhost());
|
return Optional.ofNullable(ping.getVhost());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> getRawVirtualHost() {
|
||||||
|
return getVirtualHost().map(InetSocketAddress::getHostName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return !connection.isClosed();
|
return !connection.isClosed();
|
||||||
|
@ -63,6 +63,11 @@ public final class InitialInboundConnection implements VelocityInboundConnection
|
|||||||
return Optional.of(InetSocketAddress.createUnresolved(cleanedAddress, handshake.getPort()));
|
return Optional.of(InetSocketAddress.createUnresolved(cleanedAddress, handshake.getPort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> getRawVirtualHost() {
|
||||||
|
return Optional.of(handshake.getServerAddress());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return connection.getChannel().isActive();
|
return connection.getChannel().isActive();
|
||||||
|
@ -71,6 +71,11 @@ public class LoginInboundConnection implements LoginPhaseConnection, KeyIdentifi
|
|||||||
return delegate.getVirtualHost();
|
return delegate.getVirtualHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Optional<String> getRawVirtualHost() {
|
||||||
|
return delegate.getRawVirtualHost();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isActive() {
|
public boolean isActive() {
|
||||||
return delegate.isActive();
|
return delegate.isActive();
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren