limit number of files per torrent. Increase max piece size to 256M

This commit is contained in:
orignal
2026-09-19 12:52:53 -04:00
parent 4f65b92b21
commit 933ee7db33
2 changed files with 7 additions and 3 deletions
+4 -1
View File
@@ -644,7 +644,10 @@ namespace torrents
});
if (len && fileLength && !filePath.empty ())
{
m_Files.emplace_back (std::make_shared<TorrentFile> (filePath, fileLength));
if (m_Files.size () < MAX_NUM_TORRENT_FILES)
m_Files.emplace_back (std::make_shared<TorrentFile> (filePath, fileLength));
else
m_Error = eTorrentErrorMalformedMetaInfo;
if (m_Length + fileLength <= MAX_TORRENT_LENGTH)
m_Length += fileLength;
else
+3 -2
View File
@@ -37,9 +37,10 @@ namespace torrents
{
constexpr size_t REQUEST_BLOCK_SIZE = 16384;
constexpr size_t MIN_PIECE_LENGTH = 16*1024; // 16K
constexpr size_t MAX_PIECE_LENGTH = 64*1024*1024; // 64M
constexpr size_t MAX_PIECE_LENGTH = 256*1024*1024; // 256M
constexpr size_t MAX_NUM_TORRENT_PIECES = 1024*1024; // 1M
constexpr size_t MAX_TORRENT_LENGTH = MAX_PIECE_LENGTH*MAX_NUM_TORRENT_PIECES; // 64T
constexpr size_t MAX_TORRENT_LENGTH = MAX_PIECE_LENGTH*MAX_NUM_TORRENT_PIECES; // 256T
constexpr size_t MAX_NUM_TORRENT_FILES = 10000;
constexpr uint16_t TORRENT_PORT = 6881; // not used by required by protocol
constexpr int MIN_TRACKER_REQUESTS_INTERVAL = 15000; // in milliseconds
constexpr size_t PEER_CONNECTION_RECEIVE_BUFFER_SIZE = 65535;