http.py 文件源码

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

项目:Sentry 作者: NetEaseGame 项目源码 文件源码
def is_valid_ip(ip_address, project):
    """
    Verify that an IP address is not being blacklisted
    for the given project.
    """
    blacklist = project.get_option('sentry:blacklisted_ips')
    if not blacklist:
        return True

    ip_network = IPNetwork(ip_address)
    for addr in blacklist:
        # We want to error fast if it's an exact match
        if ip_address == addr:
            return False

        # Check to make sure it's actually a range before
        # attempting to see if we're within that range
        if '/' in addr and ip_network in IPNetwork(addr):
            return False

    return True

# #845, add for server name filter, by hzwangzhiwei @20160803
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号