Commit graph

60 commits

Author SHA1 Message Date
Rodolphe Bréard
0a4ac5a709 Fix build status 2020-11-26 18:16:54 +01:00
Rodolphe Bréard
8d4d6d9419 Set Rust minimal version to 1.43 2020-11-26 12:20:58 +01:00
Rodolphe Bréard
386d4f3446 Add a minimal documentation 2020-11-25 19:29:33 +01:00
Rodolphe Bréard
dafea54dbb Log exclusively on stderr
OpenSMTPD reads filter responses on stdout, hence there must not be any
log written to this file descriptor.
2020-11-25 18:53:50 +01:00
Rodolphe Bréard
c431d5e9cc Add the Travis CI configuration 2020-11-25 18:48:16 +01:00
Rodolphe Bréard
a6d4dd21c1 Rewrite the project
The previous project architecture was far too complicated and hard to
maintain. The new one is much more simple. Although procedural macros
are cools, they are a no-go on Rust-OpenSMTPD.

Reports and filter are implemented (except data-line) but untested.
2020-11-25 18:04:16 +01:00
Rodolphe Bréard
fc072743ad
Merge pull request #3 from breard-r/dependabot/cargo/nom-6.0
Update nom requirement from 5.0 to 6.0
2020-11-02 19:19:43 +01:00
dependabot-preview[bot]
4447fe2ef9
Update nom requirement from 5.0 to 6.0
Updates the requirements on [nom](https://github.com/Geal/nom) to permit the latest version.
- [Release notes](https://github.com/Geal/nom/releases)
- [Changelog](https://github.com/Geal/nom/blob/master/CHANGELOG.md)
- [Commits](https://github.com/Geal/nom/compare/5.0.0...6.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-11-02 04:25:43 +00:00
Rodolphe Breard
fdc8bd3dc4 Add filter-level and session-level contexts 2019-09-18 20:43:46 +02:00
Rodolphe Breard
995c0c35c1 Improve the simple_filter macro
The simple_filter macro must accept the two different levels of
contexts. In the same way, it should also accept the log level, and
therefore replace the now removed simple_filter_log_level macro.
2019-09-18 14:52:21 +02:00
Rodolphe Breard
789a41b51e Add the filter proc macro 2019-09-17 20:22:07 +02:00
Rodolphe Breard
2dff22062c Move OpenSmtpdAttributes to a dedicated module 2019-09-17 19:59:06 +02:00
Rodolphe Breard
24c0253f88 Implement the register_events method 2019-09-17 19:38:41 +02:00
Rodolphe Breard
6b532242ef Return an error if end of file is reached on stdin 2019-09-17 17:50:51 +02:00
Rodolphe Breard
dfa61a9eaa Replace .find().is_some() by .any() 2019-09-17 17:45:59 +02:00
Rodolphe Breard
c08c5c0895 Retry read if interrupted
https://doc.rust-lang.org/std/io/trait.Read.html#tymethod.read
2019-09-17 17:43:11 +02:00
Rodolphe Breard
681563934a Reset the "force_read" flag 2019-09-17 17:11:30 +02:00
Rodolphe Breard
45639f18c0 Refactor the library
Threads are a bad idea because for now the filter API is not guaranteed
to be state-less. The interface is now synchronous, which should be
enough for most filters.
The refactoring brought other changes, the most important being the
concept of modular input sources and output destination and the complete
rewrite of the procedural macro.
2019-09-17 16:45:04 +02:00
Rodolphe Breard
988f028c23 Update the readme 2019-07-11 23:58:43 +02:00
Rodolphe Breard
0f917e0132 Parse the token after the session id 2019-07-11 23:42:05 +02:00
Rodolphe Breard
d76d60650a Implement the ToString trait for TimeVal instead of a custon function 2019-07-11 23:32:47 +02:00
Rodolphe Breard
9dbd90a083 Add the link-auth report 2019-07-11 23:05:15 +02:00
Rodolphe Breard
4bfca1411b Add the link-reset report 2019-07-11 23:00:45 +02:00
Rodolphe Breard
40c99af086 Store parameters as a vector of strings instead of an option 2019-07-11 22:42:58 +02:00
Rodolphe Breard
ec5aabcf99 Use more specific structs to represent an entry 2019-07-11 22:19:09 +02:00
Rodolphe Breard
a9fb623791 Add a more complete single events-only session 2019-07-11 19:20:06 +02:00
Rodolphe Breard
1faa101778 Move the response to a dedicated file 2019-07-11 12:25:51 +02:00
Rodolphe Breard
eed8f88e2b Move the session handler to a dedicated file 2019-07-11 12:25:19 +02:00
Rodolphe Breard
a9e4a697f7 Fix clippy warning 2019-06-29 17:35:56 +02:00
Rodolphe Breard
f9dc368137 Improve the coding style 2019-06-29 17:32:31 +02:00
Rodolphe Breard
4a99257263 Upgrading to nom 5 2019-06-29 17:29:52 +02:00
Rodolphe Breard
866298c948 Updating nom to 4.2 2019-03-03 15:23:31 +01:00
Rodolphe Breard
22c376930b Format code with cargo fmt 2019-01-18 19:10:12 +01:00
Rodolphe Breard
8173cb282a Switch to the MIT or Apache 2.0 license 2019-01-18 19:08:40 +01:00
Rodolphe Breard
c20fadf99d Alias event as report
This alias is made so people with OpenSMTPD filters knowledge will
directly understand that events are reports.
2019-01-17 20:05:31 +01:00
Rodolphe Breard
ae8b64941e Add a logger
OpenSMTPD plans to gather all logs from filters. Therefore, a default
logger that implements the smtpd (future) log interface has to be
available.
2019-01-17 19:53:04 +01:00
Rodolphe Breard
4b1f99db7e Allow the use of custom context
The main goal of events/reports is to update a context object, which
will be used in filters to generate a response. It is now possible to
use any object implementing both Clone and Default as a context object.
It is also possible to define no context at all.
2019-01-12 23:43:02 +01:00
Rodolphe Breard
dd7f4d1a86 Remove the Response from the events callback
Events, also known as reports, do not generate responses. Responses must
therefore be limited to filters, which are not implemented yet.
2019-01-12 12:58:01 +01:00
Rodolphe Breard
82fe5e24de Add the report registration 2019-01-12 10:42:37 +01:00
Rodolphe Breard
11f3712138 Add a context object the callbacks
Many filters requires to keep a state within a session. Although it not
currently possible to do so, the callback now accept a mutable object of
type NoContext. This is the first step, the next one will be to accept
any type that implements both Clone and Default.
An other step will be to allow the user to define different callback
parameters depending on his/her needs.
2019-01-12 00:17:59 +01:00
Rodolphe Breard
ea710408d4 Cleanup the code 2019-01-06 17:07:00 +01:00
Rodolphe Breard
45dc882b49 Remove useless use of methods 2019-01-06 16:40:53 +01:00
Rodolphe Breard
074c3697d0 Properly implement the std::str::FromStr trait 2019-01-06 16:37:07 +01:00
Rodolphe Breard
4ed4609272 Add a Response object
This object will abstract the filter response. For now, it only allow
not to respond. This will change in a future version.
2019-01-06 16:03:49 +01:00
Rodolphe Breard
21efb88331 Move the EventHandler from the client to the proc macro 2019-01-06 15:45:58 +01:00
Rodolphe Breard
789455668c Use procedural macros to define events
The construction of an EventHandler object should not be directly done
by the client. Instead, it is easier to use procedural macro to
automatize the process, hence exposing a nice and simple interface. Such
use of procedural macros requires to crate an additional crate.
2019-01-06 15:41:30 +01:00
Rodolphe Breard
ccda4b1517 Accept negative values for the timestamp 2019-01-05 17:53:56 +01:00
Rodolphe Breard
c127c5ca24 Close sessions once the disconnect events shows up 2019-01-05 16:28:51 +01:00
Rodolphe Breard
d05423edba Use an intermediate function to build the handlers
Such a function may later be generated using a procedural macro.
2019-01-05 13:59:29 +01:00
Rodolphe Breard
98dd194dca Parse the timestamp correctly
The timestamp comes from OpenBSD's struct timeval, which defines the
number of seconds as a time_t (i64) and the number of micro-seconds as a
suseconds_t (long, hence i64 too). They are separated by a dot.
https://man.openbsd.org/gettimeofday.2
2019-01-05 13:02:20 +01:00