"fmt"
"io"
"net"
+ "net/http"
+ "net/url"
"strconv"
"strings"
"time"
}
}
+ if cl.config.HTTPProxy == nil && cl.config.ProxyURL != "" {
+ if fixedURL, err := url.Parse(cl.config.ProxyURL); err == nil {
+ cl.config.HTTPProxy = http.ProxyURL(fixedURL)
+ }
+ }
+
cl.conns, err = listenAll(cl.enabledPeerNetworks(), cl.config.ListenHost, cl.config.ListenPort, cl.config.ProxyURL, cl.firewallCallback)
if err != nil {
return
import (
"net"
+ "net/http"
+ "net/url"
"time"
"github.com/anacrolix/dht"
EncryptionPolicy
// Sets usage of Socks5 Proxy. Authentication should be included in the url if needed.
- // Example of setting: "socks5://demo:demo@192.168.99.100:1080"
+ // Examples: socks5://demo:demo@192.168.99.100:1080
+ // http://proxy.domain.com:3128
ProxyURL string
IPBlocklist iplist.Ranger
// Perform logging and any other behaviour that will help debug.
Debug bool `help:"enable debugging"`
+ // HTTPProxy defines proxy for HTTP requests.
+ // Format: func(*Request) (*url.URL, error),
+ // or result of http.ProxyURL(HTTPProxy).
+ // By default, it is composed from ClientConfig.ProxyURL,
+ // if not set explicitly in ClientConfig struct
+ HTTPProxy func(*http.Request) (*url.URL, error)
// HTTPUserAgent changes default UserAgent for HTTP requests
HTTPUserAgent string
// Updated occasionally to when there's been some changes to client
Dial: (&net.Dialer{
Timeout: 15 * time.Second,
}).Dial,
+ Proxy: opt.HTTPProxy,
TLSHandshakeTimeout: 15 * time.Second,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
import (
"errors"
+ "net/http"
"net/url"
"github.com/anacrolix/dht/krpc"
TrackerUrl string
Request AnnounceRequest
HostHeader string
+ HTTPProxy func(*http.Request) (*url.URL, error)
ServerName string
UserAgent string
UdpNetwork string
req := me.t.announceRequest()
me.t.cl.unlock()
res, err := tracker.Announce{
+ HTTPProxy: me.t.cl.config.HTTPProxy,
UserAgent: me.t.cl.config.HTTPUserAgent,
TrackerUrl: me.trackerUrl(ip),
Request: req,