]> Sergey Matveev's repositories - btrtrc.git/blobdiff - global.go
No Web*
[btrtrc.git] / global.go
index ff237c8ee1edda4f9d464d08d9db1bb49c7fa670..988d434a28783f6f6b07c5aeb9a8a6c89d120546 100644 (file)
--- a/global.go
+++ b/global.go
@@ -9,8 +9,14 @@ import (
 
 const (
        pieceHash        = crypto.SHA1
-       maxRequests      = 250    // Maximum pending requests we allow peers to send us.
        defaultChunkSize = 0x4000 // 16KiB
+
+       // Arbitrary maximum of "metadata_size" (see https://www.bittorrent.org/beps/bep_0009.html)
+       // libtorrent-rasterbar uses 4MiB at last check. TODO: Add links to values used by other
+       // implementations here. I saw 14143527 in the metainfo for
+       // 3597f16e239aeb8f8524a1a1c4e4725a0a96b470. Large values for legitimate torrents should be
+       // recorded here for consideration.
+       maxMetadataSize uint32 = 16 * 1024 * 1024
 )
 
 // These are our extended message IDs. Peers will use these values to
@@ -26,6 +32,7 @@ func defaultPeerExtensionBytes() PeerExtensionBits {
 
 func init() {
        torrent.Set("peers supporting extension", &peersSupportingExtension)
+       torrent.Set("chunks received", &chunksReceived)
 }
 
 // I could move a lot of these counters to their own file, but I suspect they
@@ -33,6 +40,7 @@ func init() {
 var (
        torrent                  = expvar.NewMap("torrent")
        peersSupportingExtension expvar.Map
+       chunksReceived           expvar.Map
 
        pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
        pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")