@@ -210,29 +210,41 @@ func checkTLSVersion(client *smtp.Client, hostname string, timeout time.Duration
210210 return result .Success ()
211211}
212212
213- // CheckHostnameWithCache returns the result of CheckHostname, using or
214- // updating the Checker's cache.
215- func (c * Checker ) CheckHostnameWithCache (domain string , hostname string ) HostnameResult {
213+ // checkHostname returns the result of c.CheckHostname or FullCheckHostname,
214+ // using or updating the Checker's cache.
215+ func (c * Checker ) checkHostname (domain string , hostname string ) HostnameResult {
216+ check := c .CheckHostname
217+ if check == nil {
218+ // If CheckHostname hasn't been set, default to the full set of checks.
219+ check = FullCheckHostname
220+ }
221+
216222 if c .Cache == nil {
217- return c . CheckHostname (domain , hostname )
223+ return check (domain , hostname , c . timeout () )
218224 }
219225 hostnameResult , err := c .Cache .GetHostnameScan (hostname )
220226 if err != nil {
221- hostnameResult = c . CheckHostname (domain , hostname )
227+ hostnameResult = check (domain , hostname , c . timeout () )
222228 c .Cache .PutHostnameScan (hostname , hostnameResult )
223229 }
224230 return hostnameResult
225231}
226232
227- // CheckHostname performs a series of checks against a hostname for an email domain.
228- // `domain` is the mail domain that this server serves email for.
229- // `hostname` is the hostname for this server.
230- func (c * Checker ) CheckHostname (domain string , hostname string ) HostnameResult {
231- if c .checkHostnameOverride != nil {
232- // Allow the Checker to mock this function.
233- return c .checkHostnameOverride (domain , hostname )
233+ // NoopCheckHostname returns a fake error result containing `domain` and `hostname`.
234+ func NoopCheckHostname (domain string , hostname string , _ time.Duration ) HostnameResult {
235+ r := HostnameResult {
236+ Domain : domain ,
237+ Hostname : hostname ,
238+ Result : MakeResult ("hostnames" ),
234239 }
240+ r .addCheck (MakeResult (Connectivity ).Error ("Skipping hostname checks" ))
241+ return r
242+ }
235243
244+ // FullCheckHostname performs a series of checks against a hostname for an email domain.
245+ // `domain` is the mail domain that this server serves email for.
246+ // `hostname` is the hostname for this server.
247+ func FullCheckHostname (domain string , hostname string , timeout time.Duration ) HostnameResult {
236248 result := HostnameResult {
237249 Domain : domain ,
238250 Hostname : hostname ,
@@ -242,7 +254,7 @@ func (c *Checker) CheckHostname(domain string, hostname string) HostnameResult {
242254
243255 // Connect to the SMTP server and use that connection to perform as many checks as possible.
244256 connectivityResult := MakeResult (Connectivity )
245- client , err := smtpDialWithTimeout (hostname , c . timeout () )
257+ client , err := smtpDialWithTimeout (hostname , timeout )
246258 if err != nil {
247259 result .addCheck (connectivityResult .Error ("Could not establish connection: %v" , err ))
248260 return result
@@ -258,7 +270,7 @@ func (c *Checker) CheckHostname(domain string, hostname string) HostnameResult {
258270 // result.addCheck(checkTLSCipher(hostname))
259271
260272 // Creates a new connection to check for SSLv2/3 support because we can't call starttls twice.
261- result .addCheck (checkTLSVersion (client , hostname , c . timeout () ))
273+ result .addCheck (checkTLSVersion (client , hostname , timeout ))
262274
263275 return result
264276}
0 commit comments