Skip to content

Commit

Permalink
Use pointer receiver for Checker fns
Browse files Browse the repository at this point in the history
  • Loading branch information
vbrown608 committed Jan 24, 2019
1 parent 18fc398 commit 5fe93dc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ type Checker struct {
checkHostname func(string, string) HostnameResult
}

func (c Checker) timeout() time.Duration {
func (c *Checker) timeout() time.Duration {
if c.Timeout != 0 {
return c.Timeout
}
return 10 * time.Second
}

func (c Checker) cache() *ScanCache {
func (c *Checker) cache() *ScanCache {
if c.Cache == nil {
c.Cache = MakeSimpleCache(10 * time.Minute)
}
Expand Down
4 changes: 2 additions & 2 deletions checker/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func lookupMXWithTimeout(domain string, timeout time.Duration) ([]*net.MX, error
}

// lookupHostnames retrieves the MX hostnames associated with a domain.
func (c Checker) lookupHostnames(domain string) ([]string, error) {
func (c *Checker) lookupHostnames(domain string) ([]string, error) {
domainASCII, err := idna.ToASCII(domain)
if err != nil {
return nil, fmt.Errorf("domain name %s couldn't be converted to ASCII", domain)
Expand Down Expand Up @@ -102,7 +102,7 @@ func (c Checker) lookupHostnames(domain string) ([]string, error) {
// `domain` is the mail domain to perform the lookup on.
// `mxHostnames` is the list of expected hostnames.
// If `mxHostnames` is nil, we don't validate the DNS lookup.
func (c Checker) CheckDomain(domain string, expectedHostnames []string) DomainResult {
func (c *Checker) CheckDomain(domain string, expectedHostnames []string) DomainResult {
result := DomainResult{
Domain: domain,
MxHostnames: expectedHostnames,
Expand Down
2 changes: 1 addition & 1 deletion checker/hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func checkTLSVersion(client *smtp.Client, hostname string, timeout time.Duration
// CheckHostname performs a series of checks against a hostname for an email domain.
// `domain` is the mail domain that this server serves email for.
// `hostname` is the hostname for this server.
func (c Checker) CheckHostname(domain string, hostname string) HostnameResult {
func (c *Checker) CheckHostname(domain string, hostname string) HostnameResult {
if c.checkHostname != nil {
// Allow the Checker to mock this function.
return c.checkHostname(domain, hostname)
Expand Down

0 comments on commit 5fe93dc

Please sign in to comment.