Browse Source

Adjust visibility

ng
Rodolphe Bréard 4 weeks ago
parent
commit
be0a3e27dd
Failed to extract signature
  1. 14
      src/config.rs
  2. 22
      src/config/account.rs
  3. 66
      src/config/certificate.rs
  4. 16
      src/config/endpoint.rs
  5. 30
      src/config/global.rs
  6. 22
      src/config/hook.rs
  7. 6
      src/config/rate_limit.rs

14
src/config.rs

@ -23,19 +23,19 @@ const ALLOWED_FILE_EXT: &[&str] = &["toml"];
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct AcmedConfig { pub struct AcmedConfig {
pub global: Option<GlobalOptions>,
pub(in crate::config) global: Option<GlobalOptions>,
#[serde(default)] #[serde(default)]
pub endpoint: Vec<Endpoint>,
pub(in crate::config) endpoint: Vec<Endpoint>,
#[serde(default, rename = "rate-limit")] #[serde(default, rename = "rate-limit")]
pub rate_limit: Vec<RateLimit>,
pub(in crate::config) rate_limit: Vec<RateLimit>,
#[serde(default)] #[serde(default)]
pub hook: Vec<Hook>,
pub(in crate::config) hook: Vec<Hook>,
#[serde(default)] #[serde(default)]
pub group: Vec<Group>,
pub(in crate::config) group: Vec<Group>,
#[serde(default)] #[serde(default)]
pub account: Vec<Account>,
pub(in crate::config) account: Vec<Account>,
#[serde(default)] #[serde(default)]
pub certificate: Vec<Certificate>,
pub(in crate::config) certificate: Vec<Certificate>,
} }
pub fn load<P: AsRef<Path>>(config_dir: P) -> Result<AcmedConfig> { pub fn load<P: AsRef<Path>>(config_dir: P) -> Result<AcmedConfig> {

22
src/config/account.rs

@ -6,17 +6,17 @@ use std::collections::HashMap;
#[serde(remote = "Self")] #[serde(remote = "Self")]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Account { pub struct Account {
pub contacts: Vec<AccountContact>,
pub(in crate::config) contacts: Vec<AccountContact>,
#[serde(default)] #[serde(default)]
pub env: HashMap<String, String>,
pub external_account: Option<ExternalAccount>,
pub(in crate::config) env: HashMap<String, String>,
pub(in crate::config) external_account: Option<ExternalAccount>,
#[serde(default)] #[serde(default)]
pub hooks: Vec<String>,
pub(in crate::config) hooks: Vec<String>,
#[serde(default)] #[serde(default)]
pub key_type: AccountKeyType,
pub name: String,
pub(in crate::config) key_type: AccountKeyType,
pub(in crate::config) name: String,
#[serde(default)] #[serde(default)]
pub signature_algorithm: Option<AccountSignatureAlgorithm>,
pub(in crate::config) signature_algorithm: Option<AccountSignatureAlgorithm>,
} }
impl<'de> Deserialize<'de> for Account { impl<'de> Deserialize<'de> for Account {
@ -35,16 +35,16 @@ impl<'de> Deserialize<'de> for Account {
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)] #[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct AccountContact { pub struct AccountContact {
pub mailto: String,
pub(in crate::config) mailto: String,
} }
#[derive(Clone, Debug, Deserialize, Eq, PartialEq)] #[derive(Clone, Debug, Deserialize, Eq, PartialEq)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct ExternalAccount { pub struct ExternalAccount {
pub identifier: String,
pub key: String,
pub(in crate::config) identifier: String,
pub(in crate::config) key: String,
#[serde(default)] #[serde(default)]
pub signature_algorithm: ExternalAccountSignatureAlgorithm,
pub(in crate::config) signature_algorithm: ExternalAccountSignatureAlgorithm,
} }
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)] #[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]

66
src/config/certificate.rs

