diff --git a/opensmtpd/src/data_line.rs b/opensmtpd/src/data_line.rs index dc5c97c..a9829d4 100644 --- a/opensmtpd/src/data_line.rs +++ b/opensmtpd/src/data_line.rs @@ -4,5 +4,5 @@ use std::io::{self, Write}; pub fn return_data_line(entry: &FilterEntry, data_line: &[u8]) { print!("filter-dataline|{}|{}|", entry.session_id, entry.token); io::stdout().write_all(data_line).unwrap(); - println!(""); + println!(); } diff --git a/opensmtpd/src/filter.rs b/opensmtpd/src/filter.rs index 1400ca5..dd6cb6d 100644 --- a/opensmtpd/src/filter.rs +++ b/opensmtpd/src/filter.rs @@ -9,7 +9,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_auth(&self) -> bool { - return false; + false } fn on_filter_commit(&mut self, _entry: &FilterEntry) -> FilterResponse { @@ -17,7 +17,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_commit(&self) -> bool { - return false; + false } fn on_filter_connect( @@ -32,7 +32,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_connect(&self) -> bool { - return false; + false } fn on_filter_data(&mut self, _entry: &FilterEntry) -> FilterResponse { @@ -40,13 +40,13 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_data(&self) -> bool { - return false; + false } fn on_filter_data_line(&mut self, _entry: &FilterEntry, _data_line: &[u8]) {} #[doc(hidden)] fn has_filter_data_line(&self) -> bool { - return false; + false } fn on_filter_ehlo(&mut self, _entry: &FilterEntry, _identity: &str) -> FilterResponse { @@ -54,7 +54,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_ehlo(&self) -> bool { - return false; + false } fn on_filter_helo(&mut self, _entry: &FilterEntry, _identity: &str) -> FilterResponse { @@ -62,7 +62,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_helo(&self) -> bool { - return false; + false } fn on_filter_mail_from(&mut self, _entry: &FilterEntry, _address: &str) -> FilterResponse { @@ -70,7 +70,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_mail_from(&self) -> bool { - return false; + false } fn on_filter_rcpt_to(&mut self, _entry: &FilterEntry, _address: &str) -> FilterResponse { @@ -78,7 +78,7 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_rcpt_to(&self) -> bool { - return false; + false } fn on_filter_starttls(&mut self, _entry: &FilterEntry, _tls_string: &str) -> FilterResponse { @@ -86,13 +86,13 @@ pub trait Filter { } #[doc(hidden)] fn has_filter_starttls(&self) -> bool { - return false; + false } fn on_report_link_auth(&mut self, _entry: &ReportEntry, _username: &str, _result: AuthResult) {} #[doc(hidden)] fn has_report_link_auth(&self) -> bool { - return false; + false } fn on_report_link_connect( @@ -106,37 +106,37 @@ pub trait Filter { } #[doc(hidden)] fn has_report_link_connect(&self) -> bool { - return false; + false } fn on_report_link_disconnect(&mut self, _entry: &ReportEntry) {} #[doc(hidden)] fn has_report_link_disconnect(&self) -> bool { - return false; + false } fn on_report_link_greeting(&mut self, _entry: &ReportEntry, _hostname: &str) {} #[doc(hidden)] fn has_report_link_greeting(&self) -> bool { - return false; + false } fn on_report_link_identify(&mut self, _entry: &ReportEntry, _method: Method, _identity: &str) {} #[doc(hidden)] fn has_report_link_identify(&self) -> bool { - return false; + false } fn on_report_link_tls(&mut self, _entry: &ReportEntry, _tls_string: &str) {} #[doc(hidden)] fn has_report_link_tls(&self) -> bool { - return false; + false } fn on_report_tx_begin(&mut self, _entry: &ReportEntry, _message_id: &str) {} #[doc(hidden)] fn has_report_tx_begin(&self) -> bool { - return false; + false } fn on_report_tx_mail( @@ -149,13 +149,13 @@ pub trait Filter { } #[doc(hidden)] fn has_report_tx_mail(&self) -> bool { - return false; + false } fn on_report_tx_reset(&mut self, _entry: &ReportEntry, _message_id: &Option) {} #[doc(hidden)] fn has_report_tx_reset(&self) -> bool { - return false; + false } fn on_report_tx_rcpt( @@ -168,7 +168,7 @@ pub trait Filter { } #[doc(hidden)] fn has_report_tx_rcpt(&self) -> bool { - return false; + false } fn on_report_tx_envelope( @@ -180,13 +180,13 @@ pub trait Filter { } #[doc(hidden)] fn has_report_tx_envelope(&self) -> bool { - return false; + false } fn on_report_tx_data(&mut self, _entry: &ReportEntry, _message_id: &str, _result: MailResult) {} #[doc(hidden)] fn has_report_tx_data(&self) -> bool { - return false; + false } fn on_report_tx_commit( @@ -198,25 +198,25 @@ pub trait Filter { } #[doc(hidden)] fn has_report_tx_commit(&self) -> bool { - return false; + false } fn on_report_tx_rollback(&mut self, _entry: &ReportEntry, _message_id: &str) {} #[doc(hidden)] fn has_report_tx_rollback(&self) -> bool { - return false; + false } fn on_report_protocol_client(&mut self, _entry: &ReportEntry, _command: &str) {} #[doc(hidden)] fn has_report_protocol_client(&self) -> bool { - return false; + false } fn on_report_protocol_server(&mut self, _entry: &ReportEntry, _response: &str) {} #[doc(hidden)] fn has_report_protocol_server(&self) -> bool { - return false; + false } fn on_report_filter_response( @@ -229,7 +229,7 @@ pub trait Filter { } #[doc(hidden)] fn has_report_filter_response(&self) -> bool { - return false; + false } fn on_report_filter_report( @@ -242,12 +242,12 @@ pub trait Filter { } #[doc(hidden)] fn has_report_filter_report(&self) -> bool { - return false; + false } fn on_report_timeout(&mut self, _entry: &ReportEntry) {} #[doc(hidden)] fn has_report_timeout(&self) -> bool { - return false; + false } } diff --git a/opensmtpd/src/io.rs b/opensmtpd/src/io.rs index a357d4e..22a2d75 100644 --- a/opensmtpd/src/io.rs +++ b/opensmtpd/src/io.rs @@ -29,20 +29,13 @@ fn do_read_stdin(tx: &Sender>) -> Result<(), String> { return Err(String::from("unable to read on stdin")); } line_buffer.extend_from_slice(&read_buffer[..len]); - loop { - match line_buffer.iter().position(|i| *i == b'\n') { - Some(id) => { - let pos = id + 1; - let mut line = Vec::with_capacity(pos); - line.extend_from_slice(&line_buffer[..pos]); - log::trace!("new line:{}", get_pretty_hex(&line)); - tx.send(line).unwrap(); - line_buffer.drain(..pos); - } - None => { - break; - } - }; + while let Some(id) = line_buffer.iter().position(|i| *i == b'\n') { + let pos = id + 1; + let mut line = Vec::with_capacity(pos); + line.extend_from_slice(&line_buffer[..pos]); + log::trace!("new line:{}", get_pretty_hex(&line)); + tx.send(line).unwrap(); + line_buffer.drain(..pos); } } }