Skip to content

Commit

Permalink
fix server properties address parsing when empty values
Browse files Browse the repository at this point in the history
  • Loading branch information
zekroTJA committed Nov 12, 2022
1 parent 2bfb966 commit a3003ef
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit a3003ef

Please sign in to comment.