From 4dc19211fc9b029ca411e8f29fdb638d503c3b5d Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Mon, 9 May 2011 19:16:44 +0200 Subject: [PATCH] [iptools.py] is_crans est IPv6 compliant darcs-hash:20110509171644-bd074-058f91149e0d93404b32aefbfeff10a779da73cf.gz --- gestion/iptools.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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