handle numeric private value in metainfo

This commit is contained in:
zzz
2013-11-11 23:24:14 +00:00
parent 1b95a03d2e
commit 76078deb3f
2 changed files with 11 additions and 2 deletions

View File

@ -216,7 +216,16 @@ public class MetaInfo
// BEP 27
val = info.get("private");
privateTorrent = val != null && val.getString().equals("1");
if (val != null) {
Object o = val.getValue();
// Is it supposed to be a number or a string?
// i2psnark does it as a string. BEP 27 doesn't say.
// Transmission does numbers.
privateTorrent = "1".equals(o) ||
((o instanceof Number) && ((Number) o).intValue() == 1);
} else {
privateTorrent = false;
}
val = info.get("piece length");
if (val == null)