use of com.biglybt.core.util.bloom.BloomFilter in project BiglyBT by BiglySoftware.
the class DHTPluginStorageManager method verifyKeyBlock.
protected boolean verifyKeyBlock(keyBlock kb, DHTTransportContact originator) {
byte[] id = originator == null ? new byte[20] : originator.getID();
BloomFilter filter = kb_verify_fail_bloom;
long now = SystemTime.getCurrentTime();
if (filter == null || kb_verify_fail_bloom_create_time > now || now - kb_verify_fail_bloom_create_time > 30 * 60 * 1000) {
kb_verify_fail_bloom_create_time = now;
filter = BloomFilterFactory.createAddOnly(4000);
kb_verify_fail_bloom = filter;
}
if (filter.contains(id)) {
log.log("KB: request verify denied");
return (false);
}
try {
Signature verifier = Signature.getInstance("MD5withRSA");
verifier.initVerify(key_block_public_key);
verifier.update(kb.getRequest());
if (!verifier.verify(kb.getCertificate())) {
log.log("KB: request verify failed for " + DHTLog.getString2(kb.getKey()));
filter.add(id);
return (false);
}
log.log("KB: request verify ok " + DHTLog.getString2(kb.getKey()) + ", add = " + kb.isAdd() + ", direct = " + kb.isDirect());
return (true);
} catch (Throwable e) {
return (false);
}
}
use of com.biglybt.core.util.bloom.BloomFilter in project BiglyBT by BiglySoftware.
the class BloomFilterRotator method serialiseToMap.
protected void serialiseToMap(Map<String, Object> x) {
synchronized (filters) {
String cla = this.getClass().getName();
if (cla.startsWith(BloomFilterImpl.MY_PACKAGE)) {
cla = cla.substring(BloomFilterImpl.MY_PACKAGE.length());
}
x.put("_impl", cla);
List<Map<String, Object>> list = new ArrayList<>();
for (BloomFilter filter : filters) {
list.add(filter.serialiseToMap());
}
x.put("list", list);
x.put("index", new Long(current_filter_index));
}
}
Aggregations