]> Sergey Matveev's repositories - btrtrc.git/blobdiff - config.go
Fix UseSources panicking when sqlite storage is closed
[btrtrc.git] / config.go
index 09f9bc1eb07ad099e9f4a63eb608421e4b42c8c0..cfcfe392c3beb0d550c9ff6b6b451cb2f4eb2019 100644 (file)
--- a/config.go
+++ b/config.go
@@ -117,6 +117,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 +148,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 +180,12 @@ 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
 }
 
 func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {
@@ -202,6 +213,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,
@@ -217,6 +229,7 @@ func NewDefaultClientConfig() *ClientConfig {
                Extensions:            defaultPeerExtensionBytes(),
                AcceptPeerConnections: true,
                MaxUnverifiedBytes:    64 << 20,
+               DialRateLimiter:       rate.NewLimiter(10, 10),
        }
        cc.DhtStartingNodes = func(network string) dht.StartingNodesGetter {
                return func() ([]dht.Addr, error) { return dht.GlobalBootstrapAddrs(network) }