X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=global.go;h=5a5bddba0a6b3acfebea35d8f21d908a38ce3be0;hb=HEAD;hp=1de8539b3eb94a31223a8f8bf120ae84c3c5180d;hpb=76a3c0891ade5256f530abb56e29918192b780ab;p=btrtrc.git diff --git a/global.go b/global.go index 1de8539b..5a5bddba 100644 --- a/global.go +++ b/global.go @@ -1,43 +1,55 @@ package torrent import ( - pp "github.com/anacrolix/torrent/peer_protocol" "crypto" "expvar" + + pp "github.com/anacrolix/torrent/peer_protocol" ) const ( pieceHash = crypto.SHA1 - maxRequests = 250 // Maximum pending requests we allow peers to send us. defaultChunkSize = 0x4000 // 16KiB - // These are our extended message IDs. Peers will use these values to - // select which extension a message is intended for. + // 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 +// select which extension a message is intended for. +const ( metadataExtendedId = iota + 1 // 0 is reserved for deleting keys pexExtendedId + utHolepunchExtendedId ) func defaultPeerExtensionBytes() PeerExtensionBits { - return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast) + return pp.NewPeerExtensionBytes(pp.ExtensionBitDht, pp.ExtensionBitLtep, pp.ExtensionBitFast) +} + +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 // may be attached to a Client someday. var ( - torrent = expvar.NewMap("torrent") - - peersAddedBySource = expvar.NewMap("peersAddedBySource") + torrent = expvar.NewMap("torrent") + peersSupportingExtension expvar.Map + chunksReceived expvar.Map pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect") pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect") - peerExtensions = expvar.NewMap("peerExtensions") completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags") // Count of connections to peer with same client ID. - connsToSelf = expvar.NewInt("connsToSelf") - receivedKeepalives = expvar.NewInt("receivedKeepalives") - supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages") - postedKeepalives = expvar.NewInt("postedKeepalives") + connsToSelf = expvar.NewInt("connsToSelf") + receivedKeepalives = expvar.NewInt("receivedKeepalives") // Requests received for pieces we don't have. requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces") requestedChunkLengths = expvar.NewMap("requestedChunkLengths") @@ -48,4 +60,6 @@ var ( pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused") pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew") pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut") + + concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites") )