]> Sergey Matveev's repositories - btrtrc.git/blobdiff - config.go
Fix panic logging unknown holepunch error code
[btrtrc.git] / config.go
index e1e6452af1699ac8c509f8d25b45846d74096908..fca37e637a5d5c8a148d96fe2a1895a88133a345 100644 (file)
--- a/config.go
+++ b/config.go
@@ -148,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.
@@ -178,6 +180,8 @@ type ClientConfig struct {
        DisableWebseeds   bool
 
        Callbacks Callbacks
+
+       DialRateLimiter *rate.Limiter
 }
 
 func (cfg *ClientConfig) SetListenAddr(addr string) *ClientConfig {
@@ -205,6 +209,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,
@@ -220,6 +225,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) }