1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-22 15:27:02 +00:00

sts: Don't pre-filter MX list, but skip them if needed

Instead of pre-filtering the MX list based on STS policy, just check
if it's allowed before each attempt, and skip it if not.

This simplifies the code.
This commit is contained in:
Alberto Bertogli
2018-05-27 10:43:46 +01:00
parent 252ab5d3e3
commit 8bf584bd86
2 changed files with 17 additions and 35 deletions

View File

@@ -140,9 +140,13 @@ func (p *Policy) Check() error {
return nil
}
// MXMatches checks if the given MX is allowed, according to the policy.
// MXIsAllowed checks if the given MX is allowed, according to the policy.
// https://tools.ietf.org/html/draft-ietf-uta-mta-sts-18#section-4.1
func (p *Policy) MXIsAllowed(mx string) bool {
if p.Mode != Enforce {
return true
}
for _, pattern := range p.MXs {
if matchDomain(mx, pattern) {
return true