From a3003ef0122ac322feb1529c48317a547bc4a071 Mon Sep 17 00:00:00 2001 From: zekroTJA Date: Sat, 12 Nov 2022 02:33:10 +0000 Subject: [PATCH] fix server properties address parsing when empty values --- src/main.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main.rs b/src/main.rs index 6864422..59f611e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,12 +40,16 @@ fn main() { .build() .expect("Failed reading config from server properties"); - let ip = conf - .get_string("server-ip") - .unwrap_or_else(|_| "localhost".into()); - let port = conf - .get_string("rcon.port") - .unwrap_or_else(|_| "25575".into()); + let mut ip = conf.get_string("server-ip").unwrap_or_else(|_| "".into()); + if ip.is_empty() { + ip = "localhost".into(); + } + + let mut port = conf.get_string("rcon.port").unwrap_or_else(|_| "".into()); + if port.is_empty() { + port = "25575".into(); + } + addr = format!("{ip}:{port}"); passwd = conf.get_string("rcon.password").ok();