scanner

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2015 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHostname   = "example.com"
	DefaultMaxProcs   = 1
	DefaultMaxMin     = 5
	DefaultMaxWorkers = 4
)

Variables

This section is empty.

Functions

func PrintUsageAndExit

func PrintUsageAndExit()

PrintUsageAndExit is used to print out command line options.

func PrintVersionAndExit

func PrintVersionAndExit()

PrintVersionAndExit prints the version of the scanner then exits.

Types

type Scanner

type Scanner struct {
	RootURL    *url.URL                     // The original URL that we started the scan from.
	Tests      map[string]map[string]*Stats // URL test results go in here.
	MaxRunMin  int                          // The Maximum number of minutes we want the scanner to run.
	MaxWorkers int                          // The maximumm job workers we want in the pool.
	StartTime  time.Time                    // When the scanner started runnning.
	ExpireTime time.Time                    // The expire time: when the scanner should stop running.
	EndTime    time.Time                    // When the scanner ended.
	// contains filtered or unexported fields
}

Scanner is a manager of scanning jobs and evaluates the results of the workers.

func New

func New(hostname string, maxRunMin int, maxWorkers int) *Scanner

New is a factory function that creates a new Scanner instance.

func (*Scanner) Run

func (s *Scanner) Run()

Run starts the scanner and manages the jobs.

func (*Scanner) Stop

func (s *Scanner) Stop()

Stop performs close out procedures.

type Stats

type Stats struct {
	URL           *url.URL  `json:"url"`           // The URL we scanned.
	URLType       string    `json:"urlType"`       // The type of url ex: html, img, css, js etc..
	ParentURL     *url.URL  `json:"parentURL"`     // The parent where this was located.
	StartTime     time.Time `json:"startTime"`     // The start time of the scan.
	EndTime       time.Time `json:"endTime"`       // The end time of the scan.
	Canonical     bool      `json:"canonical"`     // Did this page contain a canonical link?
	MetaCount     int       `json:"metaCount"`     // Does meta description exist on the page?
	MetaSizedErr  bool      `json:"metaSizedErr"`  // Are meta descriptions the proper size?
	TitleCount    int       `json:"titleCount"`    // Does title exist on the page?
	TitleSizedErr bool      `json:"titleSizedErr"` // Does the title meet size criteria?
	AltTagsErr    bool      `json:"altTagsErr"`    // Did alt tags exist for all images on this page?
	H1Count       int       `json:"h1Count"`       // Does an h1 tag exist on the page and is it unique?
	StatusCode    int       `json:"status"`        // The status code we returned from the scan.
}

Stats is a construct that hold information on the scanning of a URL.

func StatsNew

func StatsNew(u *url.URL, ut string, p *url.URL) *Stats

StatsNew is a factory for creating a new Stats instance.

func (*Stats) String

func (s *Stats) String() string

String is an implentation of the Stringer interface so the structure is returned as a string to fmt.Print() etc.

Jump to

Keyboard shortcuts

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