[iptools.py] is_crans est IPv6 compliant

darcs-hash:20110509171644-bd074-058f91149e0d93404b32aefbfeff10a779da73cf.gz
This commit is contained in:
Antoine Durand-Gasselin 2011-05-09 19:16:44 +02:00
parent 0b78812de7
commit 4dc19211fc

View file

@ -7,8 +7,8 @@ Copyright (C) Frédéric Pauget
Licence : GPLv2
"""
import re
from config import NETs_regexp
import re, netaddr
from config import NETs_regexp, prefix
# Pour accélérer QuadToDec...
__QuadToDecDone = {}
@ -123,9 +123,10 @@ def is_crans(ip):
""" Vérifie que l'ip est dans le réseau CRANS
"""
# Pour titanic
if ip == '138.231.136.14' :
ip = netaddr.IPAddress(ip)
if str(ip) in [ '138.231.136.14', '2a01:240:fe3d:4:a873:65ff:fe63:6f75']:
return False
if re.match(NETs_regexp['all'], ip):
if re.match(NETs_regexp['all'], str(ip)) or ip in netaddr.IPNetwork(prefix['subnet'][0]):
return True
return False