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
评论列表
文章目录