Karta. SMTP. Relay
(Karta v1.0.0)
IP-authenticated relay: a client whose address lies in one of a server's
active ranges (a credential of kind: :ip, Karta.Credentials) may send
mail from that server without AUTH.
match/1 finds the most specific range that contains the address: the
longest prefix wins. Ranges may overlap (a /24 of one server inside a
/16 of another); two active credentials cannot hold the same range (a
unique index, credentials_active_cidr_index), and ranges of one size
that differ never both contain one address, so exactly one credential
answers. Revoked ranges match nothing.
The address is the one the connection reports as its peer: the socket's
address, or the address in the PROXY protocol header of a trusted proxy
(Karta.SMTP.Handler), normalised by Karta.CIDR.normalize/1. A
message's contents never choose it.
What the matched credential may send is Karta.SMTP.Policy.Outgoing:
the verified domains of the credential's organisation, the credential's
rate limit, its server's suspension and its TLS requirement. A range is
never a way around those rules, and nothing here authenticates a client
for anything but sending.
Summary
Functions
@spec match(:inet.ip_address()) :: {:ok, Karta.Credentials.Credential.t()} | :none
The most specific active range that contains ip, or :none.