From 0f5deac1ac7883564cfe6769028131108454e909 Mon Sep 17 00:00:00 2001 From: Jing Ling Date: Tue, 28 Jul 2020 00:43:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcdn=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/iscdn.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/modules/iscdn.py b/modules/iscdn.py index 33e82bc..b801ba3 100644 --- a/modules/iscdn.py +++ b/modules/iscdn.py @@ -37,11 +37,13 @@ def check_header_key(header): return True -def check_cdn_cidr(ip): - ip = ipaddress.ip_address(ip) - for cidr in cdn_ip_cidr: - if ip in ipaddress.ip_network(cidr): - return True +def check_cdn_cidr(content): + ips = set(content.split(',')) + for ip in ips: + ip = ipaddress.ip_address(ip) + for cidr in cdn_ip_cidr: + if ip in ipaddress.ip_network(cidr): + return True def check_cdn_asn(asn): @@ -55,7 +57,7 @@ def check_cdn(data): if cname: if check_cname_keyword(cname): data[index]['cdn'] = 1 - break + continue header = item.get('header') if header: header = json.loads(header) @@ -63,9 +65,9 @@ def check_cdn(data): data[index]['cdn'] = 1 continue kind = item.get('type') - ip = item.get('content') - if kind == 'A' and ip: - if check_cdn_cidr(ip): + content = item.get('content') + if kind == 'A' and content: + if check_cdn_cidr(content): data[index]['cdn'] = 1 continue asn = item.get('asn')