Finalize nx9-wg production release
This commit is contained in:
1 parent
4dfe42fe68
commit
d704c1e131
30 files changed
+2502
-370
No files matched your search
+45
-19
@@ -1351,7 +1351,48 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
}
|
||||
}
|
||||
SettingsSubcommands::Set { key, value, secret } => {
|
||||
store.set_setting(&key, &value, secret).await?;
|
||||
let key_trimmed = key.trim();
|
||||
let val_trimmed = value.trim();
|
||||
if key_trimmed == nx9_wg_core::types::settings::SETTING_SERVER_HOST {
|
||||
if !val_trimmed.is_empty() {
|
||||
nx9_wg_core::validation::validate_server_host(val_trimmed)?;
|
||||
}
|
||||
} else if key_trimmed == nx9_wg_core::types::settings::SETTING_SERVER_PORT {
|
||||
let port: u16 = val_trimmed.parse().map_err(
|
||||
|_| "Invalid server port: must be an integer between 1 and 65535",
|
||||
)?;
|
||||
nx9_wg_core::validation::validate_server_port(port)?;
|
||||
} else if key_trimmed
|
||||
== nx9_wg_core::types::settings::SETTING_SERVER_ENDPOINT_ENABLED
|
||||
&& val_trimmed != "true"
|
||||
&& val_trimmed != "false"
|
||||
&& val_trimmed != "1"
|
||||
&& val_trimmed != "0"
|
||||
{
|
||||
return Err("Setting wireguard.server_endpoint_enabled must be 'true' or 'false'".into());
|
||||
}
|
||||
store.set_setting(key_trimmed, val_trimmed, secret).await?;
|
||||
if (key_trimmed == nx9_wg_core::types::settings::SETTING_SERVER_HOST
|
||||
|| key_trimmed == nx9_wg_core::types::settings::SETTING_SERVER_PORT
|
||||
|| key_trimmed
|
||||
== nx9_wg_core::types::settings::SETTING_SERVER_ENDPOINT_ENABLED)
|
||||
&& let Ok(settings) = store.get_server_endpoint_settings().await
|
||||
&& settings.enabled
|
||||
&& !settings.host.trim().is_empty()
|
||||
{
|
||||
let formatted = nx9_wg_core::validation::format_endpoint(
|
||||
&settings.host,
|
||||
settings.port,
|
||||
);
|
||||
let _ = store
|
||||
.set_setting(
|
||||
nx9_wg_core::types::settings::LEGACY_SETTING_SERVER_ENDPOINT,
|
||||
&formatted,
|
||||
false,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
println!("Setting '{key}' saved.");
|
||||
}
|
||||
SettingsSubcommands::Delete { key } => {
|
||||
@@ -2089,15 +2130,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
None
|
||||
};
|
||||
|
||||
let server_host = if let Some(ref ep) = endpoint {
|
||||
ep.trim().to_string()
|
||||
} else if let Some(s) = store.get_setting("server_endpoint").await? {
|
||||
s.value.trim().to_string()
|
||||
} else if let Some(s) = store.get_setting("public_endpoint").await? {
|
||||
s.value.trim().to_string()
|
||||
} else {
|
||||
return Err("No reachable WireGuard server endpoint is configured. Configure 'server_endpoint' in settings or provide --endpoint.".into());
|
||||
};
|
||||
let server_host = store.resolve_server_endpoint(endpoint.as_deref()).await?;
|
||||
|
||||
let conf = ClientConfigBuilder::build_with_profile(
|
||||
&peer,
|
||||
@@ -2173,15 +2206,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
None
|
||||
};
|
||||
|
||||
let server_host = if let Some(ref ep) = endpoint {
|
||||
ep.trim().to_string()
|
||||
} else if let Some(s) = store.get_setting("server_endpoint").await? {
|
||||
s.value.trim().to_string()
|
||||
} else if let Some(s) = store.get_setting("public_endpoint").await? {
|
||||
s.value.trim().to_string()
|
||||
} else {
|
||||
return Err("No reachable WireGuard server endpoint is configured. Configure 'server_endpoint' in settings or provide --endpoint.".into());
|
||||
};
|
||||
let server_host = store.resolve_server_endpoint(endpoint.as_deref()).await?;
|
||||
|
||||
let conf = ClientConfigBuilder::build_with_profile(
|
||||
&peer,
|
||||
@@ -2189,6 +2214,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
&server_host,
|
||||
resolved_profile.as_ref(),
|
||||
)?;
|
||||
|
||||
match qr_format.to_lowercase().as_str() {
|
||||
"svg" => {
|
||||
let svg = generate_qr_svg(&conf)?;
|
||||
|
||||
Reference in new issue
Block a user