author | Alberto Bertogli
<albertito@blitiri.com.ar> 2019-10-14 18:24:32 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2019-10-14 18:24:32 UTC |
parent | cb233346b391520964276b6c7bfeb280ddd2b8d3 |
README.md | +6 | -4 |
spf.go | +6 | -3 |
diff --git a/README.md b/README.md index 8f8e28e..91cc3ae 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,14 @@ It is used by the [chasquid](https://blitiri.com.ar/p/chasquid/) SMTP server. ## Example -The API is quite simple: it has only one function to perform the SPF check, -similar to the one suggested in the [RFC](https://tools.ietf.org/html/rfc7208). +The API is quite simple: it has only one main function to perform the SPF +check, similar to the one suggested in the +[RFC](https://tools.ietf.org/html/rfc7208). ```go -// Check if `ip` is authorized to send email for `domain`. -result, err := spf.CheckHost(ip, domain) +// Check if `sender` is authorized to send from the given `ip`. The `domain` +// is used if the sender doesn't have one. +result, err := spf.CheckHostWithSender(ip, domain, sender) if result == spf.Fail { // Not authorized to use the domain. } diff --git a/spf.go b/spf.go index 8b8d940..c071b62 100644 --- a/spf.go +++ b/spf.go @@ -106,6 +106,9 @@ var ( // CheckHost fetches SPF records for `domain`, parses them, and evaluates them // to determine if `ip` is permitted to send mail for it. +// Because it doesn't receive enough information to handle macros well, its +// usage is not recommended, but remains supported for backwards +// compatibility. // Reference: https://tools.ietf.org/html/rfc7208#section-4 func CheckHost(ip net.IP, domain string) (Result, error) { trace("check host %q %q", ip, domain) @@ -113,9 +116,9 @@ func CheckHost(ip net.IP, domain string) (Result, error) { return r.Check(domain) } -// CheckHostWithSender fetches SPF records for `domain`, parses them, and -// evaluates them to determine if `ip` is permitted to send mail for it. -// The sender is used in macro expansion. +// CheckHostWithSender fetches SPF records for `sender`'s domain, parses them, +// and evaluates them to determine if `ip` is permitted to send mail for it. +// The `helo` domain is used if the sender has no domain part. // Reference: https://tools.ietf.org/html/rfc7208#section-4 func CheckHostWithSender(ip net.IP, helo, sender string) (Result, error) { _, domain := split(sender)