support providing a DialContext for the http client (#786)
This commit is contained in:
parent
de4c16bbe9
commit
8e53dbaeb8
|
@ -203,7 +203,8 @@ func (cl *Client) init(cfg *ClientConfig) {
|
|||
cl.ipBlockList = cfg.IPBlocklist
|
||||
cl.httpClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Proxy: cfg.HTTPProxy,
|
||||
Proxy: cfg.HTTPProxy,
|
||||
DialContext: cfg.HTTPDialContext,
|
||||
// I think this value was observed from some webseeds. It seems reasonable to extend it
|
||||
// to other uses of HTTP from the client.
|
||||
MaxConnsPerHost: 10,
|
||||
|
|
|
@ -91,6 +91,8 @@ type ClientConfig struct {
|
|||
// Defines proxy for HTTP requests, such as for trackers. It's commonly set from the result of
|
||||
// "net/http".ProxyURL(HTTPProxy).
|
||||
HTTPProxy func(*http.Request) (*url.URL, error)
|
||||
// Defines DialContext func to use for HTTP requests, such as for fetching metainfo and webtorrent seeds
|
||||
HTTPDialContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||
// Defines DialContext func to use for HTTP tracker announcements
|
||||
TrackerDialContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||
// Defines ListenPacket func to use for UDP tracker announcements
|
||||
|
|
Loading…
Reference in New Issue