From dfc06261261e2e4e3966def86c5bbc0c110ffac0 Mon Sep 17 00:00:00 2001 From: funtimes909 <68979259+Funtimes909@users.noreply.github.com> Date: Sun, 5 Apr 2026 14:16:38 +1200 Subject: [PATCH] ignore anonymous players if requested --- src/database/mod.rs | 24 ++++++++++++++---------- src/protocol/response.rs | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/database/mod.rs b/src/database/mod.rs index 72edae4..5fb1a07 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -1,6 +1,7 @@ pub mod country_tracking; -use std::str::FromStr; +use crate::CONFIG; +use crate::protocol::response::ANONYMOUS_PLAYER_NAME; use super::protocol::response::MinecraftServer; use chrono::NaiveDateTime; @@ -192,15 +193,18 @@ impl ServerUpdateOperation { let mut query_builder = QueryBuilder::new("INSERT INTO players "); query_builder.push_values(player_sample, |mut b, player| { - // Ignore player if uuid fails to parse - if let Ok(parsed_uuid) = Uuid::from_str(&player.id) { - b.push_bind(self.address) - .push_bind(self.port) - .push_bind(parsed_uuid) - .push_bind(parsed_uuid.get_version_num() == 4) - .push_bind(&player.name) - .push_bind(self.timestamp) - .push_bind(self.timestamp); + // Disregard anonymous players if specified in the config + if CONFIG.scanner.ignore_fake_players && !player.name.eq(ANONYMOUS_PLAYER_NAME) { + // Ignore players that have invalid uuid's + if let Ok(uuid) = Uuid::parse_str(&player.id) { + b.push_bind(self.address) + .push_bind(self.port) + .push_bind(uuid) + .push_bind(uuid.get_version_num() == 4) + .push_bind(&player.name) + .push_bind(self.timestamp) + .push_bind(self.timestamp); + } } }); diff --git a/src/protocol/response.rs b/src/protocol/response.rs index 6eee321..ced03e7 100644 --- a/src/protocol/response.rs +++ b/src/protocol/response.rs @@ -5,8 +5,8 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; use sqlx::types::Uuid; +pub const ANONYMOUS_PLAYER_NAME: &str = "Anonymous Player"; const OPT_OUT_CODE: &str = "§b§d§f§d§b"; -const ANONYMOUS_PLAYER_NAME: &str = "Anonymous Player"; const FAKE_PLAYER_SAMPLE_MESSAGE: &str = "To protect the privacy of this server and its\nusers, you must log in once to see ping data.";