Disable BungeeCord player info passthrough by default

This commit is contained in:
RaphiMC 2024-06-23 21:40:33 +02:00
parent 71afdfa23d
commit ff5c8301c2
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
3 changed files with 24 additions and 1 deletions

View File

@ -69,6 +69,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
private final OptionSpec<Boolean> optionIgnoreProtocolTranslationErrors; private final OptionSpec<Boolean> optionIgnoreProtocolTranslationErrors;
private final OptionSpec<Boolean> optionSuppressClientProtocolErrors; private final OptionSpec<Boolean> optionSuppressClientProtocolErrors;
private final OptionSpec<Boolean> optionAllowLegacyClientPassthrough; private final OptionSpec<Boolean> optionAllowLegacyClientPassthrough;
private final OptionSpec<Boolean> optionBungeecordPlayerInfoPassthrough;
private final OptionSpec<String> optionCustomMotd; private final OptionSpec<String> optionCustomMotd;
private final OptionSpec<String> optionResourcePackUrl; private final OptionSpec<String> optionResourcePackUrl;
private final OptionSpec<WildcardDomainHandling> optionWildcardDomainHandling; private final OptionSpec<WildcardDomainHandling> optionWildcardDomainHandling;
@ -91,6 +92,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
private boolean ignoreProtocolTranslationErrors = false; private boolean ignoreProtocolTranslationErrors = false;
private boolean suppressClientProtocolErrors = false; private boolean suppressClientProtocolErrors = false;
private boolean allowLegacyClientPassthrough = false; private boolean allowLegacyClientPassthrough = false;
private boolean bungeecordPlayerInfoPassthrough = false;
private String customMotd = ""; private String customMotd = "";
private String resourcePackUrl = ""; private String resourcePackUrl = "";
private WildcardDomainHandling wildcardDomainHandling = WildcardDomainHandling.NONE; private WildcardDomainHandling wildcardDomainHandling = WildcardDomainHandling.NONE;
@ -118,6 +120,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
this.optionIgnoreProtocolTranslationErrors = this.optionParser.accepts("ignore-protocol-translation-errors").withRequiredArg().ofType(Boolean.class).defaultsTo(this.ignoreProtocolTranslationErrors); this.optionIgnoreProtocolTranslationErrors = this.optionParser.accepts("ignore-protocol-translation-errors").withRequiredArg().ofType(Boolean.class).defaultsTo(this.ignoreProtocolTranslationErrors);
this.optionSuppressClientProtocolErrors = this.optionParser.accepts("suppress-client-protocol-errors").withRequiredArg().ofType(Boolean.class).defaultsTo(this.suppressClientProtocolErrors); this.optionSuppressClientProtocolErrors = this.optionParser.accepts("suppress-client-protocol-errors").withRequiredArg().ofType(Boolean.class).defaultsTo(this.suppressClientProtocolErrors);
this.optionAllowLegacyClientPassthrough = this.optionParser.accepts("allow-legacy-client-passthrough").withRequiredArg().ofType(Boolean.class).defaultsTo(this.allowLegacyClientPassthrough); this.optionAllowLegacyClientPassthrough = this.optionParser.accepts("allow-legacy-client-passthrough").withRequiredArg().ofType(Boolean.class).defaultsTo(this.allowLegacyClientPassthrough);
this.optionBungeecordPlayerInfoPassthrough = this.optionParser.accepts("bungeecord-player-info-passthrough").withRequiredArg().ofType(Boolean.class).defaultsTo(this.bungeecordPlayerInfoPassthrough);
this.optionCustomMotd = this.optionParser.accepts("custom-motd").withRequiredArg().ofType(String.class).defaultsTo(this.customMotd); this.optionCustomMotd = this.optionParser.accepts("custom-motd").withRequiredArg().ofType(String.class).defaultsTo(this.customMotd);
this.optionResourcePackUrl = this.optionParser.accepts("resource-pack-url").withRequiredArg().ofType(String.class).defaultsTo(this.resourcePackUrl); this.optionResourcePackUrl = this.optionParser.accepts("resource-pack-url").withRequiredArg().ofType(String.class).defaultsTo(this.resourcePackUrl);
this.optionWildcardDomainHandling = this.optionParser.accepts("wildcard-domain-handling").withRequiredArg().ofType(WildcardDomainHandling.class).defaultsTo(this.wildcardDomainHandling); this.optionWildcardDomainHandling = this.optionParser.accepts("wildcard-domain-handling").withRequiredArg().ofType(WildcardDomainHandling.class).defaultsTo(this.wildcardDomainHandling);
@ -152,6 +155,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
this.ignoreProtocolTranslationErrors = this.getBoolean("ignore-protocol-translation-errors", this.ignoreProtocolTranslationErrors); this.ignoreProtocolTranslationErrors = this.getBoolean("ignore-protocol-translation-errors", this.ignoreProtocolTranslationErrors);
this.suppressClientProtocolErrors = this.getBoolean("suppress-client-protocol-errors", this.suppressClientProtocolErrors); this.suppressClientProtocolErrors = this.getBoolean("suppress-client-protocol-errors", this.suppressClientProtocolErrors);
this.allowLegacyClientPassthrough = this.getBoolean("allow-legacy-client-passthrough", this.allowLegacyClientPassthrough); this.allowLegacyClientPassthrough = this.getBoolean("allow-legacy-client-passthrough", this.allowLegacyClientPassthrough);
this.bungeecordPlayerInfoPassthrough = this.getBoolean("bungeecord-player-info-passthrough", this.bungeecordPlayerInfoPassthrough);
this.customMotd = this.getString("custom-motd", this.customMotd); this.customMotd = this.getString("custom-motd", this.customMotd);
this.resourcePackUrl = this.getString("resource-pack-url", this.resourcePackUrl); this.resourcePackUrl = this.getString("resource-pack-url", this.resourcePackUrl);
this.wildcardDomainHandling = WildcardDomainHandling.byName(this.getString("wildcard-domain-handling", this.wildcardDomainHandling.name())); this.wildcardDomainHandling = WildcardDomainHandling.byName(this.getString("wildcard-domain-handling", this.wildcardDomainHandling.name()));
@ -190,6 +194,7 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
this.ignoreProtocolTranslationErrors = options.valueOf(this.optionIgnoreProtocolTranslationErrors); this.ignoreProtocolTranslationErrors = options.valueOf(this.optionIgnoreProtocolTranslationErrors);
this.suppressClientProtocolErrors = options.valueOf(this.optionSuppressClientProtocolErrors); this.suppressClientProtocolErrors = options.valueOf(this.optionSuppressClientProtocolErrors);
this.allowLegacyClientPassthrough = options.valueOf(this.optionAllowLegacyClientPassthrough); this.allowLegacyClientPassthrough = options.valueOf(this.optionAllowLegacyClientPassthrough);
this.bungeecordPlayerInfoPassthrough = options.valueOf(this.optionBungeecordPlayerInfoPassthrough);
this.customMotd = options.valueOf(this.optionCustomMotd); this.customMotd = options.valueOf(this.optionCustomMotd);
this.resourcePackUrl = options.valueOf(this.optionResourcePackUrl); this.resourcePackUrl = options.valueOf(this.optionResourcePackUrl);
this.wildcardDomainHandling = options.valueOf(this.optionWildcardDomainHandling); this.wildcardDomainHandling = options.valueOf(this.optionWildcardDomainHandling);
@ -375,6 +380,15 @@ public class ViaProxyConfig extends Config implements com.viaversion.viaversion.
this.set("allow-legacy-client-passthrough", allowLegacyClientPassthrough); this.set("allow-legacy-client-passthrough", allowLegacyClientPassthrough);
} }
public boolean shouldPassthroughBungeecordPlayerInfo() {
return this.bungeecordPlayerInfoPassthrough;
}
public void setPassthroughBungeecordPlayerInfo(final boolean bungeecordPlayerInfoPassthrough) {
this.bungeecordPlayerInfoPassthrough = bungeecordPlayerInfoPassthrough;
this.set("bungeecord-player-info-passthrough", bungeecordPlayerInfoPassthrough);
}
public String getCustomMotd() { public String getCustomMotd() {
return this.customMotd; return this.customMotd;
} }

