-
-
Notifications
You must be signed in to change notification settings - Fork 950
Adding more options for configuring ping passthrough. #1870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
f9c03d9
70a4383
d1640b6
a2109cf
3a24c4a
8d8acc8
ec0c630
2346929
bad5105
1344650
1218588
e868c43
84a2029
e3c3e97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /* | ||
| * Copyright (C) 2018-2023 Velocity Contributors | ||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.velocitypowered.proxy.config; | ||
|
|
||
| /** | ||
| * Legacy modes for ping passthrough. | ||
| */ | ||
| public enum LegacyPingPassthroughMode { | ||
|
WouterGritter marked this conversation as resolved.
Outdated
|
||
| DISABLED, | ||
| MODS, | ||
| DESCRIPTION, | ||
| ALL | ||
| } | ||
|
TheMiningTeamYT marked this conversation as resolved.
Outdated
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |
| import com.velocitypowered.proxy.config.migration.MiniMessageTranslationsMigration; | ||
| import com.velocitypowered.proxy.config.migration.MotdMigration; | ||
| import com.velocitypowered.proxy.config.migration.PacketLimiterMigration; | ||
| import com.velocitypowered.proxy.config.migration.PingPassthroughMigration; | ||
| import com.velocitypowered.proxy.config.migration.TransferIntegrationMigration; | ||
| import com.velocitypowered.proxy.util.AddressUtil; | ||
| import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; | ||
|
|
@@ -79,7 +80,7 @@ public class VelocityConfiguration implements ProxyConfig { | |
| @Expose | ||
| private boolean onlineModeKickExistingPlayers = false; | ||
| @Expose | ||
| private PingPassthroughMode pingPassthrough = PingPassthroughMode.DISABLED; | ||
| private PingPassthroughMode pingPassthrough = new PingPassthroughMode(false, false, false, false, false); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. = PingPassthroughMode.DEFAULTwas the primary change I suggested rather than having this randomly created instance; the blow block of getOrElse() can also use the default instance, that way it's all defined in a singular place
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay I understand now. I honestly forgot that was there. That being said, I think change this to function more like the PacketLimiterConfig. I like how it puts all the code for parsing the sections in one place. Unless you disagree.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The limiter config was just a quick toss together for the sake of getting this out, if I wanted everything in one place I would just have
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Let me ask then, is there a different way you would prefer me to do this? |
||
| @Expose | ||
| private boolean samplePlayersInPing = false; | ||
| private final Servers servers; | ||
|
|
@@ -513,7 +514,8 @@ public static VelocityConfiguration read(Path path) throws IOException { | |
| new MotdMigration(), | ||
| new MiniMessageTranslationsMigration(), | ||
| new TransferIntegrationMigration(), | ||
| new PacketLimiterMigration() | ||
| new PacketLimiterMigration(), | ||
| new PingPassthroughMigration(), | ||
| }; | ||
|
|
||
| for (final ConfigurationMigration migration : migrations) { | ||
|
|
@@ -555,9 +557,12 @@ public static VelocityConfiguration read(Path path) throws IOException { | |
| final CommentedConfig metricsConfig = config.get("metrics"); | ||
| final PlayerInfoForwarding forwardingMode = config.getEnumOrElse( | ||
| "player-info-forwarding-mode", PlayerInfoForwarding.NONE); | ||
| final PingPassthroughMode pingPassthroughMode = config.getEnumOrElse("ping-passthrough", | ||
| PingPassthroughMode.DISABLED); | ||
|
|
||
| final PingPassthroughMode pingPassthrough = new PingPassthroughMode( | ||
| config.getOrElse("ping-passthrough.version", false), | ||
| config.getOrElse("ping-passthrough.players", false), | ||
| config.getOrElse("ping-passthrough.description", false), | ||
| config.getOrElse("ping-passthrough.favicon", false), | ||
| config.getOrElse("ping-passthrough.modinfo", false)); | ||
|
TheMiningTeamYT marked this conversation as resolved.
Outdated
|
||
| final boolean samplePlayersInPing = config.getOrElse("sample-players-in-ping", false); | ||
|
|
||
| final String bind = config.getOrElse("bind", "0.0.0.0:25565"); | ||
|
|
@@ -590,7 +595,7 @@ public static VelocityConfiguration read(Path path) throws IOException { | |
| forwardingMode, | ||
| forwardingSecret, | ||
| kickExisting, | ||
| pingPassthroughMode, | ||
| pingPassthrough, | ||
| samplePlayersInPing, | ||
| enablePlayerAddressLogging, | ||
| new Servers(serversConfig), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Copyright (C) 2024 Velocity Contributors | ||
|
TheMiningTeamYT marked this conversation as resolved.
Outdated
|
||
| * | ||
| * This program is free software: you can redistribute it and/or modify | ||
| * it under the terms of the GNU General Public License as published by | ||
| * the Free Software Foundation, either version 3 of the License, or | ||
| * (at your option) any later version. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU General Public License | ||
| * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| package com.velocitypowered.proxy.config.migration; | ||
|
|
||
| import com.electronwill.nightconfig.core.file.CommentedFileConfig; | ||
| import com.velocitypowered.proxy.config.LegacyPingPassthroughMode; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
||
| /** | ||
| * Migrate the old ping passthrough entry to separate config entries. | ||
| */ | ||
| public final class PingPassthroughMigration implements ConfigurationMigration { | ||
| @Override | ||
| public boolean shouldMigrate(final CommentedFileConfig config) { | ||
| return configVersion(config) < 2.9; | ||
| } | ||
|
|
||
| @Override | ||
| public void migrate(final CommentedFileConfig config, final Logger logger) { | ||
|
TheMiningTeamYT marked this conversation as resolved.
|
||
| // Get legacy ping passthrough value | ||
| final LegacyPingPassthroughMode legacyMode = config.getEnumOrElse("ping-passthrough", | ||
| LegacyPingPassthroughMode.DISABLED); | ||
|
WouterGritter marked this conversation as resolved.
Outdated
|
||
|
|
||
| config.removeComment("ping-passthrough"); | ||
| config.remove("ping-passthrough"); | ||
|
WouterGritter marked this conversation as resolved.
|
||
|
|
||
| // Create ping passthrough entry for the version | ||
| config.set("ping-passthrough.version", legacyMode.equals(LegacyPingPassthroughMode.ALL)); | ||
| config.setComment( | ||
| "ping-passthrough.version", | ||
| " Should Velocity pass the version number from the backend server when responding to server list ping requests?" | ||
| ); | ||
|
|
||
| // Create ping passthrough entry for the players | ||
| config.set("ping-passthrough.players", legacyMode.equals(LegacyPingPassthroughMode.ALL)); | ||
| config.setComment( | ||
| "ping-passthrough.players", | ||
| " Should Velocity pass the player count from the backend server when responding to server list ping requests?" | ||
| ); | ||
|
|
||
| // Create ping passthrough entry for the description | ||
| config.set("ping-passthrough.description", | ||
| legacyMode.equals(LegacyPingPassthroughMode.ALL) | ||
| || legacyMode.equals(LegacyPingPassthroughMode.DESCRIPTION) | ||
| ); | ||
| config.setComment( | ||
| "ping-passthrough.description", | ||
| " Should Velocity pass the description from the backend server when responding to server list ping requests?" | ||
| ); | ||
|
|
||
| // Create ping passthrough entry for the favicon | ||
| config.set("ping-passthrough.favicon", legacyMode.equals(LegacyPingPassthroughMode.ALL)); | ||
| config.setComment( | ||
| "ping-passthrough.favicon", | ||
| " Should Velocity pass the favicon (also known as the server icon) from the backend server when responding to server list ping requests?" | ||
| ); | ||
|
|
||
| // Create ping passthrough entry for the mods info | ||
|
WouterGritter marked this conversation as resolved.
Outdated
|
||
| config.set("ping-passthrough.modinfo", | ||
| legacyMode.equals(LegacyPingPassthroughMode.ALL) | ||
| || legacyMode.equals(LegacyPingPassthroughMode.MODS) | ||
| || legacyMode.equals(LegacyPingPassthroughMode.DESCRIPTION) | ||
| ); | ||
| config.setComment( | ||
| "ping-passthrough.modinfo", | ||
| " Should Velocity pass the mod list from the backend server when responding to server list ping requests?" | ||
| ); | ||
|
|
||
| // Update config version | ||
| config.set("config-version", "2.9"); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.