@ -9,25 +9,25 @@ use std::path::PathBuf;
#[serde(remote = "Self")] #[serde(remote = "Self")]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Certificate { pub struct Certificate {
pub account: String,
pub(in crate::config) account: String,
#[serde(default)] #[serde(default)]
pub csr_digest: CsrDigest,
pub directory: Option<PathBuf>,
pub endpoint: String,
pub(in crate::config) csr_digest: CsrDigest,
pub(in crate::config) directory: Option<PathBuf>,
pub(in crate::config) endpoint: String,
#[serde(default)] #[serde(default)]
pub env: HashMap<String, String>,
pub file_name_format: Option<String>,
pub hooks: Vec<String>,
pub identifiers: Vec<Identifier>,
pub(in crate::config) env: HashMap<String, String>,
pub(in crate::config) file_name_format: Option<String>,
pub(in crate::config) hooks: Vec<String>,
pub(in crate::config) identifiers: Vec<Identifier>,
#[serde(default)] #[serde(default)]
pub key_type: KeyType,
pub(in crate::config) key_type: KeyType,
#[serde(default)] #[serde(default)]
pub kp_reuse: bool,
pub name: Option<String>,
pub random_early_renew: Option<String>,
pub renew_delay: Option<String>,
pub(in crate::config) kp_reuse: bool,
pub(in crate::config) name: Option<String>,
pub(in crate::config) random_early_renew: Option<String>,
pub(in crate::config) renew_delay: Option<String>,
#[serde(default)] #[serde(default)]
pub subject_attributes: SubjectAttributes,
pub(in crate::config) subject_attributes: SubjectAttributes,
} }
impl<'de> Deserialize<'de> for Certificate { impl<'de> Deserialize<'de> for Certificate {
@ -60,11 +60,11 @@ pub enum CsrDigest {
#[serde(remote = "Self")] #[serde(remote = "Self")]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Identifier { pub struct Identifier {
pub challenge: AcmeChallenge,
pub dns: Option<String>,
pub(in crate::config) challenge: AcmeChallenge,
pub(in crate::config) dns: Option<String>,
#[serde(default)] #[serde(default)]
pub env: HashMap<String, String>,
pub ip: Option<String>,
pub(in crate::config) env: HashMap<String, String>,
pub(in crate::config) ip: Option<String>,
} }
impl<'de> Deserialize<'de> for Identifier { impl<'de> Deserialize<'de> for Identifier {
@ -127,21 +127,21 @@ pub enum KeyType {
#[derive(Clone, Debug, Default, Deserialize)] #[derive(Clone, Debug, Default, Deserialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct SubjectAttributes { pub struct SubjectAttributes {
pub country_name: Option<String>,
pub generation_qualifier: Option<String>,
pub given_name: Option<String>,
pub initials: Option<String>,
pub locality_name: Option<String>,
pub name: Option<String>,
pub organization_name: Option<String>,
pub organizational_unit_name: Option<String>,
pub pkcs9_email_address: Option<String>,
pub postal_address: Option<String>,
pub postal_code: Option<String>,
pub state_or_province_name: Option<String>,
pub street: Option<String>,
pub surname: Option<String>,
pub title: Option<String>,
pub(in crate::config) country_name: Option<String>,
pub(in crate::config) generation_qualifier: Option<String>,
pub(in crate::config) given_name: Option<String>,
pub(in crate::config) initials: Option<String>,
pub(in crate::config) locality_name: Option<String>,
pub(in crate::config) name: Option<String>,
pub(in crate::config) organization_name: Option<String>,
pub(in crate::config) organizational_unit_name: Option<String>,
pub(in crate::config) pkcs9_email_address: Option<String>,
pub(in crate::config) postal_address: Option<String>,
pub(in crate::config) postal_code: Option<String>,
pub(in crate::config) state_or_province_name: Option<String>,
pub(in crate::config) street: Option<String>,
pub(in crate::config) surname: Option<String>,
pub(in crate::config) title: Option<String>,
} }
#[cfg(test)] #[cfg(test)]

16
src/config/endpoint.rs

@ -4,17 +4,17 @@ use std::path::PathBuf;
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Endpoint { pub struct Endpoint {
pub file_name_format: Option<String>,
pub name: String,
pub random_early_renew: Option<String>,
pub(in crate::config) file_name_format: Option<String>,
pub(in crate::config) name: String,
pub(in crate::config) random_early_renew: Option<String>,
#[serde(default)] #[serde(default)]
pub rate_limits: Vec<String>,
pub renew_delay: Option<String>,
pub(in crate::config) rate_limits: Vec<String>,
pub(in crate::config) renew_delay: Option<String>,
#[serde(default)] #[serde(default)]
pub root_certificates: Vec<PathBuf>,
pub(in crate::config) root_certificates: Vec<PathBuf>,
#[serde(default)] #[serde(default)]
pub tos_agreed: bool,
pub url: String,
pub(in crate::config) tos_agreed: bool,
pub(in crate::config) url: String,
} }
#[cfg(test)] #[cfg(test)]

30
src/config/global.rs

@ -6,28 +6,28 @@ use std::path::PathBuf;
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct GlobalOptions { pub struct GlobalOptions {
#[serde(default = "get_default_accounts_directory")] #[serde(default = "get_default_accounts_directory")]
pub accounts_directory: PathBuf,
pub cert_file_group: Option<String>,
pub cert_file_mode: Option<u32>,
pub cert_file_user: Option<String>,
pub(in crate::config) accounts_directory: PathBuf,
pub(in crate::config) cert_file_group: Option<String>,
pub(in crate::config) cert_file_mode: Option<u32>,
pub(in crate::config) cert_file_user: Option<String>,
#[serde(default = "get_default_cert_file_ext")] #[serde(default = "get_default_cert_file_ext")]
pub cert_file_ext: String,
pub(in crate::config) cert_file_ext: String,
#[serde(default = "get_default_certificates_directory")] #[serde(default = "get_default_certificates_directory")]
pub certificates_directory: PathBuf,
pub(in crate::config) certificates_directory: PathBuf,
#[serde(default)] #[serde(default)]
pub env: HashMap<String, String>,
pub(in crate::config) env: HashMap<String, String>,
#[serde(default = "get_default_file_name_format")] #[serde(default = "get_default_file_name_format")]
pub file_name_format: String,
pub pk_file_group: Option<String>,
pub pk_file_mode: Option<u32>,
pub pk_file_user: Option<String>,
pub(in crate::config) file_name_format: String,
pub(in crate::config) pk_file_group: Option<String>,
pub(in crate::config) pk_file_mode: Option<u32>,
pub(in crate::config) pk_file_user: Option<String>,
#[serde(default = "get_default_pk_file_ext")] #[serde(default = "get_default_pk_file_ext")]
pub pk_file_ext: String,
pub random_early_renew: Option<String>,
pub(in crate::config) pk_file_ext: String,
pub(in crate::config) random_early_renew: Option<String>,
#[serde(default = "get_default_renew_delay")] #[serde(default = "get_default_renew_delay")]
pub renew_delay: String,
pub(in crate::config) renew_delay: String,
#[serde(default)] #[serde(default)]
pub root_certificates: Vec<PathBuf>,
pub(in crate::config) root_certificates: Vec<PathBuf>,
} }
fn get_default_lib_dir() -> PathBuf { fn get_default_lib_dir() -> PathBuf {

22
src/config/hook.rs

@ -7,17 +7,17 @@ use std::path::PathBuf;
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Hook { pub struct Hook {
#[serde(default)] #[serde(default)]
pub allow_failure: bool,
pub(in crate::config) allow_failure: bool,
#[serde(default)] #[serde(default)]
pub args: Vec<String>,
pub cmd: String,
pub name: String,
pub stderr: Option<PathBuf>,
pub stdin: Option<PathBuf>,
pub stdin_str: Option<String>,
pub stdout: Option<PathBuf>,
pub(in crate::config) args: Vec<String>,
pub(in crate::config) cmd: String,
pub(in crate::config) name: String,
pub(in crate::config) stderr: Option<PathBuf>,
pub(in crate::config) stdin: Option<PathBuf>,
pub(in crate::config) stdin_str: Option<String>,
pub(in crate::config) stdout: Option<PathBuf>,
#[serde(rename = "type")] #[serde(rename = "type")]
pub hook_type: Vec<HookType>,
pub(in crate::config) hook_type: Vec<HookType>,
} }
impl<'de> Deserialize<'de> for Hook { impl<'de> Deserialize<'de> for Hook {
@ -65,8 +65,8 @@ pub enum HookType {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct Group { pub struct Group {
pub hooks: Vec<String>,
pub name: String,
pub(in crate::config) hooks: Vec<String>,
pub(in crate::config) name: String,
} }
#[cfg(test)] #[cfg(test)]

6
src/config/rate_limit.rs

@ -3,9 +3,9 @@ use serde_derive::Deserialize;
#[derive(Clone, Debug, Deserialize)] #[derive(Clone, Debug, Deserialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
pub struct RateLimit { pub struct RateLimit {
pub name: String,
pub number: usize,
pub period: String,
pub(in crate::config) name: String,
pub(in crate::config) number: usize,
pub(in crate::config) period: String,
} }
#[cfg(test)] #[cfg(test)]

Loading…
Cancel
Save