Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow external usage of parsing functions for SPF, DMARC and DKIM structs #30

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/common/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::{dkim::Canonicalization, Error, IprevOutput, IprevResult, Resolver};
use super::crypto::{Algorithm, VerifyingKey};

pub struct DomainKey {
pub(crate) p: Box<dyn VerifyingKey + Send + Sync>,
pub(crate) f: u64,
pub p: Box<dyn VerifyingKey + Send + Sync>,
pub f: u64,
}

impl Resolver {
Expand Down
34 changes: 17 additions & 17 deletions src/dkim/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,23 @@ pub struct Done;

#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct Signature {
pub(crate) v: u32,
pub(crate) a: Algorithm,
pub(crate) d: String,
pub(crate) s: String,
pub(crate) b: Vec<u8>,
pub(crate) bh: Vec<u8>,
pub(crate) h: Vec<String>,
pub(crate) z: Vec<String>,
pub(crate) i: String,
pub(crate) l: u64,
pub(crate) x: u64,
pub(crate) t: u64,
pub(crate) r: bool, // RFC 6651
pub(crate) atps: Option<String>, // RFC 6541
pub(crate) atpsh: Option<HashAlgorithm>, // RFC 6541
pub(crate) ch: Canonicalization,
pub(crate) cb: Canonicalization,
pub v: u32,
pub a: Algorithm,
pub d: String,
pub s: String,
pub b: Vec<u8>,
pub bh: Vec<u8>,
pub h: Vec<String>,
pub z: Vec<String>,
pub i: String,
pub l: u64,
pub x: u64,
pub t: u64,
pub r: bool, // RFC 6651
pub atps: Option<String>, // RFC 6541
pub atpsh: Option<HashAlgorithm>, // RFC 6541
pub ch: Canonicalization,
pub cb: Canonicalization,
}

#[derive(Debug, PartialEq, Eq, Clone)]
Expand Down
32 changes: 16 additions & 16 deletions src/dmarc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ pub mod verify;

#[derive(Debug, Hash, Clone, PartialEq, Eq)]
pub struct Dmarc {
pub(crate) v: Version,
pub(crate) adkim: Alignment,
pub(crate) aspf: Alignment,
pub(crate) fo: Report,
pub(crate) np: Policy,
pub(crate) p: Policy,
pub(crate) psd: Psd,
pub(crate) pct: u8,
pub(crate) rf: u8,
pub(crate) ri: u32,
pub(crate) rua: Vec<URI>,
pub(crate) ruf: Vec<URI>,
pub(crate) sp: Policy,
pub(crate) t: bool,
pub v: Version,
pub adkim: Alignment,
pub aspf: Alignment,
pub fo: Report,
pub np: Policy,
pub p: Policy,
pub psd: Psd,
pub pct: u8,
pub rf: u8,
pub ri: u32,
pub rua: Vec<URI>,
pub ruf: Vec<URI>,
pub sp: Policy,
pub t: bool,
}

#[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand All @@ -43,13 +43,13 @@ pub struct URI {
}

#[derive(Debug, Hash, Clone, PartialEq, Eq)]
pub(crate) enum Alignment {
pub enum Alignment {
Relaxed,
Strict,
}

#[derive(Debug, Hash, Clone, PartialEq, Eq)]
pub(crate) enum Psd {
pub enum Psd {
Yes,
No,
Default,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ pub enum IprevResult {
}

#[derive(Debug, Hash, PartialEq, Eq, Clone)]
pub(crate) enum Version {
pub enum Version {
V1,
}

Expand Down
24 changes: 12 additions & 12 deletions src/spf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{is_within_pct, SpfOutput, SpfResult, Version};
*/

#[derive(Debug, PartialEq, Eq, Clone)]
pub(crate) enum Qualifier {
pub enum Qualifier {
Pass,
Fail,
SoftFail,
Expand All @@ -39,7 +39,7 @@ pub(crate) enum Qualifier {
/ a / mx / ptr / ip4 / ip6 / exists )
*/
#[derive(Debug, PartialEq, Eq, Clone)]
pub(crate) enum Mechanism {
pub enum Mechanism {
All,
Include {
macro_string: Macro,
Expand Down Expand Up @@ -74,9 +74,9 @@ pub(crate) enum Mechanism {
directive = [ qualifier ] mechanism
*/
#[derive(Debug, PartialEq, Eq, Clone)]
pub(crate) struct Directive {
pub(crate) qualifier: Qualifier,
pub(crate) mechanism: Mechanism,
pub struct Directive {
pub qualifier: Qualifier,
pub mechanism: Mechanism,
}

/*
Expand Down Expand Up @@ -132,13 +132,13 @@ pub enum Macro {

#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Spf {
version: Version,
directives: Vec<Directive>,
exp: Option<Macro>,
redirect: Option<Macro>,
ra: Option<Vec<u8>>,
rp: u8,
rr: u8,
pub version: Version,
pub directives: Vec<Directive>,
pub exp: Option<Macro>,
pub redirect: Option<Macro>,
pub ra: Option<Vec<u8>>,
pub rp: u8,
pub rr: u8,
}

pub(crate) const RR_TEMP_PERM_ERROR: u8 = 0x01;
Expand Down
Loading