Commit graph

77 commits

Author SHA1 Message Date
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
Rodolphe Breard
2b87c9c3c3 Add the first draft of an event handler system 2019-01-05 13:00:09 +01:00
Rodolphe Breard
a6b9d18374 Update the entry parser
The latest OpenSMTPD draft added the timeout event, it therefore has
been added to the parser. As shown in the new sessions examples, the
timestamp format changed and the parameters are also optional.
2019-01-05 11:40:19 +01:00
Rodolphe Breard
98e4beadd3 Use a builder instead of a raw function
This pattern will, in the future, allow the registration of events
handlers and context objects.
2019-01-03 20:16:23 +01:00
Rodolphe Breard
c25dfb253a Add proper logging 2018-12-29 21:03:33 +01:00
Rodolphe Breard
2fecbedfa1 Add some metadata and release the project under the CeCILL-B license 2018-12-29 20:38:23 +01:00
Rodolphe Breard
234ca5477f Remove the useless from_string method in Error 2018-12-29 20:26:23 +01:00
Rodolphe Breard
24b332c615 Refactor the reader/dispatcher
The previous design did not handled errors correctly and was kind of
spaghetti code. With the new one, the reader and the dispatcher are
clearly separated. The filter will only exit on an error from the reader
or if EOF has been reached, any other error is displayed but does not
exit the filter, which is required by the API. If the filter must exit,
all threads are gracefully stopped.
2018-12-29 20:22:37 +01:00
Rodolphe Breard
b5cfe79947 Add the missing kinds and events 2018-12-29 18:34:23 +01:00
Rodolphe Breard
f57a201431 Read and parse incoming entries then dispatch them into session threads 2018-12-29 16:56:56 +01:00
Rodolphe Breard
010951c884 First commit 2018-12-26 10:27:46 +01:00