Make clients list file configurable

This commit is contained in:
2025-10-28 09:56:52 +01:00
parent e93e3f4d9c
commit 5db16c2355
2 changed files with 18 additions and 4 deletions

View File

@@ -18,6 +18,14 @@ pub struct AppConfig {
#[clap(short, long, env)]
pub storage_path: String,
/// Overwrite clients list file path, if the file is not to be found in storage path
#[clap(long, env)]
pub clients_list_file_path: Option<String>,
/// Overwrite providers list file path, if the file is not to be found in storage path
#[clap(long, env)]
pub providers_list_file_path: Option<String>,
/// App token token
#[clap(short, long, env, default_value = "")]
pub token_key: String,
@@ -32,7 +40,7 @@ pub struct AppConfig {
/// IP location service API
///
/// Up instance of IP location service : https://gitlab.com/pierre42100/iplocationserver
/// Operating instance of IP location service : https://gitlab.com/pierre42100/iplocationserver
///
/// Example: "https://api.geoip.rs"
#[arg(long, short, env)]
@@ -71,11 +79,17 @@ impl AppConfig {
}
pub fn clients_file(&self) -> PathBuf {
self.storage_path().join(CLIENTS_LIST_FILE)
match &self.clients_list_file_path {
None => self.storage_path().join(CLIENTS_LIST_FILE),
Some(p) => Path::new(p).to_path_buf(),
}
}
pub fn providers_file(&self) -> PathBuf {
self.storage_path().join(PROVIDERS_LIST_FILE)
match &self.providers_list_file_path {
None => self.storage_path().join(PROVIDERS_LIST_FILE),
Some(p) => Path::new(p).to_path_buf(),
}
}
pub fn full_url(&self, uri: &str) -> String {

View File

@@ -125,7 +125,7 @@ impl Client {
pub type ClientManager = EntityManager<Client>;
impl EntityManager<Client> {
impl ClientManager {
pub fn find_by_id(&self, u: &ClientID) -> Option<Client> {
for entry in self.iter() {
if entry.id.eq(u) {