realip header

This commit is contained in:
Reid 2023-09-11 23:25:51 -07:00
parent 1d04c7ed59
commit 6f6f48d80b
Signed by: reidlab
GPG key ID: 6C9EAA3364F962C8
4 changed files with 11 additions and 4 deletions

View file

@ -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

View file

@ -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
- moderation utilities
- probably make more things bools in the database

View file

@ -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)]

View file

@ -39,11 +39,14 @@ async fn files(file: PathBuf) -> Option<NamedFile> {
#[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