about summary refs log tree commit diff
path: root/src/httpRequest.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-11-03 18:07:28 +0100
committerEmile <hanemile@protonmail.com>2019-11-03 18:07:28 +0100
commit79244e7df141a416c803b4f7d15819228ec610c5 (patch)
tree077a66739155175db83c6fd0665800a3a9cee54a /src/httpRequest.go
parentd93cbbed938d318abdee405ef29f77a5fe9c3f4a (diff)
verbose
Diffstat (limited to 'src/httpRequest.go')
-rw-r--r--src/httpRequest.go28
1 files changed, 21 insertions, 7 deletions
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("[+]"))
+	}
 }