diff --git a/gestion/iptools.py b/gestion/iptools.py index db516767..f6a64de3 100644 --- a/gestion/iptools.py +++ b/gestion/iptools.py @@ -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