From fd13333d03957aaae08253243cb824e8c6a2237f Mon Sep 17 00:00:00 2001 From: kralverde Date: Sat, 12 Oct 2024 19:56:24 -0400 Subject: [PATCH 1/4] scrub ipds --- pumpkin-config/src/lib.rs | 4 ++++ pumpkin/src/main.rs | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/pumpkin-config/src/lib.rs b/pumpkin-config/src/lib.rs index 6062bb259..498218640 100644 --- a/pumpkin-config/src/lib.rs +++ b/pumpkin-config/src/lib.rs @@ -94,6 +94,9 @@ pub struct BasicConfiguration { /// The default game mode for players. #[serde_inline_default(GameMode::Survival)] pub default_gamemode: GameMode, + /// Whether to remove IPs from logs or not + #[serde_inline_default(true)] + pub scrub_ips: bool, } fn default_server_address() -> SocketAddr { @@ -115,6 +118,7 @@ impl Default for BasicConfiguration { encryption: true, motd: "A Blazing fast Pumpkin Server!".to_string(), default_gamemode: GameMode::Survival, + scrub_ips: true, } } } diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index 976910003..e205a6081 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -39,6 +39,12 @@ pub mod server; pub mod util; pub mod world; +fn scrub_address(ip: &str) -> String { + ip.chars() + .map(|ch| if ch == '.' || ch == ':' { ch } else { 'x' }) + .collect() +} + fn init_logger() { use pumpkin_config::ADVANCED_CONFIG; if ADVANCED_CONFIG.logging.enabled { @@ -128,7 +134,10 @@ fn main() -> io::Result<()> { let server = Arc::new(Server::new()); log::info!("Started Server took {}ms", time.elapsed().as_millis()); - log::info!("You now can connect to the server, Listening on {}", addr); + log::info!( + "You now can connect to the server, Listening on {}", + scrub_address(&format!("{}", addr)) + ); if use_console { let server = server.clone(); @@ -189,7 +198,10 @@ fn main() -> io::Result<()> { log::warn!("failed to set TCP_NODELAY {e}"); } - log::info!("Accepted connection from: {}", address); + log::info!( + "Accepted connection from: {}", + scrub_address(&format!("{}", address)) + ); let token = next(&mut unique_token); poll.registry().register( From 7f93e17154220e2e80ca6f8bef56fdeb40b4eff0 Mon Sep 17 00:00:00 2001 From: kralverde Date: Sat, 12 Oct 2024 19:59:06 -0400 Subject: [PATCH 2/4] add check --- pumpkin/src/main.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index e205a6081..b33b5b950 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -40,9 +40,14 @@ pub mod util; pub mod world; fn scrub_address(ip: &str) -> String { - ip.chars() - .map(|ch| if ch == '.' || ch == ':' { ch } else { 'x' }) - .collect() + use pumpkin_config::BASIC_CONFIG; + if BASIC_CONFIG.scrub_ips { + ip.chars() + .map(|ch| if ch == '.' || ch == ':' { ch } else { 'x' }) + .collect() + } else { + ip.to_string() + } } fn init_logger() { From c2be6af8c9e807b7caddc640c274fe16264dc92f Mon Sep 17 00:00:00 2001 From: kralverde Date: Mon, 14 Oct 2024 14:51:39 -0400 Subject: [PATCH 3/4] add bool to config docs --- docs/config/basic.md | 34 +++++++++++++++++++++------------- pumpkin/src/main.rs | 5 +---- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/docs/config/basic.md b/docs/config/basic.md index ac8b118fc..7d646c33c 100644 --- a/docs/config/basic.md +++ b/docs/config/basic.md @@ -1,8 +1,8 @@ -### Basic Configuration +# Basic Configuration Representing `configuration.toml` -### Server Address +## Server Address The address to bind the server to @@ -10,7 +10,7 @@ The address to bind the server to server_address=0.0.0.0 ``` -### Seed +## Seed The seed for world generation @@ -18,7 +18,7 @@ The seed for world generation seed= ``` -### Max players +## Max players The maximum number of players allowed on the server @@ -26,7 +26,7 @@ The maximum number of players allowed on the server max_players=10000 ``` -### View distance +## View distance The maximum view distance for players @@ -34,7 +34,7 @@ The maximum view distance for players view_distance=10 ``` -### Simulation distance +## Simulation distance The maximum simulation distance for players @@ -42,7 +42,7 @@ The maximum simulation distance for players simulation_distance=10 ``` -### Default difficulty +## Default difficulty The default game difficulty @@ -57,7 +57,7 @@ Normal Hard ``` -### Allow nether +## Allow nether Whether the Nether dimension is enabled @@ -65,7 +65,7 @@ Whether the Nether dimension is enabled allow_nether=true ``` -### Hardcore +## Hardcore Whether the server is in hardcore mode. @@ -73,7 +73,7 @@ Whether the server is in hardcore mode. hardcore=true ``` -### Online Mode +## Online Mode Whether online mode is enabled. Requires valid Minecraft accounts @@ -81,7 +81,7 @@ Whether online mode is enabled. Requires valid Minecraft accounts online_mode=true ``` -### Encryption +## Encryption Whether packet encryption is enabled @@ -92,7 +92,7 @@ Whether packet encryption is enabled encryption=true ``` -### Motd +## Motd The server's description displayed on the status screen. @@ -100,7 +100,7 @@ The server's description displayed on the status screen. motd=true ``` -### Default gamemode +## Default gamemode The default game mode for players @@ -115,3 +115,11 @@ Creative Adventure Spectator ``` + +## IP Scrubbing + +Whether to scrub player IPs from logs + +```toml +scrub_ips=true +``` diff --git a/pumpkin/src/main.rs b/pumpkin/src/main.rs index b33b5b950..a370f982c 100644 --- a/pumpkin/src/main.rs +++ b/pumpkin/src/main.rs @@ -139,10 +139,7 @@ fn main() -> io::Result<()> { let server = Arc::new(Server::new()); log::info!("Started Server took {}ms", time.elapsed().as_millis()); - log::info!( - "You now can connect to the server, Listening on {}", - scrub_address(&format!("{}", addr)) - ); + log::info!("You now can connect to the server, Listening on {}", addr); if use_console { let server = server.clone(); From 47208e9a0f0c9fa5081f13e57cb39c0824e12626 Mon Sep 17 00:00:00 2001 From: kralverde Date: Mon, 14 Oct 2024 16:00:08 -0400 Subject: [PATCH 4/4] revert styling changes --- docs/config/basic.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/config/basic.md b/docs/config/basic.md index 7d646c33c..8d224a02e 100644 --- a/docs/config/basic.md +++ b/docs/config/basic.md @@ -1,8 +1,8 @@ -# Basic Configuration +### Basic Configuration Representing `configuration.toml` -## Server Address +### Server Address The address to bind the server to @@ -10,7 +10,7 @@ The address to bind the server to server_address=0.0.0.0 ``` -## Seed +### Seed The seed for world generation @@ -18,7 +18,7 @@ The seed for world generation seed= ``` -## Max players +### Max players The maximum number of players allowed on the server @@ -26,7 +26,7 @@ The maximum number of players allowed on the server max_players=10000 ``` -## View distance +### View distance The maximum view distance for players @@ -34,7 +34,7 @@ The maximum view distance for players view_distance=10 ``` -## Simulation distance +### Simulation distance The maximum simulation distance for players @@ -42,7 +42,7 @@ The maximum simulation distance for players simulation_distance=10 ``` -## Default difficulty +### Default difficulty The default game difficulty @@ -57,7 +57,7 @@ Normal Hard ``` -## Allow nether +### Allow nether Whether the Nether dimension is enabled @@ -65,7 +65,7 @@ Whether the Nether dimension is enabled allow_nether=true ``` -## Hardcore +### Hardcore Whether the server is in hardcore mode. @@ -73,7 +73,7 @@ Whether the server is in hardcore mode. hardcore=true ``` -## Online Mode +### Online Mode Whether online mode is enabled. Requires valid Minecraft accounts @@ -81,7 +81,7 @@ Whether online mode is enabled. Requires valid Minecraft accounts online_mode=true ``` -## Encryption +### Encryption Whether packet encryption is enabled @@ -92,7 +92,7 @@ Whether packet encryption is enabled encryption=true ``` -## Motd +### Motd The server's description displayed on the status screen. @@ -100,7 +100,7 @@ The server's description displayed on the status screen. motd=true ``` -## Default gamemode +### Default gamemode The default game mode for players @@ -116,7 +116,7 @@ Adventure Spectator ``` -## IP Scrubbing +### IP Scrubbing Whether to scrub player IPs from logs