Skip to content

Commit

Permalink
randomise default rcon password
Browse files Browse the repository at this point in the history
  • Loading branch information
circlesabound committed Mar 31, 2024
1 parent ac65cdb commit 3a5d36d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ http = "1.0"
lazy_static = "1.4"
log = "0.4"
nix = { version = "0.28", features = [ "process", "signal" ] }
rand = "0.8"
rcon = { version = "0.6", features = [ "rt-tokio" ] }
regex = "1.4"
reqwest = { version = "0.12.1", features = [ "json" ] }
Expand Down
9 changes: 8 additions & 1 deletion src/agent/server/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use std::{
use fctrl::schema::ServerSettingsConfig;
use lazy_static::lazy_static;
use log::{error, info, warn};
use rand::Rng;
use serde::{Deserialize, Serialize};
use tokio::fs;

Expand Down Expand Up @@ -96,10 +97,16 @@ impl Default for LaunchSettings {
.unwrap()
.parse()
.unwrap();
// generate random RCON password, 12 length, alphanumeric
let rcon_password = rand::thread_rng()
.sample_iter(&rand::distributions::Alphanumeric)
.take(12)
.map(char::from)
.collect();
LaunchSettings {
server_bind: SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), server_port),
rcon_bind: SocketAddr::new(IpAddr::V4(Ipv4Addr::UNSPECIFIED), rcon_port),
rcon_password: "rcon".to_owned(),
rcon_password,
use_whitelist: false,
}
}
Expand Down

0 comments on commit 3a5d36d

Please sign in to comment.