Commit
+33 -35 +/-8 browse
1 | diff --git a/CHANGELOG.md b/CHANGELOG.md |
2 | index 7c1e2de..8505437 100644 |
3 | --- a/CHANGELOG.md |
4 | +++ b/CHANGELOG.md |
5 | @@ -1,3 +1,8 @@ |
6 | + mail-auth 0.3.3 |
7 | + ================================ |
8 | + - Bump `mail-parser` dependency to 0.9 |
9 | + - Bump `trust-dns-resolver` dependency to 0.23 |
10 | + |
11 | mail-auth 0.3.2 |
12 | ================================ |
13 | - Bump `mail-builder` dependency to 0.3 |
14 | diff --git a/Cargo.toml b/Cargo.toml |
15 | index 1e767b5..196a6da 100644 |
16 | --- a/Cargo.toml |
17 | +++ b/Cargo.toml |
18 | @@ -1,7 +1,7 @@ |
19 | [package] |
20 | name = "mail-auth" |
21 | description = "DKIM, ARC, SPF and DMARC library for Rust" |
22 | - version = "0.3.2" |
23 | + version = "0.3.3" |
24 | edition = "2021" |
25 | authors = [ "Stalwart Labs <hello@stalw.art>"] |
26 | license = "Apache-2.0 OR MIT" |
27 | @@ -22,21 +22,21 @@ test = [] |
28 | |
29 | [dependencies] |
30 | ahash = "0.8.0" |
31 | - ed25519-dalek = { version = "1.0.1", optional = true } |
32 | + ed25519-dalek = { version = "1.0", optional = true } |
33 | flate2 = "1.0.25" |
34 | lru-cache = "0.1.2" |
35 | - mail-parser = { version = "0.8", git = "https://github.com/stalwartlabs/mail-parser", features = ["ludicrous_mode", "full_encoding"] } |
36 | + mail-parser = { version = "0.9", git = "https://github.com/stalwartlabs/mail-parser", features = ["ludicrous_mode", "full_encoding"] } |
37 | mail-builder = { version = "0.3", git = "https://github.com/stalwartlabs/mail-builder", features = ["ludicrous_mode"] } |
38 | parking_lot = "0.12.0" |
39 | - quick-xml = "0.28" |
40 | + quick-xml = "0.30" |
41 | ring = { version = "0.16.20", optional = true } |
42 | - rsa = { version = "0.7.0", optional = true } |
43 | + rsa = { version = "0.7", optional = true } |
44 | rustls-pemfile = { version = "1", optional = true } |
45 | serde = { version = "1.0", features = ["derive"] } |
46 | serde_json = "1.0" |
47 | sha1 = { version = "0.10", features = ["oid"], optional = true } |
48 | sha2 = { version = "0.10.6", features = ["oid"], optional = true } |
49 | - trust-dns-resolver = { version = "0.22.0", features = ["dns-over-rustls", "dnssec-ring"] } |
50 | + trust-dns-resolver = { version = "0.23", features = ["dns-over-rustls", "dnssec-ring"] } |
51 | zip = "0.6.3" |
52 | |
53 | [dev-dependencies] |
54 | diff --git a/src/common/headers.rs b/src/common/headers.rs |
55 | index 51cdb07..2cf0265 100644 |
56 | --- a/src/common/headers.rs |
57 | +++ b/src/common/headers.rs |
58 | @@ -539,7 +539,7 @@ mod test { |
59 | |
60 | #[test] |
61 | fn chained_header_iterator() { |
62 | - let parts = vec![ |
63 | + let parts = [ |
64 | &b"From: a\nTo: b\nEmpty:\nMulti: 1\n 2\n"[..], |
65 | &b"Subject: c\nReceived: d\n\nhey"[..], |
66 | ]; |
67 | diff --git a/src/common/message.rs b/src/common/message.rs |
68 | index 7575405..e570a29 100644 |
69 | --- a/src/common/message.rs |
70 | +++ b/src/common/message.rs |
71 | @@ -8,7 +8,7 @@ |
72 | * except according to those terms. |
73 | */ |
74 | |
75 | - use mail_parser::{parsers::MessageStream, HeaderValue}; |
76 | + use mail_parser::{parsers::MessageStream, Address, HeaderValue}; |
77 | |
78 | use crate::{arc, common::crypto::HashAlgorithm, dkim, AuthenticatedMessage}; |
79 | |
80 | @@ -96,26 +96,13 @@ impl<'x> AuthenticatedMessage<'x> { |
81 | } |
82 | AuthenticatedHeader::From(name) => { |
83 | match MessageStream::new(value).parse_address() { |
84 | - HeaderValue::Address(addr) => { |
85 | - if let Some(addr) = addr.address { |
86 | - message.from.push(addr.to_lowercase()); |
87 | - } |
88 | - } |
89 | - HeaderValue::AddressList(list) => { |
90 | + HeaderValue::Address(Address::List(list)) => { |
91 | message.from.extend( |
92 | list.into_iter() |
93 | .filter_map(|a| a.address.map(|a| a.to_lowercase())), |
94 | ); |
95 | } |
96 | - HeaderValue::Group(group) => { |
97 | - message.from.extend( |
98 | - group |
99 | - .addresses |
100 | - .into_iter() |
101 | - .filter_map(|a| a.address.map(|a| a.to_lowercase())), |
102 | - ); |
103 | - } |
104 | - HeaderValue::GroupList(group_list) => { |
105 | + HeaderValue::Address(Address::Group(group_list)) => { |
106 | message |
107 | .from |
108 | .extend(group_list.into_iter().flat_map(|group| { |
109 | diff --git a/src/common/resolver.rs b/src/common/resolver.rs |
110 | index 85d566c..87b0e2c 100644 |
111 | --- a/src/common/resolver.rs |
112 | +++ b/src/common/resolver.rs |
113 | @@ -72,7 +72,7 @@ impl Resolver { |
114 | capacity: usize, |
115 | ) -> Result<Self, ResolveError> { |
116 | Ok(Self { |
117 | - resolver: AsyncResolver::tokio(config, options)?, |
118 | + resolver: AsyncResolver::tokio(config, options), |
119 | cache_txt: LruCache::with_capacity(capacity), |
120 | cache_mx: LruCache::with_capacity(capacity), |
121 | cache_ipv4: LruCache::with_capacity(capacity), |
122 | @@ -91,7 +91,7 @@ impl Resolver { |
123 | ptr_capacity: usize, |
124 | ) -> Result<Self, ResolveError> { |
125 | Ok(Self { |
126 | - resolver: AsyncResolver::tokio(config, options)?, |
127 | + resolver: AsyncResolver::tokio(config, options), |
128 | cache_txt: LruCache::with_capacity(txt_capacity), |
129 | cache_mx: LruCache::with_capacity(mx_capacity), |
130 | cache_ipv4: LruCache::with_capacity(ipv4_capacity), |
131 | @@ -196,10 +196,10 @@ impl Resolver { |
132 | } |
133 | |
134 | let ipv4_lookup = self.resolver.ipv4_lookup(key.as_ref()).await?; |
135 | - let ips = ipv4_lookup |
136 | + let ips: Vec<Ipv4Addr> = ipv4_lookup |
137 | .as_lookup() |
138 | .record_iter() |
139 | - .filter_map(|r| (*r.data()?.as_a()?).into()) |
140 | + .filter_map(|r| r.data()?.as_a()?.0.into()) |
141 | .collect::<Vec<_>>(); |
142 | |
143 | Ok(self |
144 | @@ -225,7 +225,7 @@ impl Resolver { |
145 | let ips = ipv6_lookup |
146 | .as_lookup() |
147 | .record_iter() |
148 | - .filter_map(|r| (*r.data()?.as_aaaa()?).into()) |
149 | + .filter_map(|r| r.data()?.as_aaaa()?.0.into()) |
150 | .collect::<Vec<_>>(); |
151 | |
152 | Ok(self |
153 | @@ -325,7 +325,7 @@ impl Resolver { |
154 | match self.resolver.lookup_ip(key.as_ref()).await { |
155 | Ok(result) => Ok(result.as_lookup().record_iter().any(|r| { |
156 | r.data().map_or(false, |d| { |
157 | - matches!(d.to_record_type(), RecordType::A | RecordType::AAAA) |
158 | + matches!(d.record_type(), RecordType::A | RecordType::AAAA) |
159 | }) |
160 | })), |
161 | Err(err) => { |
162 | diff --git a/src/report/arf/parse.rs b/src/report/arf/parse.rs |
163 | index b5ecf0f..a93cd85 100644 |
164 | --- a/src/report/arf/parse.rs |
165 | +++ b/src/report/arf/parse.rs |
166 | @@ -10,7 +10,7 @@ |
167 | |
168 | use std::borrow::Cow; |
169 | |
170 | - use mail_parser::{parsers::MessageStream, HeaderValue, Message, MimeHeaders, PartType}; |
171 | + use mail_parser::{parsers::MessageStream, HeaderValue, MessageParser, MimeHeaders, PartType}; |
172 | |
173 | use crate::{ |
174 | common::headers::HeaderIterator, |
175 | @@ -19,7 +19,9 @@ use crate::{ |
176 | |
177 | impl<'x> Feedback<'x> { |
178 | pub fn parse_rfc5322(message: &'x [u8]) -> Result<Self, Error> { |
179 | - let message = Message::parse(message).ok_or(Error::MailParseError)?; |
180 | + let message = MessageParser::new() |
181 | + .parse(message) |
182 | + .ok_or(Error::MailParseError)?; |
183 | let mut feedback = None; |
184 | let mut included_message = None; |
185 | let mut included_headers = None; |
186 | diff --git a/src/report/dmarc/parse.rs b/src/report/dmarc/parse.rs |
187 | index 274b5a9..a7646f4 100644 |
188 | --- a/src/report/dmarc/parse.rs |
189 | +++ b/src/report/dmarc/parse.rs |
190 | @@ -13,7 +13,7 @@ use std::net::IpAddr; |
191 | use std::str::FromStr; |
192 | |
193 | use flate2::read::GzDecoder; |
194 | - use mail_parser::{Message, MimeHeaders, PartType}; |
195 | + use mail_parser::{MessageParser, MimeHeaders, PartType}; |
196 | use quick_xml::events::{BytesStart, Event}; |
197 | use quick_xml::reader::Reader; |
198 | |
199 | @@ -26,7 +26,9 @@ use crate::report::{ |
200 | |
201 | impl Report { |
202 | pub fn parse_rfc5322(report: &[u8]) -> Result<Self, Error> { |
203 | - let message = Message::parse(report).ok_or(Error::MailParseError)?; |
204 | + let message = MessageParser::new() |
205 | + .parse(report) |
206 | + .ok_or(Error::MailParseError)?; |
207 | let mut error = Error::NoReportsFound; |
208 | |
209 | for part in &message.parts { |
210 | diff --git a/src/report/tlsrpt/parse.rs b/src/report/tlsrpt/parse.rs |
211 | index b3d5aed..97e3d5e 100644 |
212 | --- a/src/report/tlsrpt/parse.rs |
213 | +++ b/src/report/tlsrpt/parse.rs |
214 | @@ -11,7 +11,7 @@ |
215 | use std::io::{Cursor, Read}; |
216 | |
217 | use flate2::read::GzDecoder; |
218 | - use mail_parser::{Message, MimeHeaders, PartType}; |
219 | + use mail_parser::{MessageParser, MimeHeaders, PartType}; |
220 | use zip::ZipArchive; |
221 | |
222 | use crate::report::Error; |
223 | @@ -24,7 +24,9 @@ impl TlsReport { |
224 | } |
225 | |
226 | pub fn parse_rfc5322(report: &[u8]) -> Result<Self, Error> { |
227 | - let message = Message::parse(report).ok_or(Error::MailParseError)?; |
228 | + let message = MessageParser::new() |
229 | + .parse(report) |
230 | + .ok_or(Error::MailParseError)?; |
231 | let mut error = Error::NoReportsFound; |
232 | |
233 | for part in &message.parts { |