func scanMain(args []string, c cli.Config) (err error) { if c.List { printJSON(scan.Default) } else { if err = scan.LoadRootCAs(c.CABundleFile); err != nil { return } // Execute for each HOST argument given for len(args) > 0 { var host string host, args, err = cli.PopFirstArgument(args) if err != nil { return } fmt.Printf("Scanning %s...\n", host) var results map[string]scan.FamilyResult results, err = scan.Default.RunScans(host, c.IP, c.Family, c.Scanner, c.Timeout) if err != nil { return } if results != nil { printJSON(results) } } } return }
// NewHandler returns a new http.Handler that handles a scan request. func NewHandler(caBundleFile string) (http.Handler, error) { return api.HTTPHandler{ Handler: api.HandlerFunc(scanHandler), Methods: []string{"GET"}, }, scan.LoadRootCAs(caBundleFile) }