author | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-05-22 20:53:50 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2020-05-22 20:53:50 UTC |
parent | a683815bdae8772117bbb85c02ff4458a9f726a8 |
spf.go | +4 | -4 |
spf_test.go | +3 | -3 |
diff --git a/spf.go b/spf.go index 788a1fc..b8f74ed 100644 --- a/spf.go +++ b/spf.go @@ -92,7 +92,7 @@ var ( errInvalidMask = fmt.Errorf("invalid mask") errInvalidMacro = fmt.Errorf("invalid macro") errInvalidDomain = fmt.Errorf("invalid domain") - errNoResult = fmt.Errorf("lookup yielded no result") + errNoResult = fmt.Errorf("no DNS record found") errMultipleRecords = fmt.Errorf("multiple matching DNS records") errTooManyMXRecords = fmt.Errorf("too many MX records") @@ -177,8 +177,8 @@ func (r *resolution) Check(domain string) (Result, error) { if txt == "" { // No record => None. - // https://tools.ietf.org/html/rfc7208#section-4.6 - return None, nil + // https://tools.ietf.org/html/rfc7208#section-4.5 + return None, errNoResult } fields := strings.Split(txt, " ") @@ -467,7 +467,7 @@ func (r *resolution) includeField(res Result, field, domain string) (bool, Resul case PermError: return true, PermError, err case None: - return true, PermError, errNoResult + return true, PermError, err } return false, "", fmt.Errorf("This should never be reached") diff --git a/spf_test.go b/spf_test.go index 7e59a4d..7f47dac 100644 --- a/spf_test.go +++ b/spf_test.go @@ -20,8 +20,8 @@ func TestBasic(t *testing.T) { res Result err error }{ - {"", None, nil}, - {"blah", None, nil}, + {"", None, errNoResult}, + {"blah", None, errNoResult}, {"v=spf1", Neutral, nil}, {"v=spf1 ", Neutral, nil}, {"v=spf1 -", PermError, errUnknownField}, @@ -204,7 +204,7 @@ func TestInvalidRedirect(t *testing.T) { } res, err = CheckHost(ip1111, "domain") - if res != PermError || err != nil { + if res != PermError || err != errNoResult { t.Errorf("expected permerror, got %v (%v)", res, err) } }