about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/httpRequest.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/httpRequest.go b/src/httpRequest.go
index 12a8a6d..4d1c3d8 100644
--- a/src/httpRequest.go
+++ b/src/httpRequest.go
@@ -1,6 +1,7 @@
 package main
 
 import (
+	"fmt"
 	"log"
 	"net/http"
 	"strings"
@@ -33,3 +34,30 @@ func httpRequest(wordlistChannel chan string, printChannel chan Response, doneCh
 		doneChannel <- threadNr
 	}
 }
+
+func httpHandler(wordlistChannel chan string, printChannel chan Response, doneChannel chan int) {
+	log.Printf("%s Starting the http handlers", green("[i]"))
+
+	// 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)
+
+		// 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)
+
+		for i := 0; i < threads; i++ {
+			threadNum := <-doneChannel
+			fmt.Printf("Thread %d done!\n", threadNum)
+		}
+	}
+
+	log.Printf("%s Done starting the http handlers", boldGreen("[+]"))
+}