2025-06-13 12:36:28 +02:00
|
|
|
use std::env;
|
2025-10-07 20:39:52 +02:00
|
|
|
use std::net::Ipv4Addr;
|
2025-06-13 12:36:28 +02:00
|
|
|
use once_cell::sync::Lazy;
|
|
|
|
|
use crate::nex::account::Account;
|
2025-11-06 22:55:41 +00:00
|
|
|
use std::error::Error;
|
|
|
|
|
|
|
|
|
|
const IP_REQ_SERVICE_URL: &str = "https://ipinfo.io/ip";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn try_get_ip() -> Result<Ipv4Addr, Box<dyn Error>> {
|
|
|
|
|
let req = reqwest::blocking::get(IP_REQ_SERVICE_URL)?;
|
|
|
|
|
Ok(req.text()?.parse()?)
|
|
|
|
|
}
|
2025-06-13 12:36:28 +02:00
|
|
|
|
|
|
|
|
pub static OWN_IP_PRIVATE: Lazy<Ipv4Addr> = Lazy::new(|| {
|
|
|
|
|
env::var("SERVER_IP")
|
|
|
|
|
.ok()
|
2025-11-05 22:47:06 +01:00
|
|
|
.map(|s| s.parse().expect("invalid ip address"))
|
|
|
|
|
.unwrap_or(Ipv4Addr::UNSPECIFIED)
|
2025-06-13 12:36:28 +02:00
|
|
|
});
|
|
|
|
|
|
2025-06-29 11:40:42 +02:00
|
|
|
pub static OWN_IP_PUBLIC: Lazy<Ipv4Addr> = Lazy::new(|| {
|
|
|
|
|
env::var("SERVER_IP_PUBLIC")
|
|
|
|
|
.ok()
|
2025-11-06 22:55:41 +00:00
|
|
|
.map(|s| s.parse().expect("invalid ip address"))
|
|
|
|
|
.unwrap_or_else(||{
|
|
|
|
|
try_get_ip().unwrap()
|
|
|
|
|
})
|
2025-06-29 11:40:42 +02:00
|
|
|
});
|
|
|
|
|
|
2025-06-13 12:36:28 +02:00
|
|
|
pub static SERVER_PORT: Lazy<u16> = Lazy::new(|| {
|
|
|
|
|
env::var("SERVER_PORT")
|
|
|
|
|
.ok()
|
|
|
|
|
.and_then(|s| s.parse().ok())
|
|
|
|
|
.unwrap_or(10000)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
pub static KERBEROS_SERVER_PASSWORD: Lazy<String> = Lazy::new(|| {
|
|
|
|
|
env::var("AUTH_SERVER_PASSWORD")
|
|
|
|
|
.ok()
|
|
|
|
|
.unwrap_or("password".to_owned())
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
pub static AUTH_SERVER_ACCOUNT: Lazy<Account> =
|
|
|
|
|
Lazy::new(|| Account::new(1, "Quazal Authentication", &KERBEROS_SERVER_PASSWORD));
|
|
|
|
|
pub static SECURE_SERVER_ACCOUNT: Lazy<Account> =
|
|
|
|
|
Lazy::new(|| Account::new(2, "Quazal Rendez-Vous", &KERBEROS_SERVER_PASSWORD));
|
2025-06-29 11:40:42 +02:00
|
|
|
|
|
|
|
|
|
2025-09-21 15:59:27 +02:00
|
|
|
|