ipcidrlist.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:pscheduler 作者: perfsonar 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号