Skip to content

Commit

Permalink
feat(cmd): implement struct forceData with neccesary data for brutfor…
Browse files Browse the repository at this point in the history
…cer's request
  • Loading branch information
57ave committed Jun 28, 2024
1 parent 5a93954 commit 681cde1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions cmd/callWorker.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ type forceData struct {
url string
}

func executeQueryFromFile(currentPath chan string) {
func executeQueryFromFile(data forceData, currentPath chan string) {
for taskData := range currentPath{
queryExecute(taskData, "POST")
queryExecute(data, taskData, "POST")
}
}

func mainRequest(worker int) {
func mainRequest(data forceData) {
channel := make(chan string)
wordArray := GetFileContent("../wordList/rootList")

for i := 0 ;i < worker; i++ {
go executeQueryFromFile(channel)
for i := 0 ;i < data.worker; i++ {
go executeQueryFromFile(data, channel)
}
for i := 0; i < len(wordArray); i++ {
channel <- wordArray[i]
Expand All @@ -31,5 +31,10 @@ func mainRequest(worker int) {
}

func main () {
mainRequest(3);
data := forceData {
worker: 3,
wordList: "../wordList/rootList",
url: "http://localhost:3333",
}
mainRequest(data);
}
4 changes: 2 additions & 2 deletions cmd/queryExecute.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"net/http"
)

func queryExecute(path string, method string) {
func queryExecute(data forceData, path string, method string) {

client := &http.Client{}
req, err := http.NewRequest(method, "http://localhost:3333" + path, nil)
req, err := http.NewRequest(method, data.url + path, nil)
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 681cde1

Please sign in to comment.