def is_authorized(ip, authorized_ips):
ip = ip_address(ip)
for item in authorized_ips:
try:
if ip == ip_address(item):
return True
except ValueError:
try:
if ip in ip_network(item):
return True
except ValueError:
logger.warn('The "authorized_ip" list (settings.HEARTBEAT)'
'contains an item that is neither an ip address '
'nor an ip network: {}'.format(item))
评论列表
文章目录