diff --git a/config.example.toml b/config.example.toml index 7e20b53..8f9e714 100644 --- a/config.example.toml +++ b/config.example.toml @@ -13,6 +13,8 @@ append_path = "/" # where can your server be accessible? port = 8000 +# your realip header, if you're behind a reverse proxy +realip_header = "X-Real-IP" [accounts] # allow new accounts to be created diff --git a/readme.md b/readme.md index caf9ac3..1fc274d 100644 --- a/readme.md +++ b/readme.md @@ -42,4 +42,5 @@ _these features are implemented_ - better way for checking if song is custom (currently `id > 50`) - sqlite would make sense for this - unscuff difficulties -- moderation utilities \ No newline at end of file +- moderation utilities +- probably make more things bools in the database \ No newline at end of file diff --git a/src/config.rs b/src/config.rs index 6333b20..597d744 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,7 +13,8 @@ pub struct Config { #[derive(Deserialize)] pub struct ConfigGeneral { pub append_path: String, - pub port: u16 + pub port: u16, + pub realip_header: String } #[derive(Deserialize)] diff --git a/src/main.rs b/src/main.rs index ed8f513..ab78110 100644 --- a/src/main.rs +++ b/src/main.rs @@ -26,11 +26,6 @@ use template_endpoints::*; mod config; use config::*; -#[get("/")] -fn index() -> String { - return String::from("gdps-server | https://git.reidlab.online/reidlab/gdps-server"); -} - #[get("/")] async fn files(file: PathBuf) -> Option { NamedFile::open(Path::new("public/").join(file)).await.ok() @@ -39,11 +34,14 @@ async fn files(file: PathBuf) -> Option { #[launch] fn rocket() -> _ { // this is a bit scuffed - fs::create_dir_all(&CONFIG.db.data_folder).expect("failed to create data directory! (probably a permission err)"); + fs::create_dir_all(&CONFIG.db.data_folder).expect("failed to create data directory!"); fs::create_dir_all(format!("{}/levels", &CONFIG.db.data_folder)).expect("failed to create data directory for levels"); rocket::build() - .configure(rocket::Config::figment().merge(("port", CONFIG.general.port))) + // conf + .configure(rocket::Config::figment() + .merge(("port", CONFIG.general.port)) + .merge(("ip_header", CONFIG.general.realip_header.as_str()))) // actual website .mount("/", routes![ template_endpoints::index::index