1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | class CIDR_LIST(list):
def __init__(self, cidrs):
self.cidrs = []
try:
#http://cheeseshop.python.org/pypi/IPv4_Utils/0.35
import ipv4
for cidr in cidrs:
self.cidrs.append(ipv4.CIDR(cidr))
except ImportError:
pass
def __contains__(self, ip):
import ipv4
try:
for cidr in self.cidrs:
if ipv4.CIDR(ip) in cidr:
return True
except:
pass
return False
|
More like this
- Include entire networks in INTERNAL_IPS setting by pmclanahan 2 years, 11 months ago
- Globs for INTERNAL_IPS by kcarnold 2 years, 10 months ago
- Internal view decorator by gsakkis 1 year, 6 months ago
- Firebug Lite Middleware by jfw 3 years, 3 months ago
- Middleware to prevent access to the admin when user ip not in INTERNAL_IPS by jezdez 1 year, 7 months ago
Comments