-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into noscript-with-models
- Loading branch information
Showing
18 changed files
with
261 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package checker | ||
|
||
import ( | ||
"net" | ||
"time" | ||
) | ||
|
||
// A Checker is used to run checks against SMTP domains and hostnames. | ||
type Checker struct { | ||
// Timeout specifies the maximum timeout for network requests made during | ||
// checks. | ||
// If nil, a default timeout of 10 seconds is used. | ||
Timeout time.Duration | ||
|
||
// Cache specifies the hostname scan cache store and expire time. | ||
// Defaults to a 10-minute in-memory cache. | ||
Cache *ScanCache | ||
|
||
// lookupMX specifies an alternate function to retrieve hostnames for a given | ||
// domain. It is used to mock DNS lookups during testing. | ||
lookupMX func(string) ([]*net.MX, error) | ||
|
||
// checkHostname is used to mock checks for a single hostname. | ||
checkHostname func(string, string) HostnameResult | ||
} | ||
|
||
func (c *Checker) timeout() time.Duration { | ||
if c.Timeout != 0 { | ||
return c.Timeout | ||
} | ||
return 10 * time.Second | ||
} | ||
|
||
func (c *Checker) cache() *ScanCache { | ||
if c.Cache == nil { | ||
c.Cache = MakeSimpleCache(10 * time.Minute) | ||
} | ||
return c.Cache | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.