Skip to content

Commit 4c420e2

Browse files
jshaDaniel McCarney
authored andcommitted
bdns: Remove LookupMX. (letsencrypt#4202)
We used to use this for checking email domains on registration, but not anymore.
1 parent 825277f commit 4c420e2

File tree

3 files changed

+1
-57
lines changed

3 files changed

+1
-57
lines changed

bdns/dns.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ type DNSClient interface {
148148
LookupTXT(context.Context, string) (txts []string, authorities []string, err error)
149149
LookupHost(context.Context, string) ([]net.IP, error)
150150
LookupCAA(context.Context, string) ([]*dns.CAA, error)
151-
LookupMX(context.Context, string) ([]string, error)
152151
}
153152

154153
// DNSClientImpl represents a client that talks to an external resolver
@@ -481,25 +480,3 @@ func (dnsClient *DNSClientImpl) LookupCAA(ctx context.Context, hostname string)
481480
}
482481
return CAAs, nil
483482
}
484-
485-
// LookupMX sends a DNS query to find a MX record associated hostname and returns the
486-
// record target.
487-
func (dnsClient *DNSClientImpl) LookupMX(ctx context.Context, hostname string) ([]string, error) {
488-
dnsType := dns.TypeMX
489-
r, err := dnsClient.exchangeOne(ctx, hostname, dnsType)
490-
if err != nil {
491-
return nil, &DNSError{dnsType, hostname, err, -1}
492-
}
493-
if r.Rcode != dns.RcodeSuccess {
494-
return nil, &DNSError{dnsType, hostname, nil, r.Rcode}
495-
}
496-
497-
var results []string
498-
for _, answer := range r.Answer {
499-
if mx, ok := answer.(*dns.MX); ok {
500-
results = append(results, mx.Mx)
501-
}
502-
}
503-
504-
return results, nil
505-
}

bdns/mocks.go

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"net"
77
"os"
8-
"strings"
98

109
"github.com/miekg/dns"
1110
"golang.org/x/net/context"
@@ -65,13 +64,9 @@ func (t timeoutError) Timeout() bool {
6564
}
6665

6766
// LookupHost is a mock
68-
//
69-
// Note: see comments on LookupMX regarding email.only
70-
//
7167
func (mock *MockDNSClient) LookupHost(_ context.Context, hostname string) ([]net.IP, error) {
7268
if hostname == "always.invalid" ||
73-
hostname == "invalid.invalid" ||
74-
hostname == "email.only" {
69+
hostname == "invalid.invalid" {
7570
return []net.IP{}, nil
7671
}
7772
if hostname == "always.timeout" {
@@ -102,27 +97,3 @@ func (mock *MockDNSClient) LookupHost(_ context.Context, hostname string) ([]net
10297
func (mock *MockDNSClient) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, error) {
10398
return nil, nil
10499
}
105-
106-
// LookupMX is a mock
107-
//
108-
// Note: the email.only domain must have an MX but no A or AAAA
109-
// records. The mock LookupHost returns an address of 127.0.0.1 for
110-
// all domains except for special cases, so MX-only domains must be
111-
// handled in both LookupHost and LookupMX.
112-
//
113-
func (mock *MockDNSClient) LookupMX(_ context.Context, domain string) ([]string, error) {
114-
switch strings.TrimRight(domain, ".") {
115-
case "letsencrypt.org":
116-
fallthrough
117-
case "email.only":
118-
fallthrough
119-
case "email.com":
120-
return []string{"mail.email.com"}, nil
121-
case "always.error":
122-
return []string{}, &DNSError{dns.TypeA, "always.error",
123-
&net.OpError{Err: errors.New("always.error always errors")}, -1}
124-
case "always.timeout":
125-
return []string{}, &DNSError{dns.TypeA, "always.timeout", MockTimeoutError(), -1}
126-
}
127-
return nil, nil
128-
}

va/caa_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ func (mock caaMockDNS) LookupHost(_ context.Context, hostname string) ([]net.IP,
3333
return []net.IP{ip}, nil
3434
}
3535

36-
func (mock caaMockDNS) LookupMX(_ context.Context, domain string) ([]string, error) {
37-
return nil, nil
38-
}
39-
4036
func (mock caaMockDNS) LookupCAA(_ context.Context, domain string) ([]*dns.CAA, error) {
4137
var results []*dns.CAA
4238
var record dns.CAA

0 commit comments

Comments
 (0)