Skip to content

Commit a8b4624

Browse files
committed
refactor: create new configuration v1 mod with figment
- Clone config strcuctures into a new mod `v1`. - Introduce versioning for configuration API. - Split config sections into submodules. TODO: - Still using root mod types in production. - Not using figment to build config in production.
1 parent 18f4166 commit a8b4624

File tree

6 files changed

+515
-2
lines changed

6 files changed

+515
-2
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use serde::{Deserialize, Serialize};
2+
use serde_with::serde_as;
3+
4+
/// Configuration for the Health Check API.
5+
#[serde_as]
6+
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
7+
pub struct HealthCheckApi {
8+
/// The address the API will bind to.
9+
/// The format is `ip:port`, for example `127.0.0.1:1313`. If you want to
10+
/// listen to all interfaces, use `0.0.0.0`. If you want the operating
11+
/// system to choose a random port, use port `0`.
12+
pub bind_address: String,
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use serde::{Deserialize, Serialize};
2+
use serde_with::{serde_as, NoneAsEmptyString};
3+
4+
/// Configuration for each HTTP tracker.
5+
#[serde_as]
6+
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Clone)]
7+
pub struct HttpTracker {
8+
/// Weather the HTTP tracker is enabled or not.
9+
pub enabled: bool,
10+
/// The address the tracker will bind to.
11+
/// The format is `ip:port`, for example `0.0.0.0:6969`. If you want to
12+
/// listen to all interfaces, use `0.0.0.0`. If you want the operating
13+
/// system to choose a random port, use port `0`.
14+
pub bind_address: String,
15+
/// Weather the HTTP tracker will use SSL or not.
16+
pub ssl_enabled: bool,
17+
/// Path to the SSL certificate file. Only used if `ssl_enabled` is `true`.
18+
#[serde_as(as = "NoneAsEmptyString")]
19+
pub ssl_cert_path: Option<String>,
20+
/// Path to the SSL key file. Only used if `ssl_enabled` is `true`.
21+
#[serde_as(as = "NoneAsEmptyString")]
22+
pub ssl_key_path: Option<String>,
23+
}

0 commit comments

Comments
 (0)