mirror of
https://github.com/TrustTunnel/TrustTunnel.git
synced 2026-04-28 03:39:53 +00:00
Support new fields in setup_wizard
This commit is contained in:
parent
a26237d702
commit
c8633e7736
3 changed files with 39 additions and 5 deletions
|
|
@ -178,17 +178,17 @@ pub struct Settings {
|
|||
#[serde(deserialize_with = "deserialize_rules")]
|
||||
pub(crate) rules_engine: Option<rules::RulesEngine>,
|
||||
|
||||
/// Whether speedtest is available on the main hosts via `/speed` path.
|
||||
/// Whether speedtest is available on the main hosts.
|
||||
#[serde(default = "Settings::default_speedtest_enable")]
|
||||
pub(crate) speedtest_enable: bool,
|
||||
/// Whether ping is available on the main hosts.
|
||||
#[serde(default = "Settings::default_ping_enable")]
|
||||
pub(crate) ping_enable: bool,
|
||||
/// Optional path prefix for ping requests on main hosts.
|
||||
#[serde(default)]
|
||||
#[serde(default = "Settings::default_ping_path")]
|
||||
pub(crate) ping_path: Option<String>,
|
||||
/// Optional path prefix for speedtest requests on main hosts.
|
||||
#[serde(default)]
|
||||
#[serde(default = "Settings::default_speedtest_path")]
|
||||
pub(crate) speedtest_path: Option<String>,
|
||||
/// Default maximum number of simultaneous HTTP/1 and HTTP/2 connections per client credentials.
|
||||
/// TrustTunnel clients open 8 HTTP/2 connections by default, so set this to
|
||||
|
|
@ -566,10 +566,18 @@ impl Settings {
|
|||
false
|
||||
}
|
||||
|
||||
pub fn default_speedtest_path() -> Option<String> {
|
||||
Some("/speedtest".to_string())
|
||||
}
|
||||
|
||||
pub fn default_ping_enable() -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn default_ping_path() -> Option<String> {
|
||||
Some("/ping".to_string())
|
||||
}
|
||||
|
||||
fn validate_request_path(name: &str, path: &Option<String>) -> Result<(), ValidationError> {
|
||||
if let Some(path) = path {
|
||||
if path.is_empty() || !path.starts_with('/') {
|
||||
|
|
@ -879,8 +887,8 @@ impl SettingsBuilder {
|
|||
rules_engine: Some(rules::RulesEngine::default_allow()),
|
||||
speedtest_enable: Settings::default_speedtest_enable(),
|
||||
ping_enable: Settings::default_ping_enable(),
|
||||
ping_path: None,
|
||||
speedtest_path: None,
|
||||
ping_path: Settings::default_ping_path(),
|
||||
speedtest_path: Settings::default_speedtest_path(),
|
||||
default_max_http2_conns_per_client: None,
|
||||
default_max_http3_conns_per_client: None,
|
||||
built: true,
|
||||
|
|
|
|||
|
|
@ -40,6 +40,17 @@ fn compose_main_table(settings: &Settings, credentials_path: &str, rules_path: &
|
|||
doc["udp_connections_timeout_secs"] =
|
||||
value(settings.get_udp_connections_timeout().as_secs() as i64);
|
||||
doc["speedtest_enable"] = value(*settings.get_speedtest_enable());
|
||||
if let Some(path) = settings.get_speedtest_path().as_ref() {
|
||||
doc["speedtest_path"] = value(path.clone());
|
||||
} else {
|
||||
doc.remove("speedtest_path");
|
||||
}
|
||||
doc["ping_enable"] = value(*settings.get_ping_enable());
|
||||
if let Some(path) = settings.get_ping_path().as_ref() {
|
||||
doc["ping_path"] = value(path.clone());
|
||||
} else {
|
||||
doc.remove("ping_path");
|
||||
}
|
||||
|
||||
doc.to_string()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,15 @@ udp_connections_timeout_secs = {}
|
|||
|
||||
{}
|
||||
speedtest_enable = {}
|
||||
|
||||
{}
|
||||
speedtest_path = "{}"
|
||||
|
||||
{}
|
||||
ping_enable = {}
|
||||
|
||||
{}
|
||||
ping_path = "{}"
|
||||
"#,
|
||||
Settings::doc_listen_address().to_toml_comment(),
|
||||
crate::library_settings::DEFAULT_CREDENTIALS_PATH,
|
||||
|
|
@ -91,6 +100,12 @@ speedtest_enable = {}
|
|||
Settings::default_udp_connections_timeout().as_secs(),
|
||||
Settings::doc_speedtest_enable().to_toml_comment(),
|
||||
Settings::default_speedtest_enable(),
|
||||
Settings::doc_speedtest_path().to_toml_comment(),
|
||||
Settings::default_speedtest_path().unwrap(),
|
||||
Settings::doc_ping_enable().to_toml_comment(),
|
||||
Settings::default_ping_enable(),
|
||||
Settings::doc_ping_path().to_toml_comment(),
|
||||
Settings::default_ping_path().unwrap(),
|
||||
)
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue