From 4c420e2bc2bc0072479076ba6341ff73c805c627 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Mon, 6 May 2019 06:29:44 -0700 Subject: [PATCH] bdns: Remove LookupMX. (#4202) We used to use this for checking email domains on registration, but not anymore. --- bdns/dns.go | 23 ----------------------- bdns/mocks.go | 31 +------------------------------ va/caa_test.go | 4 ---- 3 files changed, 1 insertion(+), 57 deletions(-) diff --git a/bdns/dns.go b/bdns/dns.go index 265e016f4..8d28cad2f 100644 --- a/bdns/dns.go +++ b/bdns/dns.go @@ -148,7 +148,6 @@ type DNSClient interface { LookupTXT(context.Context, string) (txts []string, authorities []string, err error) LookupHost(context.Context, string) ([]net.IP, error) LookupCAA(context.Context, string) ([]*dns.CAA, error) - LookupMX(context.Context, string) ([]string, error) } // DNSClientImpl represents a client that talks to an external resolver @@ -481,25 +480,3 @@ func (dnsClient *DNSClientImpl) LookupCAA(ctx context.Context, hostname string) } return CAAs, nil } - -// LookupMX sends a DNS query to find a MX record associated hostname and returns the -// record target. -func (dnsClient *DNSClientImpl) LookupMX(ctx context.Context, hostname string) ([]string, error) { - dnsType := dns.TypeMX - r, err := dnsClient.exchangeOne(ctx, hostname, dnsType) - if err != nil { - return nil, &DNSError{dnsType, hostname, err, -1} - } - if r.Rcode != dns.RcodeSuccess { - return nil, &DNSError{dnsType, hostname, nil, r.Rcode} - } - - var results []string - for _, answer := range r.Answer { - if mx, ok := answer.(*dns.MX); ok { - results = append(results, mx.Mx) - } - } - - return results, nil -} diff --git a/bdns/mocks.go b/bdns/mocks.go index cbe1e920c..583a726d4 100644 --- a/bdns/mocks.go +++ b/bdns/mocks.go @@ -5,7 +5,6 @@ import ( "fmt" "net" "os" - "strings" "github.com/miekg/dns" "golang.org/x/net/context" @@ -65,13 +64,9 @@ func (t timeoutError) Timeout() bool { } // LookupHost is a mock -// -// Note: see comments on LookupMX regarding email.only -// func (mock *MockDNSClient) LookupHost(_ context.Context, hostname string) ([]net.IP, error) { if hostname == "always.invalid" || - hostname == "invalid.invalid" || - hostname == "email.only" { + hostname == "invalid.invalid" { return []net.IP{}, nil } if hostname == "always.timeout" { @@ -102,27 +97,3 @@ func (mock *MockDNSClient) LookupHost(_ context.Context, hostname string) ([]net func (mock *MockDNSClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, error) { return nil, nil } - -// LookupMX is a mock -// -// Note: the email.only domain must have an MX but no A or AAAA -// records. The mock LookupHost returns an address of 127.0.0.1 for -// all domains except for special cases, so MX-only domains must be -// handled in both LookupHost and LookupMX. -// -func (mock *MockDNSClient) LookupMX(_ context.Context, domain string) ([]string, error) { - switch strings.TrimRight(domain, ".") { - case "letsencrypt.org": - fallthrough - case "email.only": - fallthrough - case "email.com": - return []string{"mail.email.com"}, nil - case "always.error": - return []string{}, &DNSError{dns.TypeA, "always.error", - &net.OpError{Err: errors.New("always.error always errors")}, -1} - case "always.timeout": - return []string{}, &DNSError{dns.TypeA, "always.timeout", MockTimeoutError(), -1} - } - return nil, nil -} diff --git a/va/caa_test.go b/va/caa_test.go index 7452aa49d..56f57d09e 100644 --- a/va/caa_test.go +++ b/va/caa_test.go @@ -33,10 +33,6 @@ func (mock caaMockDNS) LookupHost(_ context.Context, hostname string) ([]net.IP, return []net.IP{ip}, nil } -func (mock caaMockDNS) LookupMX(_ context.Context, domain string) ([]string, error) { - return nil, nil -} - func (mock caaMockDNS) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, error) { var results []*dns.CAA var record dns.CAA