View File

@ -124,7 +124,12 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
this.proxyConnection.kickClient("§cYour client version is not supported by ViaProxy!"); this.proxyConnection.kickClient("§cYour client version is not supported by ViaProxy!");
} }
final String[] handshakeParts = packet.address.split("\0"); final String[] handshakeParts;
if (ViaProxy.getConfig().shouldPassthroughBungeecordPlayerInfo()) {
handshakeParts = packet.address.split("\0");
} else {
handshakeParts = new String[]{packet.address};
}
SocketAddress serverAddress = ViaProxy.getConfig().getTargetAddress(); SocketAddress serverAddress = ViaProxy.getConfig().getTargetAddress();
ProtocolVersion serverVersion = ViaProxy.getConfig().getTargetVersion(); ProtocolVersion serverVersion = ViaProxy.getConfig().getTargetVersion();

View File

@ -59,6 +59,10 @@ suppress-client-protocol-errors: false
# Allow <= 1.6.4 clients to connect through ViaProxy to the target server. (No protocol translation or packet handling) # Allow <= 1.6.4 clients to connect through ViaProxy to the target server. (No protocol translation or packet handling)
allow-legacy-client-passthrough: false allow-legacy-client-passthrough: false
# #
# Allow additional information like player ip, player uuid to be passed through to the backend server.
# This is typically used by proxies like BungeeCord and requires support from the backend server as well.
bungeecord-player-info-passthrough: false
#
# Custom MOTD to send when clients ping the proxy. Leave empty to use the target server's MOTD. # Custom MOTD to send when clients ping the proxy. Leave empty to use the target server's MOTD.
custom-motd: "" custom-motd: ""
# #