From 6809acb6c651d12dc348f1089dc630aeb9be0866 Mon Sep 17 00:00:00 2001 From: Emile Date: Sat, 2 Nov 2019 21:12:43 +0100 Subject: http Handler --- src/httpRequest.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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("[+]")) +} -- cgit 1.4.1