def cdn_ip(address): if address: _ = addr_to_int(address) for prefix, mask in CDN_RANGES.get(address.split('.')[0], {}): if _ & mask == prefix: return True return False
def cdn_ip(address): if not address: return False try: _ = addr_to_int(address) for prefix, mask in CDN_RANGES.get(address.split('.')[0], {}): if _ & mask == prefix: return True except (IndexError, ValueError): pass return False