7 Commits

Author SHA1 Message Date
Alberto Bertogli
f3b01cb493 docs: Add missing docstrings, adjust wording to match standard style
This patch adds a missing docstrings for exported identifiers, and
adjust some of the existing ones to match the standard style.

In some cases, the identifiers were un-exported after noticing they had
no external users.

Besides improving documentation, it also reduces the linter noise
significantly.
2018-03-04 16:00:06 +00:00
Alberto Bertogli
d80c76f746 envelope: Handle zero-length keys in AddHeader
We don't expect the AddHeader function to be given an empty key;
however, if that were to happen, it currently crashes.

This patch fixes the bug, while also adding tests for that and other
similar cases.
2018-03-02 19:37:28 +00:00
Alberto Bertogli
112e492c3a Normalize domains
We should ignore the domains' case, and treat them uniformly, specially when it
comes to local domains.

This patch extends the existing normalization (IDNA, keeping domains as
UTF8 internally) to include case conversion and NFC form for
consistency.
2016-10-10 00:51:05 +01:00
Alberto Bertogli
f767b83fe0 Implement basic IDNA support
This patch implements the first steps of support for IDNA (Internationalized
Domain Names for Applications).

Internally, we maintain the byte-agnostic representation, including
configuration.

We support receiving IDNA mail over SMTP, which we convert to unicode for
internal handling.

Local deliveries are still kept agnostic.

For sending over SMTP, we use IDNA for DNS resolution, but there are some
corner cases pending in the SMTP courier that are tied with SMTPUTF8 and will
be fixed in subsequent patches.
2016-10-10 00:51:04 +01:00
Alberto Bertogli
d05b8ef189 chasquid: Add "Received" email headers
This patch makes chasquid add "Received" email headers, after DATA completes
and before queueing.

We only use this for debugging purposes.
2016-10-10 00:51:04 +01:00
Alberto Bertogli
e2fdcb3705 Add checks to prevent unauthorized relaying and impersonation
This patch adds checks that verify:

 - The envelope from must match the authenticated user. This prevents
   impersonation at the envelope level (while still allowing bounces, of
   course).
 - If the destination is remote, then the user must have completed
   authentication. This prevents unauthorized relaying.

The patch ends up adjusting quite a few tests, as they were not written
considering these restrictions so they have to be changed accordingly.
2016-10-10 00:50:56 +01:00
Alberto Bertogli
362ef6f6d0 Introduce an "envelope" package
This patch introduces an "envelope" package which, for now, provides simple
utilities for getting the user and domain of an address.

It also changes the couriers to use it (but other implementations remain, will
be moved over in subsequent patches).
2016-07-22 01:44:45 +01:00