Pull request 78: Add command to generate client's config

Squashed commit of the following:

commit d7c1d780d9b58a9108330fb37f7278f01397dc2f
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Tue Jul 22 22:40:56 2025 +0400

    Fix docs for certificate

commit 045c8d3170f825335cca084b9f0b46e2b0e99553
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Tue Jul 22 22:39:59 2025 +0400

    Fulfill the generated config with all remaing fields from [endpoint] config section

commit 1ab3271c0785a75fc89ec4f7f9bd214516d3d16d
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Tue Jul 22 22:30:10 2025 +0400

    Fix has_ipv6 description

commit 21f138edca65d7aa1606881d58789a51790f601c
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Tue Jul 22 19:08:34 2025 +0400

    Place has_ipv6 after addresses

commit 0b520c398cede67557fbb2669d0d46e8daaf5823
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Tue Jul 22 19:01:58 2025 +0400

    Add has_ipv6 field to client's config

commit 03c692e63f2d6a91f4ccd332627f44eb00f6066a
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Mon Jun 16 14:38:40 2025 +0400

    Do not create authenticator if there are no clients

commit e16d2de1063dfadc244c0605bddecbcd56e55514
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Thu Jun 5 18:45:10 2025 +0400

    Introduce client's config generator

commit bb83e046c1ae71fca63033c515152780be4412ba
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Thu Jun 5 17:08:01 2025 +0400

    Move ToTomlComment trait to utils

commit a170584d76684c8960c218146e7a10672a373863
Author: Andrey Yakushin <a.yakushin@adguard.com>
Date:   Thu Jun 5 17:07:01 2025 +0400

    Move authenticator out of settings
This commit is contained in:
Andrey Yakushin
2025-07-28 11:36:53 +03:00
parent 8e018cd56a
commit b7a95f5a71
12 changed files with 209 additions and 53 deletions

View File

@@ -1,9 +1,8 @@
use std::iter::once;
use toml_edit::{Document, value};
use vpn_libs_endpoint::settings::{ForwardProtocolSettings, Http1Settings, Http2Settings, IcmpSettings, ListenProtocolSettings, MetricsSettings, QuicSettings, Settings};
use vpn_libs_endpoint::utils::IterJoin;
use vpn_libs_endpoint::utils::{IterJoin, ToTomlComment};
use crate::template_settings;
use crate::template_settings::ToTomlComment;
pub fn compose_document(settings: &Settings, credentials_path: &str) -> String {
once(compose_main_table(settings, credentials_path))

View File

@@ -1,26 +1,6 @@
use once_cell::sync::Lazy;
use vpn_libs_endpoint::settings::{ForwardProtocolSettings, Http1Settings, Http2Settings, IcmpSettings, ListenProtocolSettings, MetricsSettings, QuicSettings, Settings, Socks5ForwarderSettings};
use vpn_libs_endpoint::utils::IterJoin;
pub trait ToTomlComment {
/// Prepend each line of string with "# " turning
/// the whole string it into TOML comment.
fn to_toml_comment(&self) -> String;
}
impl ToTomlComment for &str {
fn to_toml_comment(&self) -> String {
self.lines()
.map(|x| format!("# {x}"))
.join("\n")
}
}
impl ToTomlComment for String {
fn to_toml_comment(&self) -> String {
self.as_str().to_toml_comment()
}
}
use vpn_libs_endpoint::utils::ToTomlComment;
pub static MAIN_TABLE: Lazy<String> = Lazy::new(|| format!(
r#"{}