Remove ClientConfig.ProxyURL and DefaultHTTPUserAgent

ProxyURL is no longer used for implicit sockets, this will ensure consumers are aware. It's other behaviour is already more correct specified through HTTPProxy.

DefaultHTTPUserAgent was vestigial, and is specified now through the ClientConfig.
This commit is contained in:
Matt Joiner 2020-02-20 17:04:11 +11:00
parent 3505d126d4
commit 71f18f1042
2 changed files with 3 additions and 21 deletions

View File

@ -10,8 +10,6 @@ import (
"fmt" "fmt"
"io" "io"
"net" "net"
"net/http"
"net/url"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -217,12 +215,6 @@ func NewClient(cfg *ClientConfig) (cl *Client, err error) {
} }
} }
if cl.config.HTTPProxy == nil && cl.config.ProxyURL != "" {
if fixedURL, err := url.Parse(cl.config.ProxyURL); err == nil {
cl.config.HTTPProxy = http.ProxyURL(fixedURL)
}
}
sockets, err := listenAll(cl.listenNetworks(), cl.config.ListenHost, cl.config.ListenPort, cl.firewallCallback) sockets, err := listenAll(cl.listenNetworks(), cl.config.ListenHost, cl.config.ListenPort, cl.firewallCallback)
if err != nil { if err != nil {
return return

View File

@ -19,8 +19,6 @@ import (
"github.com/anacrolix/torrent/storage" "github.com/anacrolix/torrent/storage"
) )
var DefaultHTTPUserAgent = "Go-Torrent/1.0"
// Probably not safe to modify this after it's given to a Client. // Probably not safe to modify this after it's given to a Client.
type ClientConfig struct { type ClientConfig struct {
// Store torrent file data in this directory unless .DefaultStorage is // Store torrent file data in this directory unless .DefaultStorage is
@ -76,11 +74,6 @@ type ClientConfig struct {
// Chooses the crypto method to use when receiving connections with header obfuscation. // Chooses the crypto method to use when receiving connections with header obfuscation.
CryptoSelector mse.CryptoSelector CryptoSelector mse.CryptoSelector
// Sets usage of Socks5 Proxy. Authentication should be included in the url if needed.
// Examples: socks5://demo:demo@192.168.99.100:1080
// http://proxy.domain.com:3128
ProxyURL string
IPBlocklist iplist.Ranger IPBlocklist iplist.Ranger
DisableIPv6 bool `long:"disable-ipv6"` DisableIPv6 bool `long:"disable-ipv6"`
DisableIPv4 bool DisableIPv4 bool
@ -89,11 +82,8 @@ type ClientConfig struct {
Debug bool `help:"enable debugging"` Debug bool `help:"enable debugging"`
Logger log.Logger Logger log.Logger
// HTTPProxy defines proxy for HTTP requests. // Defines proxy for HTTP requests, such as for trackers. It's commonly set from the result of
// Format: func(*Request) (*url.URL, error), // "net/http".ProxyURL(HTTPProxy).
// 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) HTTPProxy func(*http.Request) (*url.URL, error)
// HTTPUserAgent changes default UserAgent for HTTP requests // HTTPUserAgent changes default UserAgent for HTTP requests
HTTPUserAgent string HTTPUserAgent string
@ -150,7 +140,7 @@ func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {
func NewDefaultClientConfig() *ClientConfig { func NewDefaultClientConfig() *ClientConfig {
cc := &ClientConfig{ cc := &ClientConfig{
HTTPUserAgent: DefaultHTTPUserAgent, HTTPUserAgent: "Go-Torrent/1.0",
ExtendedHandshakeClientVersion: "go.torrent dev 20181121", ExtendedHandshakeClientVersion: "go.torrent dev 20181121",
Bep20: "-GT0002-", Bep20: "-GT0002-",
UpnpID: "anacrolix/torrent", UpnpID: "anacrolix/torrent",