Commit
Author: Mies van der Lippe [miesvanderlippe@gmail.com]
Committer: GitHub [noreply@github.com] Wed, 15 May 2024 16:49:26 +0000
Hash: 0a0ac88d88ed02e267aad6e9dace55e514871d7d
Timestamp: Wed, 15 May 2024 16:49:26 +0000 (5 months ago)

+48 -48 +/-5 browse
Allow external usage of parsing functions for SPF, DMARC and DKIM structs (#30)
Allow external usage of parsing functions for SPF, DMARC and DKIM structs (#30)

* Make Spf struct more accesible

For using the Spf parser in other packages

* Make DKIM struct more accesible

For using the Spf parser in other packages

* Make Dmarc struct more accesible

For using the Spf parser in other packages
1diff --git a/src/common/verify.rs b/src/common/verify.rs
2index af4d9a9..327cbfd 100644
3--- a/src/common/verify.rs
4+++ b/src/common/verify.rs
5 @@ -15,8 +15,8 @@ use crate::{dkim::Canonicalization, Error, IprevOutput, IprevResult, Resolver};
6 use super::crypto::{Algorithm, VerifyingKey};
7
8 pub struct DomainKey {
9- pub(crate) p: Box<dyn VerifyingKey + Send + Sync>,
10- pub(crate) f: u64,
11+ pub p: Box<dyn VerifyingKey + Send + Sync>,
12+ pub f: u64,
13 }
14
15 impl Resolver {
16 diff --git a/src/dkim/mod.rs b/src/dkim/mod.rs
17index d30306e..ea08812 100644
18--- a/src/dkim/mod.rs
19+++ b/src/dkim/mod.rs
20 @@ -47,23 +47,23 @@ pub struct Done;
21
22 #[derive(Debug, PartialEq, Eq, Clone, Default)]
23 pub struct Signature {
24- pub(crate) v: u32,
25- pub(crate) a: Algorithm,
26- pub(crate) d: String,
27- pub(crate) s: String,
28- pub(crate) b: Vec<u8>,
29- pub(crate) bh: Vec<u8>,
30- pub(crate) h: Vec<String>,
31- pub(crate) z: Vec<String>,
32- pub(crate) i: String,
33- pub(crate) l: u64,
34- pub(crate) x: u64,
35- pub(crate) t: u64,
36- pub(crate) r: bool, // RFC 6651
37- pub(crate) atps: Option<String>, // RFC 6541
38- pub(crate) atpsh: Option<HashAlgorithm>, // RFC 6541
39- pub(crate) ch: Canonicalization,
40- pub(crate) cb: Canonicalization,
41+ pub v: u32,
42+ pub a: Algorithm,
43+ pub d: String,
44+ pub s: String,
45+ pub b: Vec<u8>,
46+ pub bh: Vec<u8>,
47+ pub h: Vec<String>,
48+ pub z: Vec<String>,
49+ pub i: String,
50+ pub l: u64,
51+ pub x: u64,
52+ pub t: u64,
53+ pub r: bool, // RFC 6651
54+ pub atps: Option<String>, // RFC 6541
55+ pub atpsh: Option<HashAlgorithm>, // RFC 6541
56+ pub ch: Canonicalization,
57+ pub cb: Canonicalization,
58 }
59
60 #[derive(Debug, PartialEq, Eq, Clone)]
61 diff --git a/src/dmarc/mod.rs b/src/dmarc/mod.rs
62index 7dc5c63..eaa2dea 100644
63--- a/src/dmarc/mod.rs
64+++ b/src/dmarc/mod.rs
65 @@ -19,20 +19,20 @@ pub mod verify;
66
67 #[derive(Debug, Hash, Clone, PartialEq, Eq)]
68 pub struct Dmarc {
69- pub(crate) v: Version,
70- pub(crate) adkim: Alignment,
71- pub(crate) aspf: Alignment,
72- pub(crate) fo: Report,
73- pub(crate) np: Policy,
74- pub(crate) p: Policy,
75- pub(crate) psd: Psd,
76- pub(crate) pct: u8,
77- pub(crate) rf: u8,
78- pub(crate) ri: u32,
79- pub(crate) rua: Vec<URI>,
80- pub(crate) ruf: Vec<URI>,
81- pub(crate) sp: Policy,
82- pub(crate) t: bool,
83+ pub v: Version,
84+ pub adkim: Alignment,
85+ pub aspf: Alignment,
86+ pub fo: Report,
87+ pub np: Policy,
88+ pub p: Policy,
89+ pub psd: Psd,
90+ pub pct: u8,
91+ pub rf: u8,
92+ pub ri: u32,
93+ pub rua: Vec<URI>,
94+ pub ruf: Vec<URI>,
95+ pub sp: Policy,
96+ pub t: bool,
97 }
98
99 #[derive(Debug, Hash, Clone, PartialEq, Eq, Serialize, Deserialize)]
100 @@ -43,13 +43,13 @@ pub struct URI {
101 }
102
103 #[derive(Debug, Hash, Clone, PartialEq, Eq)]
104- pub(crate) enum Alignment {
105+ pub enum Alignment {
106 Relaxed,
107 Strict,
108 }
109
110 #[derive(Debug, Hash, Clone, PartialEq, Eq)]
111- pub(crate) enum Psd {
112+ pub enum Psd {
113 Yes,
114 No,
115 Default,
116 diff --git a/src/lib.rs b/src/lib.rs
117index 7957986..f49feef 100644
118--- a/src/lib.rs
119+++ b/src/lib.rs
120 @@ -439,7 +439,7 @@ pub enum IprevResult {
121 }
122
123 #[derive(Debug, Hash, PartialEq, Eq, Clone)]
124- pub(crate) enum Version {
125+ pub enum Version {
126 V1,
127 }
128
129 diff --git a/src/spf/mod.rs b/src/spf/mod.rs
130index 80ae823..96459cf 100644
131--- a/src/spf/mod.rs
132+++ b/src/spf/mod.rs
133 @@ -27,7 +27,7 @@ use crate::{is_within_pct, SpfOutput, SpfResult, Version};
134 */
135
136 #[derive(Debug, PartialEq, Eq, Clone)]
137- pub(crate) enum Qualifier {
138+ pub enum Qualifier {
139 Pass,
140 Fail,
141 SoftFail,
142 @@ -39,7 +39,7 @@ pub(crate) enum Qualifier {
143 / a / mx / ptr / ip4 / ip6 / exists )
144 */
145 #[derive(Debug, PartialEq, Eq, Clone)]
146- pub(crate) enum Mechanism {
147+ pub enum Mechanism {
148 All,
149 Include {
150 macro_string: Macro,
151 @@ -74,9 +74,9 @@ pub(crate) enum Mechanism {
152 directive = [ qualifier ] mechanism
153 */
154 #[derive(Debug, PartialEq, Eq, Clone)]
155- pub(crate) struct Directive {
156- pub(crate) qualifier: Qualifier,
157- pub(crate) mechanism: Mechanism,
158+ pub struct Directive {
159+ pub qualifier: Qualifier,
160+ pub mechanism: Mechanism,
161 }
162
163 /*
164 @@ -132,13 +132,13 @@ pub enum Macro {
165
166 #[derive(Debug, PartialEq, Eq, Clone)]
167 pub struct Spf {
168- version: Version,
169- directives: Vec<Directive>,
170- exp: Option<Macro>,
171- redirect: Option<Macro>,
172- ra: Option<Vec<u8>>,
173- rp: u8,
174- rr: u8,
175+ pub version: Version,
176+ pub directives: Vec<Directive>,
177+ pub exp: Option<Macro>,
178+ pub redirect: Option<Macro>,
179+ pub ra: Option<Vec<u8>>,
180+ pub rp: u8,
181+ pub rr: u8,
182 }
183
184 pub(crate) const RR_TEMP_PERM_ERROR: u8 = 0x01;