From b8c95ce521946a33c80e05064c3697c3119da8d7 Mon Sep 17 00:00:00 2001 From: Jess Frazelle Date: Thu, 5 Jul 2018 16:58:35 -0400 Subject: [PATCH] disbale logger and time the scan Signed-off-by: Jess Frazelle --- k8scan/main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/k8scan/main.go b/k8scan/main.go index 42b0129..152ce3b 100644 --- a/k8scan/main.go +++ b/k8scan/main.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "io/ioutil" + "log" "net" "net/http" "os" @@ -38,9 +39,16 @@ func main() { } }() + // Set the logger to nil so we ignore messages from the Dial that don't matter. + // See: https://github.com/golang/go/issues/19895#issuecomment-292793756 + log.SetFlags(0) + log.SetOutput(ioutil.Discard) + logrus.Infof("Scanning for Kubernetes Dashboards and API Servers on %s over port range %d-%d", cidr, beginPort, endPort) logrus.Infof("This may take a bit...") + startTime := time.Now() + ip, ipnet, err := net.ParseCIDR(cidr) if err != nil { logrus.Fatal(err) @@ -80,6 +88,9 @@ func main() { } wg.Wait() + + since := time.Since(startTime) + logrus.Infof("Scan took: %s", since.String()) } func portOpen(ip string, port int) bool {