MCPcopy
hub / github.com/tsenart/vegeta / LocalAddr

Function LocalAddr

lib/attack.go:176–182  ·  view source on GitHub ↗

LocalAddr returns a functional option which sets the local address an Attacker will use with its requests.

(addr net.IPAddr)

Source from the content-addressed store, hash-verified

174// LocalAddr returns a functional option which sets the local address
175// an Attacker will use with its requests.
176func LocalAddr(addr net.IPAddr) func(*Attacker) {
177 return func(a *Attacker) {
178 tr := a.client.Transport.(*http.Transport)
179 a.dialer.LocalAddr = &net.TCPAddr{IP: addr.IP, Zone: addr.Zone}
180 tr.DialContext = a.dialer.DialContext
181 }
182}
183
184// KeepAlive returns a functional option which toggles KeepAlive
185// connections on the dialer and transport.

Callers 1

TestLocalAddrFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestLocalAddrFunction · 0.68