]> Sergey Matveev's repositories - btrtrc.git/blobdiff - config.go
Drop support for go 1.20
[btrtrc.git] / config.go
index 09f9bc1eb07ad099e9f4a63eb608421e4b42c8c0..e2d0ea1ebec230cce1c7fa50e67ff5fc88f8006d 100644 (file)
--- a/config.go
+++ b/config.go
@@ -107,6 +107,8 @@ type ClientConfig struct {
        Debug  bool `help:"enable debugging"`
        Logger log.Logger
 
+       // Used for torrent sources and webseeding if set.
+       WebTransport http.RoundTripper
        // 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)
@@ -117,6 +119,9 @@ type ClientConfig struct {
        // HttpRequestDirector modifies the request before it's sent.
        // Useful for adding authentication headers, for example
        HttpRequestDirector func(*http.Request) error
+       // WebsocketTrackerHttpHeader returns a custom header to be used when dialing a websocket connection
+       // to the tracker. Useful for adding authentication headers
+       WebsocketTrackerHttpHeader func() http.Header
        // Updated occasionally to when there's been some changes to client
        // behaviour in case other clients are assuming anything of us. See also
        // `bep20`.
@@ -145,6 +150,8 @@ type ClientConfig struct {
        // How long between writes before sending a keep alive message on a peer connection that we want
        // to maintain.
        KeepAliveTimeout time.Duration
+       // Maximum bytes to buffer per peer connection for peer request data before it is sent.
+       MaxAllocPeerRequestDataPerConn int64
 
        // The IP addresses as our peers should see them. May differ from the
        // local interfaces due to NAT or other network configurations.
@@ -175,6 +182,14 @@ type ClientConfig struct {
        DisableWebseeds   bool
 
        Callbacks Callbacks
+
+       // ICEServers defines a slice describing servers available to be used by
+       // ICE, such as STUN and TURN servers.
+       ICEServers []string
+
+       DialRateLimiter *rate.Limiter
+
+       PieceHashersPerTorrent int // default: 2
 }
 
 func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {
@@ -202,6 +217,7 @@ func NewDefaultClientConfig() *ClientConfig {
                TorrentPeersLowWater:           50,
                HandshakesTimeout:              4 * time.Second,
                KeepAliveTimeout:               time.Minute,
+               MaxAllocPeerRequestDataPerConn: 1 << 20,
                ListenHost:                     func(string) string { return "" },
                UploadRateLimiter:              unlimited,
                DownloadRateLimiter:            unlimited,
@@ -211,12 +227,14 @@ func NewDefaultClientConfig() *ClientConfig {
                        Preferred:        true,
                        RequirePreferred: false,
                },
-               CryptoSelector:        mse.DefaultCryptoSelector,
-               CryptoProvides:        mse.AllSupportedCrypto,
-               ListenPort:            42069,
-               Extensions:            defaultPeerExtensionBytes(),
-               AcceptPeerConnections: true,
-               MaxUnverifiedBytes:    64 << 20,
+               CryptoSelector:         mse.DefaultCryptoSelector,
+               CryptoProvides:         mse.AllSupportedCrypto,
+               ListenPort:             42069,
+               Extensions:             defaultPeerExtensionBytes(),
+               AcceptPeerConnections:  true,
+               MaxUnverifiedBytes:     64 << 20,
+               DialRateLimiter:        rate.NewLimiter(10, 10),
+               PieceHashersPerTorrent: 2,
        }
        cc.DhtStartingNodes = func(network string) dht.StartingNodesGetter {
                return func() ([]dht.Addr, error) { return dht.GlobalBootstrapAddrs(network) }