Some useful tools for I2P
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
800 B

from . import util
class Filter:
name = "unnamed filter"
def process(self, info):
"""
process an info and return True if it should be added to blocklist
any other return value will cause this info to NOT be added to blocklist
"""
class FloodfillFilter(Filter):
name = "floodfill sybil detector"
def __init__(self, fmax):
self._floodfills = dict()
self.fmax = int(fmax)
def process(self, info):
caps = util.getcaps(info)
if not caps:
return False
if b'f' not in caps:
return False
h = util.getaddress(info)
if h not in self._floodfills:
self._floodfills[h] = 0
self._floodfills[h] += 1
return self._floodfills[h] > self.fmax