* i2psnark:

- Reject torrents with too many pieces
      - Reject torrents with a single file named *.torrent
      - Increase max piece size to 2MB (was 1MB), but reduce
        max number of connections to lessen ooms
This commit is contained in:
zzz
2009-11-09 17:09:53 +00:00
parent 13b3edfb07
commit 05b17e5a00
3 changed files with 22 additions and 6 deletions

View File

@@ -552,11 +552,15 @@ public class SnarkManager implements Snark.CompleteListener {
List files = info.getFiles();
if ( (files != null) && (files.size() > MAX_FILES_PER_TORRENT) ) {
return "Too many files in " + info.getName() + " (" + files.size() + "), deleting it!";
} else if ( (files == null) && (info.getName().endsWith(".torrent")) ) {
return "Torrent file " + info.getName() + " cannot end in '.torrent', deleting it!";
} else if (info.getPieces() <= 0) {
return "No pieces in " + info.getName() + "? deleting it!";
} else if (info.getPieces() > Storage.MAX_PIECES) {
return "Too many pieces in " + info.getName() + ", limit is " + Storage.MAX_PIECES + ", deleting it!";
} else if (info.getPieceLength(0) > Storage.MAX_PIECE_SIZE) {
return "Pieces are too large in " + info.getName() + " (" + DataHelper.formatSize(info.getPieceLength(0)) +
"B), deleting it.";
"B, limit is " + DataHelper.formatSize(Storage.MAX_PIECE_SIZE) + "B), deleting it.";
} else if (info.getTotalLength() > Storage.MAX_TOTAL_SIZE) {
System.out.println("torrent info: " + info.toString());
List lengths = info.getLengths();