about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-11-02 21:12:43 +0100
committerEmile <hanemile@protonmail.com>2019-11-02 21:12:43 +0100
commit6809acb6c651d12dc348f1089dc630aeb9be0866 (patch)
treeca97e7ec1755e86d9ff58043ccfd8f8ff0282ffd /src
parentcc8223215bc5aa45ce7dee1a1e96fb091d29f6a8 (diff)
http Handler
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("[+]"))
+}