diff --git a/Cargo.toml b/Cargo.toml index 2bb5d5a..47df0f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] members = [ - "opensmtpd", - "opensmtpd-derive" + "opensmtpd", + "opensmtpd-derive" ] diff --git a/opensmtpd/src/lib.rs b/opensmtpd/src/lib.rs index 6a323f8..d58b622 100644 --- a/opensmtpd/src/lib.rs +++ b/opensmtpd/src/lib.rs @@ -56,19 +56,19 @@ //! use opensmtpd_derive::register; //! //! struct MyCounter { -//! nb: u64, +//! nb: u64, //! } //! //! impl Filter for MyCounter { -//! #[register] -//! fn on_report_link_disconnect(&mut self, _entry: &ReportEntry) { -//! self.nb + 1; -//! } +//! #[register] +//! fn on_report_link_disconnect(&mut self, _entry: &ReportEntry) { +//! self.nb + 1; +//! } //! } //! //! fn main() { -//! let mut my_counter = MyCounter { nb: 0, }; -//! run_filter(&mut my_counter); +//! let mut my_counter = MyCounter { nb: 0, }; +//! run_filter(&mut my_counter); //! } //! ``` //! @@ -88,23 +88,23 @@ //! struct RmXOriginatingIp {} //! //! impl Filter for RmXOriginatingIp { -//! #[register] -//! fn on_filter_data_line(&mut self, entry: &FilterEntry, data_line: &[u8]) { -//! if data_line.len() >= HEADER_LEN { -//! let head_start = data_line[..HEADER_LEN].to_vec(); -//! if let Ok(s) = String::from_utf8(head_start) { -//! if s.to_lowercase() == HEADER_NAME { -//! return; -//! } -//! } -//! } -//! return_data_line(entry, data_line); -//! } +//! #[register] +//! fn on_filter_data_line(&mut self, entry: &FilterEntry, data_line: &[u8]) { +//! if data_line.len() >= HEADER_LEN { +//! let head_start = data_line[..HEADER_LEN].to_vec(); +//! if let Ok(s) = String::from_utf8(head_start) { +//! if s.to_lowercase() == HEADER_NAME { +//! return; +//! } +//! } +//! } +//! return_data_line(entry, data_line); +//! } //! } //! //! fn main() { -//! let mut my_filter = RmXOriginatingIp {}; -//! run_filter(&mut my_filter); +//! let mut my_filter = RmXOriginatingIp {}; +//! run_filter(&mut my_filter); //! } //! ``` //! diff --git a/opensmtpd/src/parsers/handshake.rs b/opensmtpd/src/parsers/handshake.rs index 938091e..3d65257 100644 --- a/opensmtpd/src/parsers/handshake.rs +++ b/opensmtpd/src/parsers/handshake.rs @@ -109,11 +109,11 @@ mod tests { #[test] fn test_invalid_handshakes() { let test_vectors = vec![ - "config|smtpd-version|6.6.1\nconfig|smtp-session-timeout|\nconfig|subsystem|smtp-in\nconfig|ready\n", - "config|smtp-session-timeout|300\nconfig|smtpd-version|6.6.1\nconfig|subsystem|smtp-in\nconfig|ready\n", - "config|smtpd-version|6.6.1\nconfig|smtp-session-timeout|300\nconfig|subsystem|smtp-in\nconfig|ready", - "config|smtpd-version|6.6.1\nconfig|smtp-session-timeout|300\nconfig|subsystem|smtp-in\nconfig|ready\r", - ]; + "config|smtpd-version|6.6.1\nconfig|smtp-session-timeout|\nconfig|subsystem|smtp-in\nconfig|ready\n", + "config|smtp-session-timeout|300\nconfig|smtpd-version|6.6.1\nconfig|subsystem|smtp-in\nconfig|ready\n", + "config|smtpd-version|6.6.1\nconfig|smtp-session-timeout|300\nconfig|subsystem|smtp-in\nconfig|ready", + "config|smtpd-version|6.6.1\nconfig|smtp-session-timeout|300\nconfig|subsystem|smtp-in\nconfig|ready\r", + ]; for input in test_vectors { let r = parse_handshake(input.as_bytes()); assert!(r.is_err());