-
-
Notifications
You must be signed in to change notification settings - Fork 859
feat: Add more options for ping passthrough #1631
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
Open
ButterDebugger
wants to merge
17
commits into
PaperMC:dev/3.0.0
Choose a base branch
from
ButterDebugger:ping-passthrough-dev
base: dev/3.0.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e2b8214
Added 'ALLBUTVERSION' option for ping passthrough.
38238b1
Trying to get the GitHub build action to run
f68bfb1
Added more configuration options for ping passthrough.
6dfdd9d
Updated default velocity.toml
1ac07b8
Update proxy/src/main/java/com/velocitypowered/proxy/connection/util/…
TheMiningTeamYT 00652b5
Update proxy/src/main/java/com/velocitypowered/proxy/connection/util/…
TheMiningTeamYT 73813fb
Update proxy/src/main/java/com/velocitypowered/proxy/connection/util/…
TheMiningTeamYT 39f5c21
Update proxy/src/main/java/com/velocitypowered/proxy/connection/util/…
TheMiningTeamYT aca2132
Update proxy/src/main/java/com/velocitypowered/proxy/connection/util/…
TheMiningTeamYT 72ed9c8
Update proxy/src/main/java/com/velocitypowered/proxy/connection/util/…
TheMiningTeamYT 71c11a8
Add support for the legacy ping passthrough.
TheMiningTeamYT 5eb3906
Merge branch 'dev/3.0.0' into ping-passthrough-dev
TheMiningTeamYT e76b3ed
Add more options for ping passthrough configuration. (Merge ping-pass…
TheMiningTeamYT 8b53943
Merge branch 'PaperMC:dev/3.0.0' into dev/3.0.0
TheMiningTeamYT 52d0d63
Merge branch 'dev/3.0.0' into ping-passthrough-dev
ButterDebugger fd30e8d
Removed legacy ping passthrough & added config migration
ButterDebugger f48e6fa
Cleaned up code to match code style
ButterDebugger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
proxy/src/main/java/com/velocitypowered/proxy/config/LegacyPingPassthroughMode.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 { | ||
| DISABLED, | ||
| MODS, | ||
| DESCRIPTION, | ||
| ALL | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
proxy/src/main/java/com/velocitypowered/proxy/config/migration/PingPassthroughMigration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* | ||
| * Copyright (C) 2024 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.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.8; | ||
| } | ||
|
|
||
| @Override | ||
| public void migrate(final CommentedFileConfig config, final Logger logger) { | ||
| // Get legacy ping passthrough value | ||
| final LegacyPingPassthroughMode legacyMode = config.getEnumOrElse("ping-passthrough", | ||
| LegacyPingPassthroughMode.DISABLED); | ||
|
|
||
| config.removeComment("ping-passthrough"); | ||
| config.remove("ping-passthrough"); | ||
|
|
||
| // 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 | ||
| 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.8"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ternaries for each of those would make them a bit more compact. And not sure if this means much, but this looks functionally different to the description and mods search from before where it would continue iterating responses if they're null in the current one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the ternaries, personal preference but that's an easy fix to make down the road. I don't think that should keep you from merging the pull request.
As for the difference in handling mod/description search: If you were to implement that in this code, you'd run the risk of, say, returning the player count from one server and the mod list from another, or returning the player count & mod list from a different server from the one the player is about to join, so unless someone jumps in here and says "hey I need that," I think it's fine the way it is.