From 175b90be5a42e5bfd3289ffdfbf7b201404f82a8 Mon Sep 17 00:00:00 2001 From: Josiah Glosson Date: Mon, 28 Jul 2025 07:44:34 -0700 Subject: [PATCH] Legacy ping support (#4062) * Detection of protocol versions before 18w47b * Refactor old_protocol_versions into protocol_version * Ping servers closer to how a client of an instance's version would ping a server * Allow pinging legacy servers from a modern profile in the same way a modern client would * Ping 1.4.2 through 1.5.2 like a Vanilla client in those versions would when in such an instance --- Cargo.lock | 44 ++ Cargo.toml | 1 + .../components/ui/world/RecentWorldsList.vue | 14 +- .../src/components/ui/world/WorldItem.vue | 16 +- apps/app-frontend/src/helpers/worlds.ts | 38 +- .../src/pages/instance/Worlds.vue | 7 +- apps/app/src/api/worlds.rs | 10 +- packages/app-lib/Cargo.toml | 1 + packages/app-lib/src/api/worlds.rs | 20 +- packages/app-lib/src/launcher/mod.rs | 4 +- packages/app-lib/src/state/profiles.rs | 4 +- packages/app-lib/src/util/mod.rs | 1 + packages/app-lib/src/util/protocol_version.rs | 478 ++++++++++++++++++ packages/app-lib/src/util/server_ping.rs | 112 +++- 14 files changed, 705 insertions(+), 45 deletions(-) create mode 100644 packages/app-lib/src/util/protocol_version.rs diff --git a/Cargo.lock b/Cargo.lock index 4dfc698b6..66073b932 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5731,6 +5731,17 @@ dependencies = [ "phf_shared 0.11.3", ] +[[package]] +name = "phf" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7" +dependencies = [ + "phf_macros 0.12.1", + "phf_shared 0.12.1", + "serde", +] + [[package]] name = "phf_codegen" version = "0.8.0" @@ -5781,6 +5792,16 @@ dependencies = [ "rand 0.8.5", ] +[[package]] +name = "phf_generator" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cbb1126afed61dd6368748dae63b1ee7dc480191c6262a3b4ff1e29d86a6c5b" +dependencies = [ + "fastrand 2.3.0", + "phf_shared 0.12.1", +] + [[package]] name = "phf_macros" version = "0.10.0" @@ -5808,6 +5829,19 @@ dependencies = [ "syn 2.0.101", ] +[[package]] +name = "phf_macros" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d713258393a82f091ead52047ca779d37e5766226d009de21696c4e667044368" +dependencies = [ + "phf_generator 0.12.1", + "phf_shared 0.12.1", + "proc-macro2", + "quote", + "syn 2.0.101", +] + [[package]] name = "phf_shared" version = "0.8.0" @@ -5835,6 +5869,15 @@ dependencies = [ "siphasher 1.0.1", ] +[[package]] +name = "phf_shared" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981" +dependencies = [ + "siphasher 1.0.1", +] + [[package]] name = "pin-project" version = "1.1.10" @@ -8946,6 +8989,7 @@ dependencies = [ "notify-debouncer-mini", "p256", "paste", + "phf 0.12.1", "png", "quartz_nbt", "quick-xml 0.37.5", diff --git a/Cargo.toml b/Cargo.toml index 341c8838b..b3c0bfa71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,6 +99,7 @@ notify = { version = "8.0.0", default-features = false } notify-debouncer-mini = { version = "0.6.0", default-features = false } p256 = "0.13.2" paste = "1.0.15" +phf = { version = "0.12.1", features = ["macros"] } png = "0.17.16" prometheus = "0.14.0" quartz_nbt = "0.2.9" diff --git a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue index a960f805f..5f80a194f 100644 --- a/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue +++ b/apps/app-frontend/src/components/ui/world/RecentWorldsList.vue @@ -1,5 +1,6 @@