Skip to content

Commit

Permalink
Merge pull request #234 from chrismoos/proxy_option
Browse files Browse the repository at this point in the history
Add option to override HTTP Proxy on Attacker.
  • Loading branch information
tsenart authored May 18, 2018
2 parents beea5c7 + e02ecc7 commit 6d87d90
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"net"
"net/http"
"net/url"
"sync"
"time"

Expand Down Expand Up @@ -105,6 +106,15 @@ func Redirects(n int) func(*Attacker) {
}
}

// Proxy returns a functional option which sets the `Proxy` field on
// the http.Client's Transport
func Proxy(proxy func(*http.Request) (*url.URL, error)) func(*Attacker) {
return func(a *Attacker) {
tr := a.client.Transport.(*http.Transport)
tr.Proxy = proxy
}
}

// Timeout returns a functional option which sets the maximum amount of time
// an Attacker will wait for a request to be responded to.
func Timeout(d time.Duration) func(*Attacker) {
Expand Down

0 comments on commit 6d87d90

Please sign in to comment.