added the consts to the prelude and replaced derive aliases with attribute aliases
Dieser Commit ist enthalten in:
Ursprung
8b9bf2a77d
Commit
b8d49d91ba
12 geänderte Dateien mit 74 neuen und 93 gelöschten Zeilen
|
@ -1,4 +1,4 @@
|
||||||
use macro_rules_attribute::derive_alias;
|
use macro_rules_attribute::attribute_alias;
|
||||||
|
|
||||||
#[allow(unused_macros)]
|
#[allow(unused_macros)]
|
||||||
macro_rules! match_error {
|
macro_rules! match_error {
|
||||||
|
@ -24,9 +24,10 @@ macro_rules! attr_function {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
derive_alias! {
|
attribute_alias! {
|
||||||
#[derive(DefDer!)] = #[derive(Debug, Clone)];
|
#[apply(ConfigFile!)] = #[derive(::serde::Deserialize, ::schemars::JsonSchema)];
|
||||||
#[derive(Hashable!)] = #[derive(Eq, Hash)];
|
#[apply(Hashable!)] = #[derive(Eq,Hash)];
|
||||||
|
#[apply(DefDer!)] = #[derive(Debug, Clone)];
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
|
|
@ -19,7 +19,6 @@ pub(crate) mod types;
|
||||||
pub(crate) mod utils;
|
pub(crate) mod utils;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
consts::*,
|
|
||||||
prelude::*,
|
prelude::*,
|
||||||
types::{
|
types::{
|
||||||
config::{
|
config::{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
pub(crate) use crate::{
|
pub(crate) use crate::{
|
||||||
|
consts::*,
|
||||||
macros::*,
|
macros::*,
|
||||||
types::traits::{
|
types::traits::{
|
||||||
FromFile as _,
|
FromFile as _,
|
||||||
|
|
|
@ -19,15 +19,6 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
consts::{
|
|
||||||
ATTEMPTS,
|
|
||||||
FILE_MODE,
|
|
||||||
FILE_MODE_OVERWRITE,
|
|
||||||
MODE_PRIVATE,
|
|
||||||
MODE_PUBLIC,
|
|
||||||
MODE_SECRETS,
|
|
||||||
WAIT_TIME,
|
|
||||||
},
|
|
||||||
prelude::*,
|
prelude::*,
|
||||||
types::{
|
types::{
|
||||||
self,
|
self,
|
||||||
|
@ -93,8 +84,8 @@ use tokio::{
|
||||||
remove_file,
|
remove_file,
|
||||||
},
|
},
|
||||||
io::{
|
io::{
|
||||||
AsyncReadExt,
|
AsyncReadExt as _,
|
||||||
AsyncWriteExt,
|
AsyncWriteExt as _,
|
||||||
},
|
},
|
||||||
join,
|
join,
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,20 +16,19 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use macro_rules_attribute::macro_rules_derive;
|
use macro_rules_attribute::apply;
|
||||||
use openssl::pkey::{
|
use openssl::pkey::{
|
||||||
PKey,
|
PKey,
|
||||||
Private,
|
Private,
|
||||||
};
|
};
|
||||||
use schemars::JsonSchema;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
net::IpAddr,
|
net::IpAddr,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct General {
|
pub struct General {
|
||||||
#[serde(default = "General::default_accounts")]
|
#[serde(default = "General::default_accounts")]
|
||||||
|
@ -84,8 +83,8 @@ impl General {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Eab {
|
pub struct Eab {
|
||||||
#[serde(rename = "eab_token", alias = "id")]
|
#[serde(rename = "eab_token", alias = "id")]
|
||||||
|
@ -101,8 +100,8 @@ impl Eab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct CA {
|
pub struct CA {
|
||||||
/// Url for the directory
|
/// Url for the directory
|
||||||
|
@ -132,8 +131,9 @@ impl CA {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, Default, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
|
#[derive(Default)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Site {
|
pub struct Site {
|
||||||
/// The Configured Certificate Authority
|
/// The Configured Certificate Authority
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
use crate::{
|
use crate::prelude::*;
|
||||||
consts::RsaStrength,
|
use macro_rules_attribute::apply;
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
use macro_rules_attribute::macro_rules_derive;
|
|
||||||
use schemars::JsonSchema;
|
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Copy, Deserialize, Default, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
|
#[derive(Copy, Default)]
|
||||||
pub enum Algorithm {
|
pub enum Algorithm {
|
||||||
Rsa,
|
Rsa,
|
||||||
Brainpool,
|
Brainpool,
|
||||||
|
@ -18,8 +14,9 @@ pub enum Algorithm {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Copy, Deserialize, Default, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
|
#[derive(Copy, Default)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub enum Strength {
|
pub enum Strength {
|
||||||
Weak,
|
Weak,
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
use macro_rules_attribute::macro_rules_derive;
|
use macro_rules_attribute::apply;
|
||||||
use schemars::JsonSchema;
|
|
||||||
use serde::Deserialize;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
macros::DefDer,
|
macros::{
|
||||||
|
ConfigFile,
|
||||||
|
DefDer,
|
||||||
|
},
|
||||||
types::{
|
types::{
|
||||||
self,
|
self,
|
||||||
dns::Dns,
|
dns::Dns,
|
||||||
|
@ -12,8 +13,8 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct DNSUpdateClientOptions {}
|
pub struct DNSUpdateClientOptions {}
|
||||||
|
|
||||||
|
@ -23,7 +24,7 @@ impl DNSUpdateClientOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub struct DnsUpdateHandler {}
|
pub struct DnsUpdateHandler {}
|
||||||
|
|
||||||
impl DnsHandler for DnsUpdateHandler {
|
impl DnsHandler for DnsUpdateHandler {
|
||||||
|
@ -32,7 +33,7 @@ impl DnsHandler for DnsUpdateHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub struct DnsUpdateToken {}
|
pub struct DnsUpdateToken {}
|
||||||
|
|
||||||
impl DnsUpdateToken {
|
impl DnsUpdateToken {
|
||||||
|
|
|
@ -2,7 +2,10 @@ pub(super) mod dnsupdate;
|
||||||
pub(super) mod pdns;
|
pub(super) mod pdns;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
macros::DefDer,
|
macros::{
|
||||||
|
ConfigFile,
|
||||||
|
DefDer,
|
||||||
|
},
|
||||||
types::{
|
types::{
|
||||||
self,
|
self,
|
||||||
dns::{
|
dns::{
|
||||||
|
@ -19,21 +22,19 @@ use crate::{
|
||||||
DnsToken,
|
DnsToken,
|
||||||
Error,
|
Error,
|
||||||
},
|
},
|
||||||
traits::DnsHandler,
|
traits::DnsHandler as _,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use log::*;
|
use log::*;
|
||||||
use macro_rules_attribute::macro_rules_derive;
|
use macro_rules_attribute::apply;
|
||||||
use reqwest::Client;
|
use reqwest::Client;
|
||||||
use schemars::JsonSchema;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub struct Manager(Arc<Mutex<InnerManager>>, Client);
|
pub struct Manager(Arc<Mutex<InnerManager>>, Client);
|
||||||
|
|
||||||
impl Manager {
|
impl Manager {
|
||||||
|
@ -100,8 +101,9 @@ struct InnerManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, Default, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
|
#[derive(Default)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
#[serde(tag = "type", rename_all = "lowercase")]
|
#[serde(tag = "type", rename_all = "lowercase")]
|
||||||
pub enum Builder {
|
pub enum Builder {
|
||||||
|
@ -111,7 +113,7 @@ pub enum Builder {
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub enum Dns {
|
pub enum Dns {
|
||||||
PowerDNS(PdnsHandler),
|
PowerDNS(PdnsHandler),
|
||||||
DNSUpdate(DnsUpdateHandler),
|
DNSUpdate(DnsUpdateHandler),
|
||||||
|
|
|
@ -5,21 +5,23 @@ use std::time::{
|
||||||
|
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use log::*;
|
use log::*;
|
||||||
use macro_rules_attribute::macro_rules_derive;
|
use macro_rules_attribute::apply;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
Client,
|
Client,
|
||||||
RequestBuilder,
|
RequestBuilder,
|
||||||
StatusCode,
|
StatusCode,
|
||||||
Url,
|
Url,
|
||||||
};
|
};
|
||||||
use schemars::JsonSchema;
|
|
||||||
use serde::{
|
use serde::{
|
||||||
Deserialize,
|
Deserialize,
|
||||||
Serialize,
|
Serialize,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
macros::DefDer,
|
macros::{
|
||||||
|
ConfigFile,
|
||||||
|
DefDer,
|
||||||
|
},
|
||||||
types::{
|
types::{
|
||||||
self,
|
self,
|
||||||
dns::Dns,
|
dns::Dns,
|
||||||
|
@ -31,8 +33,8 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize, JsonSchema)]
|
#[apply(ConfigFile)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct PdnsClientOptions {
|
pub struct PdnsClientOptions {
|
||||||
api_key: String,
|
api_key: String,
|
||||||
|
@ -60,7 +62,7 @@ impl PdnsClientOptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub struct PdnsHandler {
|
pub struct PdnsHandler {
|
||||||
client: Client,
|
client: Client,
|
||||||
server: String,
|
server: String,
|
||||||
|
@ -179,7 +181,7 @@ impl PdnsToken {
|
||||||
|
|
||||||
unsafe impl Send for PdnsToken {}
|
unsafe impl Send for PdnsToken {}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct PdnsError {
|
pub struct PdnsError {
|
||||||
|
@ -188,7 +190,7 @@ pub struct PdnsError {
|
||||||
pub errors: Vec<String>,
|
pub errors: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Serialize, new)]
|
#[derive(Serialize, new)]
|
||||||
struct Comment {
|
struct Comment {
|
||||||
#[new(into)]
|
#[new(into)]
|
||||||
|
@ -207,7 +209,7 @@ impl Comment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Serialize, new)]
|
#[derive(Serialize, new)]
|
||||||
struct Record {
|
struct Record {
|
||||||
content: String,
|
content: String,
|
||||||
|
@ -216,7 +218,7 @@ struct Record {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(tag = "changetype", rename_all = "UPPERCASE")]
|
#[serde(tag = "changetype", rename_all = "UPPERCASE")]
|
||||||
enum ChangeType {
|
enum ChangeType {
|
||||||
|
@ -228,7 +230,7 @@ enum ChangeType {
|
||||||
Delete,
|
Delete,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Serialize, new)]
|
#[derive(Serialize, new)]
|
||||||
struct RRSet {
|
struct RRSet {
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -239,7 +241,7 @@ struct RRSet {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Serialize, new)]
|
#[derive(Serialize, new)]
|
||||||
struct RecordUpdate {
|
struct RecordUpdate {
|
||||||
rrsets: Vec<RRSet>,
|
rrsets: Vec<RRSet>,
|
||||||
|
|
|
@ -15,7 +15,7 @@ use clap::{
|
||||||
Subcommand,
|
Subcommand,
|
||||||
};
|
};
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use macro_rules_attribute::macro_rules_derive;
|
use macro_rules_attribute::apply;
|
||||||
use openssl::x509::X509;
|
use openssl::x509::X509;
|
||||||
use reqwest::{
|
use reqwest::{
|
||||||
Client,
|
Client,
|
||||||
|
@ -41,7 +41,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
pub struct Arguments {
|
pub struct Arguments {
|
||||||
pub config: String,
|
pub config: String,
|
||||||
|
@ -49,13 +49,13 @@ pub struct Arguments {
|
||||||
pub subcommands: Option<SubCommand>,
|
pub subcommands: Option<SubCommand>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub enum SubCommand {
|
pub enum SubCommand {
|
||||||
Schema,
|
Schema,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
#[derive(new)]
|
#[derive(new)]
|
||||||
pub struct ProcessorArgs<'a> {
|
pub struct ProcessorArgs<'a> {
|
||||||
|
@ -129,7 +129,8 @@ impl<'a: 'b, 'b> ProcessorArgs<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer, Hashable)]
|
#[apply(DefDer)]
|
||||||
|
#[apply(Hashable)]
|
||||||
#[derive(PartialEq)]
|
#[derive(PartialEq)]
|
||||||
pub enum San {
|
pub enum San {
|
||||||
Dns(String),
|
Dns(String),
|
||||||
|
@ -137,7 +138,7 @@ pub enum San {
|
||||||
IPAddress(IpAddr),
|
IPAddress(IpAddr),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
#[derive(derive_new::new)]
|
#[derive(derive_new::new)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
pub(super) message: String,
|
pub(super) message: String,
|
||||||
|
@ -163,7 +164,7 @@ impl Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub enum DnsToken {
|
pub enum DnsToken {
|
||||||
None,
|
None,
|
||||||
Pdns(Box<PdnsToken>),
|
Pdns(Box<PdnsToken>),
|
||||||
|
@ -192,7 +193,7 @@ impl DnsToken {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_rules_derive(DefDer)]
|
#[apply(DefDer)]
|
||||||
pub struct Certificate {
|
pub struct Certificate {
|
||||||
pub cert: X509,
|
pub cert: X509,
|
||||||
pub account_id: Option<String>,
|
pub account_id: Option<String>,
|
||||||
|
|
|
@ -2,16 +2,9 @@ use std::collections::HashSet;
|
||||||
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
consts::{
|
prelude::*,
|
||||||
BRAINPOOL_MIDDLE,
|
|
||||||
BRAINPOOL_STRONG,
|
|
||||||
BRAINPOOL_WEAK,
|
|
||||||
SECP_MIDDLE,
|
|
||||||
SECP_STRONG,
|
|
||||||
SECP_WEAK,
|
|
||||||
},
|
|
||||||
types,
|
|
||||||
types::{
|
types::{
|
||||||
|
self,
|
||||||
cryptography::{
|
cryptography::{
|
||||||
Algorithm,
|
Algorithm,
|
||||||
Strength,
|
Strength,
|
||||||
|
@ -36,7 +29,7 @@ use serde::de::DeserializeOwned;
|
||||||
use std::fmt::Debug as fmtDebug;
|
use std::fmt::Debug as fmtDebug;
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::AsyncReadExt,
|
io::AsyncReadExt as _,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait FromFile: Default + DeserializeOwned {
|
pub trait FromFile: Default + DeserializeOwned {
|
||||||
|
|
|
@ -7,14 +7,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
consts::{
|
prelude::*,
|
||||||
BRAINPOOL_MIDDLE,
|
|
||||||
BRAINPOOL_STRONG,
|
|
||||||
BRAINPOOL_WEAK,
|
|
||||||
SECP_MIDDLE,
|
|
||||||
SECP_STRONG,
|
|
||||||
SECP_WEAK,
|
|
||||||
},
|
|
||||||
types::{
|
types::{
|
||||||
cryptography::{
|
cryptography::{
|
||||||
Algorithm,
|
Algorithm,
|
||||||
|
|
Laden …
Tabelle hinzufügen
In neuem Issue referenzieren