Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-09-08 20:43:04 +02:00
Add option to forward the connection hostname over to the remote server (#2149)
Co-authored-by: Camotoy <20743703+Camotoy@users.noreply.github.com>
Dieser Commit ist enthalten in:
Ursprung
bb41c0f9ee
Commit
f0a002f0e3
@ -138,6 +138,8 @@ public interface GeyserConfiguration {
|
|||||||
boolean isPasswordAuthentication();
|
boolean isPasswordAuthentication();
|
||||||
|
|
||||||
boolean isUseProxyProtocol();
|
boolean isUseProxyProtocol();
|
||||||
|
|
||||||
|
boolean isForwardHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IUserAuthenticationInfo {
|
interface IUserAuthenticationInfo {
|
||||||
|
@ -197,6 +197,9 @@ public abstract class GeyserJacksonConfiguration implements GeyserConfiguration
|
|||||||
|
|
||||||
@JsonProperty("use-proxy-protocol")
|
@JsonProperty("use-proxy-protocol")
|
||||||
private boolean useProxyProtocol = false;
|
private boolean useProxyProtocol = false;
|
||||||
|
|
||||||
|
@JsonProperty("forward-hostname")
|
||||||
|
private boolean forwardHost = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -693,26 +693,41 @@ public class GeyserSession implements CommandSender {
|
|||||||
@Override
|
@Override
|
||||||
public void packetSending(PacketSendingEvent event) {
|
public void packetSending(PacketSendingEvent event) {
|
||||||
//todo move this somewhere else
|
//todo move this somewhere else
|
||||||
if (event.getPacket() instanceof HandshakePacket && floodgate) {
|
if (event.getPacket() instanceof HandshakePacket) {
|
||||||
String encrypted = "";
|
String addressSuffix;
|
||||||
try {
|
if (floodgate) {
|
||||||
encrypted = EncryptionUtil.encryptBedrockData(publicKey, new BedrockData(
|
String encrypted = "";
|
||||||
clientData.getGameVersion(),
|
try {
|
||||||
authData.getName(),
|
encrypted = EncryptionUtil.encryptBedrockData(publicKey, new BedrockData(
|
||||||
authData.getXboxUUID(),
|
clientData.getGameVersion(),
|
||||||
clientData.getDeviceOS().ordinal(),
|
authData.getName(),
|
||||||
clientData.getLanguageCode(),
|
authData.getXboxUUID(),
|
||||||
clientData.getCurrentInputMode().ordinal(),
|
clientData.getDeviceOS().ordinal(),
|
||||||
upstream.getAddress().getAddress().getHostAddress()
|
clientData.getLanguageCode(),
|
||||||
));
|
clientData.getCurrentInputMode().ordinal(),
|
||||||
} catch (Exception e) {
|
upstream.getAddress().getAddress().getHostAddress()
|
||||||
connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.auth.floodgate.encrypt_fail"), e);
|
));
|
||||||
|
} catch (Exception e) {
|
||||||
|
connector.getLogger().error(LanguageUtils.getLocaleStringLog("geyser.auth.floodgate.encrypt_fail"), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
addressSuffix = '\0' + BedrockData.FLOODGATE_IDENTIFIER + '\0' + encrypted;
|
||||||
|
} else {
|
||||||
|
addressSuffix = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
HandshakePacket handshakePacket = event.getPacket();
|
HandshakePacket handshakePacket = event.getPacket();
|
||||||
|
|
||||||
|
String address;
|
||||||
|
if (connector.getConfig().getRemote().isForwardHost()) {
|
||||||
|
address = clientData.getServerAddress().split(":")[0];
|
||||||
|
} else {
|
||||||
|
address = handshakePacket.getHostname();
|
||||||
|
}
|
||||||
|
|
||||||
event.setPacket(new HandshakePacket(
|
event.setPacket(new HandshakePacket(
|
||||||
handshakePacket.getProtocolVersion(),
|
handshakePacket.getProtocolVersion(),
|
||||||
handshakePacket.getHostname() + '\0' + BedrockData.FLOODGATE_IDENTIFIER + '\0' + encrypted,
|
address + addressSuffix,
|
||||||
handshakePacket.getPort(),
|
handshakePacket.getPort(),
|
||||||
handshakePacket.getIntent()
|
handshakePacket.getIntent()
|
||||||
));
|
));
|
||||||
|
@ -53,6 +53,9 @@ remote:
|
|||||||
# 2) You run Velocity or BungeeCord with the option enabled in the proxy's main config.
|
# 2) You run Velocity or BungeeCord with the option enabled in the proxy's main config.
|
||||||
# IF YOU DON'T KNOW WHAT THIS IS, DON'T TOUCH IT!
|
# IF YOU DON'T KNOW WHAT THIS IS, DON'T TOUCH IT!
|
||||||
use-proxy-protocol: false
|
use-proxy-protocol: false
|
||||||
|
# Forward the hostname that the Bedrock client used to connect over to the Java server
|
||||||
|
# This is designed to be used for forced hosts on proxies
|
||||||
|
forward-hostname: false
|
||||||
|
|
||||||
# Floodgate uses encryption to ensure use from authorised sources.
|
# Floodgate uses encryption to ensure use from authorised sources.
|
||||||
# This should point to the public key generated by Floodgate (Bungee or CraftBukkit)
|
# This should point to the public key generated by Floodgate (Bungee or CraftBukkit)
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren