We did it like this.
##
## Constants.
##
BANNED_IPS = (
'X.X.X.X',
'Y.Y.Y.Y',
)
In class (at the beginning, first thing to drop):
class Parser(object):
"""
The Parser parses the lines in a specified file and inserts them into
a Queue.
"""
## All check_* methods are called for each hit and must return True if the
## hit can be imported, False otherwise.
def check_ip(self, hit):
for x in BANNED_IPS:
if hit.ip.find(x) != -1:
return False
return True
You can use it to drop more than one ip - whole class (simplified version)
example
192.168.0. -> this gives you all ip's from 192.168.0.0 to 192.168.0.255 :)
##
## Constants.
##
BANNED_IPS = (
'X.X.X.X',
'Y.Y.Y.Y',
)
In class (at the beginning, first thing to drop):
class Parser(object):
"""
The Parser parses the lines in a specified file and inserts them into
a Queue.
"""
## All check_* methods are called for each hit and must return True if the
## hit can be imported, False otherwise.
def check_ip(self, hit):
for x in BANNED_IPS:
if hit.ip.find(x) != -1:
return False
return True
You can use it to drop more than one ip - whole class (simplified version)
example
192.168.0. -> this gives you all ip's from 192.168.0.0 to 192.168.0.255 :)