pass TrackerDialContext to webtorrent trackers (#785)
This commit is contained in:
parent
8e53dbaeb8
commit
455913c752
|
@ -298,7 +298,8 @@ func NewClient(cfg *ClientConfig) (cl *Client, err error) {
|
|||
}
|
||||
return t.announceRequest(event), nil
|
||||
},
|
||||
Proxy: cl.config.HTTPProxy,
|
||||
Proxy: cl.config.HTTPProxy,
|
||||
DialContext: cl.config.TrackerDialContext,
|
||||
OnConn: func(dc datachannel.ReadWriteCloser, dcc webtorrent.DataChannelContext) {
|
||||
cl.lock()
|
||||
defer cl.unlock()
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package torrent
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
"sync"
|
||||
|
||||
|
@ -40,6 +42,7 @@ type websocketTrackers struct {
|
|||
mu sync.Mutex
|
||||
clients map[string]*refCountedWebtorrentTrackerClient
|
||||
Proxy http.ProxyFunc
|
||||
DialContext func(ctx context.Context, network, addr string) (net.Conn, error)
|
||||
}
|
||||
|
||||
func (me *websocketTrackers) Get(url string, infoHash [20]byte) (*webtorrent.TrackerClient, func()) {
|
||||
|
@ -47,7 +50,7 @@ func (me *websocketTrackers) Get(url string, infoHash [20]byte) (*webtorrent.Tra
|
|||
defer me.mu.Unlock()
|
||||
value, ok := me.clients[url]
|
||||
if !ok {
|
||||
dialer := &websocket.Dialer{Proxy: me.Proxy, HandshakeTimeout: websocket.DefaultDialer.HandshakeTimeout}
|
||||
dialer := &websocket.Dialer{Proxy: me.Proxy, NetDialContext: me.DialContext, HandshakeTimeout: websocket.DefaultDialer.HandshakeTimeout}
|
||||
value = &refCountedWebtorrentTrackerClient{
|
||||
TrackerClient: webtorrent.TrackerClient{
|
||||
Dialer: dialer,
|
||||
|
|
Loading…
Reference in New Issue