60 lines
1.4 KiB
Rust
60 lines
1.4 KiB
Rust
use serde::{Deserialize, Serialize};
|
|
|
|
#[derive(Deserialize, Serialize)]
|
|
pub enum KillSwitchPolicy {
|
|
#[serde(alias = "allow-proxy")]
|
|
AllowProxies,
|
|
#[serde(alias = "full")]
|
|
Strict,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize)]
|
|
pub enum ClearnetPolicy {
|
|
#[serde(alias = "killswitched")]
|
|
Killwitched,
|
|
#[serde(alias = "allowed")]
|
|
Allowed,
|
|
}
|
|
|
|
#[derive(Deserialize, Serialize)]
|
|
pub struct Policy {
|
|
pub clearnet: Option<ClearnetPolicy>,
|
|
pub killswitch_mode: Option<KillSwitchPolicy>,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize)]
|
|
pub struct Config {
|
|
/// Paths to `geosite.dat', `geolite2.mmdb`
|
|
pub geo_files: [String; 2],
|
|
/// Routing settings similar to v2ray
|
|
pub routing: String,
|
|
/// Clearnet routing policies
|
|
pub policy: Option<Policy>,
|
|
}
|
|
|
|
// TODO: Think how to add other anonymisers
|
|
// Like VPN on localhost:10808
|
|
// it can be like:
|
|
// ```toml
|
|
// [[proxy]]
|
|
// name = "VPN"
|
|
// addr = "127.0.0.1:10808"
|
|
// type = "SOCKS5" # ...
|
|
// ```
|
|
//
|
|
|
|
impl Default for Config {
|
|
fn default() -> Self {
|
|
Self {
|
|
geo_files: [
|
|
String::from("/var/nsc/geodata/geolite2.mmdb"),
|
|
String::from("/var/nsc/geodata/geosite.dat"),
|
|
],
|
|
routing: String::from("/etc/nsc/routing.toml"),
|
|
policy: Some(Policy {
|
|
clearnet: Some(ClearnetPolicy::Allowed),
|
|
killswitch_mode: Some(KillSwitchPolicy::AllowProxies),
|
|
}),
|
|
}
|
|
}
|
|
}
|