about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-11-02 16:50:20 +0100
committerEmile <hanemile@protonmail.com>2019-11-02 16:50:20 +0100
commit2ef681c9b7edb76d236713d83fab9773f672177c (patch)
tree39ec714806a2c027897357f52307872e8bc4aa28
parentf810c9c4e96807171ddc2cae5a24a5957902808a (diff)
better logging
-rw-r--r--src/main.go22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main.go b/src/main.go
index 6bb8beb..2ef1f56 100644
--- a/src/main.go
+++ b/src/main.go
@@ -21,33 +21,33 @@ func main() {
 	// requests
 	wordlistChannel := make(chan string)
 	printChannel := make(chan Response)
+	doneChannel := make(chan int)
+	log.Printf("%s Done defining channels", green("[+]"))
 
 	// write into the wordlist channel and read out of the print channel
 	go writeWordlistToChannel(wordlistChannel, wordlist)
 	go printResponses(printChannel)
+	log.Printf("%s Done starting hander routines", green("[+]"))
 
 	log.Printf("%s Starting the http handlers", cyan("[+]"))
 	// handle one or more theads
 	if threads <= 1 {
-		log.Printf("%s 1 thread", yellow("[+]"))
-		httpRequest(wordlistChannel, printChannel)
+		log.Printf("%s 1 thread", yellow("[i]"))
+		httpRequest(wordlistChannel, printChannel, nil, 0)
 	} else {
-		log.Printf("%s multiple threads", yellow("[+]"))
+		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
 		// the printChannel
 		for i := 0; i < threads; i++ {
-			log.Printf("%s Starting Thread %d\n", cyan("[i]"), i)
-			go httpRequest(wordlistChannel, printChannel)
+			go httpRequest(wordlistChannel, printChannel, doneChannel, i)
 		}
-	}
-
-	fmt.Println(len(wordlistChannel))
+		log.Printf("%s Done starting %d threads", green("[i]"), threads)
 
-	for {
-		if len(wordlistChannel) > 0 {
-			break
+		for i := 0; i < threads; i++ {
+			threadNum := <-doneChannel
+			fmt.Printf("Thread %d done!\n", threadNum)
 		}
 	}
 }