about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-11-02 21:11:26 +0100
committerEmile <hanemile@protonmail.com>2019-11-02 21:11:26 +0100
commit06440511a8a310bfebc8d67ef6de8f005c92bf64 (patch)
tree42071bf13be1080c12704f6f9e60a11e5a6ed1f2
parent319ac3d30db83acdb1d46bfab042ee468e7b29b0 (diff)
cleaned up logging
-rw-r--r--src/main.go42
1 files changed, 8 insertions, 34 deletions
diff --git a/src/main.go b/src/main.go
index badeed8..bfb839c 100644
--- a/src/main.go
+++ b/src/main.go
@@ -1,55 +1,29 @@
 package main
 
 import (
-	"fmt"
 	"log"
 )
 
 func main() {
-	// pase the command line aguments
+	// read command line arguments, create channels...
 	registerFlags()
-	log.Printf("%s Done reading flags", green("[+]"))
+	channels = registerChannels()
 
 	// read the wordlist from a file
 	wordlist, err := readWordlist(wordlist)
 	if err != nil {
 		log.Println(err)
 	}
-	log.Printf("%s Done reading the wordlist", green("[+]"))
-
-	// define channels storing the wordlist and the responses resulting from the
-	// 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
 	// these functions wait for input into the channels and process the given
 	// data
-	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("[i]"))
-		httpRequest(wordlistChannel, printChannel, nil, 0)
-	} else {
-		log.Printf("%s Starting %d threads...", yellow("[i]"), threads)
+	go writeWordlistToChannel(channels, wordlist)
+	go printResponses(channels)
 
-		// 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++ {
-			go httpRequest(wordlistChannel, printChannel, doneChannel, i)
-		}
-		log.Printf("%s Done starting %d threads", green("[i]"), threads)
+	// start the http server exposing the data found
+	go httpStartServer()
 
-		for i := 0; i < threads; i++ {
-			threadNum := <-doneChannel
-			fmt.Printf("Thread %d done!\n", threadNum)
-		}
-	}
+	// make the http requests by fetching the data from the channels
+	httpHandler(wordlistChannel, printChannel, doneChannel)
 }