scroll.server/services/auth-service/src/config.rs
scroll 812052bc3e initial import, client gets to the lobby
titan engine, logic model, auth/game/gateway services.
csv tables pulled out of the ipa are checked in so it runs out of the box.
2026-08-23 07:50:31 +03:00

43 lines
1.5 KiB
Rust

use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct AuthConfig {
pub listen: String,
pub store_path: PathBuf,
pub min_client_build: i32,
pub max_client_build: i32,
pub content_fingerprint: Option<String>,
pub content_url: Option<String>,
}
impl Default for AuthConfig {
fn default() -> Self {
Self {
listen: "127.0.0.1:9401".to_owned(),
store_path: PathBuf::from("data/accounts.json"),
min_client_build: 0,
max_client_build: i32::MAX,
content_fingerprint: None,
content_url: None,
}
}
}
impl AuthConfig {
pub fn from_env() -> Self {
let defaults = Self::default();
Self {
listen: env_string("SCROLL_AUTH_LISTEN").unwrap_or(defaults.listen),
store_path: env_string("SCROLL_AUTH_STORE")
.map(PathBuf::from)
.unwrap_or(defaults.store_path),
min_client_build: env_i32("SCROLL_MIN_CLIENT_BUILD").unwrap_or(defaults.min_client_build),
max_client_build: env_i32("SCROLL_MAX_CLIENT_BUILD").unwrap_or(defaults.max_client_build),
content_fingerprint: env_string("SCROLL_CONTENT_FINGERPRINT"),
content_url: env_string("SCROLL_CONTENT_URL"),
}
}
}
pub fn env_string(key: &str) -> Option<String> {
std::env::var(key).ok().filter(|value| !value.is_empty())
}
pub fn env_i32(key: &str) -> Option<i32> {
env_string(key).and_then(|value| value.parse().ok())
}