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.

26 lines
769 B

8 years ago
from . import util
import datetime
class BaddieProcessor:
def __init__(self, filters):
self._filters = filters
self._baddies = dict()
def hook(self, entry):
now = datetime.datetime.now()
8 years ago
for f in self._filters:
if f.process(entry) is True:
self.add_baddie(entry, 'detected by {} on {}'.format(f.name, now.strftime("%c").replace(":",'-')))
8 years ago
def add_baddie(self, entry, reason):
addr = util.getaddress(entry).decode('ascii')
self._baddies[addr] = reason
8 years ago
def write_blocklist(self, f):
8 years ago
f.write('# baddies blocklist generated on {}\n'.format(datetime.datetime.now()))
8 years ago
for k in self._baddies:
f.write('{}:{}\n'.format(self._baddies[k], k))