修复非IP报错

This commit is contained in:
Jing Ling
2020-08-16 19:34:09 +08:00
parent bb80ae357d
commit c645a58263
+4
View File
@@ -40,7 +40,11 @@ def check_header_key(header):
def check_cdn_cidr(content):
ips = set(content.split(','))
for ip in ips:
try:
ip = ipaddress.ip_address(ip)
except Exception as e:
logger.log('DEBUG', e.args)
return False
for cidr in cdn_ip_cidr:
if ip in ipaddress.ip_network(cidr):
return True