From 79244e7df141a416c803b4f7d15819228ec610c5 Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 3 Nov 2019 18:07:28 +0100 Subject: verbose --- src/httpRequest.go | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/httpRequest.go') diff --git a/src/httpRequest.go b/src/httpRequest.go index 3cc3b17..163a524 100644 --- a/src/httpRequest.go +++ b/src/httpRequest.go @@ -22,13 +22,17 @@ func httpRequest(channels channels, threadNr int) { // make the http get request resp, err := http.Get(requestURL) if err != nil { - log.Println(err) + if verbose == true { + log.Println(err) + } } else { defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - log.Println(err) + if verbose == true { + log.Println(err) + } } responseLines := len(strings.Split(string(body), "\n")) - 1 @@ -55,7 +59,9 @@ func httpRequest(channels channels, threadNr int) { } func httpHandler(channels channels) { - log.Printf("%s Starting the http handlers", green("[i]")) + if verbose == true { + log.Printf("%s Starting the http handlers", green("[i]")) + } // handle one or more theads if threads <= 1 { @@ -63,7 +69,9 @@ func httpHandler(channels channels) { httpRequest(channels, 0) } else { - log.Printf("%s Starting %d threads...", yellow("[i]"), threads) + if verbose == true { + log.Printf("%s Starting %d threads...", yellow("[i]"), threads) + } // loop over all the threads starting a go routine fetching a word from // the wordlistChannel, making the request and inserting the result into @@ -71,13 +79,19 @@ func httpHandler(channels channels) { for i := 0; i < threads; i++ { go httpRequest(channels, i) } - log.Printf("%s Done starting %d threads", green("[i]"), threads) + if verbose == true { + log.Printf("%s Done starting %d threads", green("[i]"), threads) + } for i := 0; i < threads; i++ { threadNum := <-channels.doneChannel - fmt.Printf("Thread %d done!\n", threadNum) + if verbose == true { + fmt.Printf("Thread %d done!\n", threadNum) + } } } - log.Printf("%s Done starting the http handlers", boldGreen("[+]")) + if verbose == true { + log.Printf("%s Done starting the http handlers", boldGreen("[+]")) + } } -- cgit 1.4.1