def evaluate(self,
hints # Information used for doing identification
):
"""Given a set of hints, evaluate this identifier and return True if
an identification is made.
"""
try:
ip = ipaddr.IPNetwork(hints['requester'])
except KeyError:
return False
# TODO: Find out of there's a more hash-like way to do this
# instead of a linear search. This would be great if it
# weren't GPL: https://pypi.python.org/pypi/pytricia
for cidr in self.cidrs:
if ip in cidr:
return True
return False
# A short test program
评论列表
文章目录