scanner

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// IP addresses of publicly-available nameservers.
	GoogleDNS = []string{"8.8.8.8", "8.8.4.4"}
	Level3    = []string{"4.2.2.1", "4.2.2.2", "4.2.2.3", "4.2.2.4", "4.2.2.5", "4.2.2.6"}
	OpenDNS   = []string{"208.67.222.222", "208.67.220.220"}
)

Functions

This section is empty.

Types

type ScanFlag

type ScanFlag uint
const (
	ScanDKIM ScanFlag = 1 << iota
	ScanDMARC
	ScanSPF
)

type ScanResult

type ScanResult struct {
	Domain   string        `json:"domain"`
	SPF      string        `json:"spf"`
	DMARC    string        `json:"dmarc"`
	DKIM     string        `json:"-"`
	Duration time.Duration `json:"duration"`
	Err      error         `json:"-"`
	Error    string        `json:"error,omitempty"`
}

ScanResult holds the results of scanning a domain's DNS records.

type Scanner

type Scanner struct {
	// Nameservers is a slice of "host:port" strings of nameservers to
	// issue queries against.
	Nameservers []string
	// contains filtered or unexported fields
}

Scanner is a type that queries the DNS records for domain names, looking for specific resource records.

func New

func New(options ...ScannerOption) (*Scanner, error)

New initializes and returns a new *Scanner.

func (*Scanner) Scan

func (sc *Scanner) Scan(name string) *ScanResult

Scan allows the caller to use the *Scanner's underlying data structures for performing a one-off scan of the given domain name.

func (*Scanner) Start

func (sc *Scanner) Start(src Source) <-chan *ScanResult

Start consumes domain names from the Source src, scans the domain name's DNS records, and returns a channel of the results.

type ScannerOption

type ScannerOption func(*Scanner) error

ScannerOption defines a functional configuration type for a *Scanner.

func ConcurrentScans

func ConcurrentScans(n int) ScannerOption

ConcurrentScans sets the number of domains that will be scanned concurrently.

If n <= 0, then this option will default to the return value of runtime.NumCPU().

func UseNameservers

func UseNameservers(ns []string) ScannerOption

UseNameservers allows the caller to provide a custom set of nameservers for a *Scanner to use. If ns is nil, or zero-length, the *Scanner will use the nameservers specified in /etc/resolv.conf.

func WithTimeout

func WithTimeout(timeout time.Duration) ScannerOption

WithTimeout sets the timeout duration of a DNS query.

type Source

type Source interface {
	Read() <-chan string
	Close() error
}

Source defines the interface of a data source that feeds a Scanner.

func TextSource

func TextSource(r io.Reader) Source

TextSource returns a new Source that can be used by a Scanner to read newline-separated domain names from r.

func ZonefileSource

func ZonefileSource(r io.Reader) Source

ZonefileSource returns a Source that can be used by a Scanner to read domain names from an io.Reader that reads from a RFC 1035 formatted zone file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL