Skip to content

Commit 9786350

Browse files
committed
feat: route http requests through a proxy
1 parent a3dd4f6 commit 9786350

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Looking for new features? Create an issue.
2020
- POST/PUT/PATCH HTTP requests
2121
- HTTP JSON payload
2222
- Custom HTTP headers
23+
- Proxy HTTP requests
2324

2425
## Coming
2526

2627
- UDP payload attachment
2728
- Form data payload
2829
- JSON output of the result
29-
- Proxy
3030

3131
## Usage
3232

@@ -86,6 +86,8 @@ Usage of RIP
8686
POST HTTP request (default false)
8787
-put bool
8888
PUT HTTP request (default false)
89+
-proxy string
90+
The proxy URL to route the traffic (default "")
8991
-udp bool
9092
Run requests UDP flood attack and not http requests (default false)
9193
-udp-bytes int

request/request.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io"
66
"net"
77
"net/http"
8+
"net/url"
89

910
"github.com/bjarneo/rip/statistics"
1011
"github.com/bjarneo/rip/utils"
@@ -64,6 +65,17 @@ func httpRequests(hosts []string, args utils.Arguments, stats statistics.Statist
6465
}
6566

6667
client := &http.Client{}
68+
69+
if args.Proxy() != "" {
70+
proxyUrl, err := url.Parse(args.Proxy())
71+
72+
if err != nil {
73+
panic(err)
74+
}
75+
76+
client.Transport = &http.Transport{Proxy: http.ProxyURL(proxyUrl)}
77+
}
78+
6779
resp, err := client.Do(req)
6880

6981
if err != nil {

utils/args.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Arguments struct {
1919
patch *bool
2020
json *string
2121
headers *string
22+
proxy *string
2223
}
2324

2425
func Args() Arguments {
@@ -34,6 +35,7 @@ func Args() Arguments {
3435
patch: flag.Bool("patch", false, "PATCH HTTP request"),
3536
json: flag.String("json", "", "Path to the JSON payload file to be used for the HTTP requests"),
3637
headers: flag.String("headers", "", "Path to the headers file"),
38+
proxy: flag.String("proxy", "", "The proxy URL to route the traffic"),
3739
}
3840

3941
flag.Parse()
@@ -120,3 +122,7 @@ func (flags *Arguments) Headers() []string {
120122

121123
return make([]string, 0)
122124
}
125+
126+
func (flags *Arguments) Proxy() string {
127+
return *flags.proxy
128+
}

0 commit comments

Comments
 (0)