ignore anonymous players if requested

This commit is contained in:
funtimes909
2026-04-05 14:16:38 +12:00
parent e72e51f60c
commit dfc0626126
2 changed files with 15 additions and 11 deletions
+14 -10
View File
@@ -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);
}
}
});
+1 -1
View File
@@ -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.";