Skip to content

Commit b9b80df

Browse files
committed
added protocol choice
1 parent b899980 commit b9b80df

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ You can download the pre-built binaries from the [releases](https://github.com/u
4242

4343
# Usage
4444

45-
reqstress requires 3 parameters to run:
45+
reqstress requires 4 parameters to run:
4646

4747
`-r` : Path of the request file. For example: `-r request.txt`. Request file should contain a raw HTTP request. For example:
4848

@@ -68,4 +68,6 @@ log=admin&pwd=asdadsasdads
6868

6969
`-w` : The number of workers to run. The default value is 500. You can increase or decrease this by testing out the capability of your system.
7070

71-
`-d` : Duration of the test (in seconds). Default is infinite.
71+
`-d` : Duration of the test (in seconds). Default is infinite.
72+
73+
`-p` : Protocol to attack. Can be http or https. Default is https.

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ var average_time time.Duration
2020
var numOfSuccess int
2121
var numOfFail int
2222
var numOfnon200 int
23+
var urlStr string
2324

2425
func sendRequest(wg *sync.WaitGroup, req *fasthttp.Request, resp *fasthttp.Response, client *fasthttp.Client) {
2526
defer wg.Done()
@@ -47,6 +48,7 @@ func main() {
4748
requestFile := flag.String("r", "", "Path of request file")
4849
numWorker := flag.Int("w", 500, "Number of worker. Default: 500")
4950
duration := flag.Int("d", 0, "Test duration. Default: infinite")
51+
protocol := flag.String("p", "https", "Protol to attack. http or https.")
5052
flag.Parse()
5153
if *requestFile == "" {
5254
fmt.Println("Please specify all arguments!")
@@ -63,7 +65,12 @@ func main() {
6365
panic(err)
6466
}
6567
var wg sync.WaitGroup
66-
urlStr := "http://" + httpRequest.Host + httpRequest.RequestURI
68+
if *protocol == "http" {
69+
urlStr = "http://" + httpRequest.Host + httpRequest.RequestURI
70+
} else {
71+
urlStr = "https://" + httpRequest.Host + httpRequest.RequestURI
72+
}
73+
6774
bodyBytes, _ := ioutil.ReadAll(httpRequest.Body)
6875
bodyString := string(bodyBytes)
6976
req := fasthttp.AcquireRequest()

0 commit comments

Comments
 (0)