diff options
author | Christopher Harvey <chris@basementcode.com> | 2010-08-17 06:17:35 -0400 |
---|---|---|
committer | Christopher Harvey <chris@basementcode.com> | 2010-08-17 06:17:35 -0400 |
commit | 19126c9ae309aebb7c802006df37a9a0dbe65077 (patch) | |
tree | a6f1844911706f9b7e07072d2dc45d08a638b5f6 | |
parent | Added the change root feature. (diff) | |
download | ventoo-19126c9ae309aebb7c802006df37a9a0dbe65077.tar.gz ventoo-19126c9ae309aebb7c802006df37a9a0dbe65077.tar.bz2 ventoo-19126c9ae309aebb7c802006df37a9a0dbe65077.zip |
-rw-r--r-- | modules/hosts/ipMatch.py | 15 | ||||
-rw-r--r-- | modules/hosts/main.xml | 4 |
2 files changed, 17 insertions, 2 deletions
diff --git a/modules/hosts/ipMatch.py b/modules/hosts/ipMatch.py new file mode 100644 index 0000000..f633cd5 --- /dev/null +++ b/modules/hosts/ipMatch.py @@ -0,0 +1,15 @@ +import re + +def validate(userIn): + ipVer4 = "^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$" + ipVer6Std = "^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$" + ipVer6Hex = "^((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)::((?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4})*)?)$" + + if(re.match(ipVer4, userIn)!=None): + return True + elif(re.match(ipVer6Std, userIn)!=None): + return True + elif(re.match(ipVer6Hex, userIn)!=None): + return True + + return False diff --git a/modules/hosts/main.xml b/modules/hosts/main.xml index 4b17844..df647e0 100644 --- a/modules/hosts/main.xml +++ b/modules/hosts/main.xml @@ -1,7 +1,7 @@ <VentooModule> <root mult="*"> - <ipaddr mult="1" docurl="ipaddr.html"/> + <ipaddr mult="1" docurl="ipaddr.html" validate="ipMatch.py"/> <canonical mult="1"/> <alias mult="*"/> </root> -</VentooModule>
\ No newline at end of file +</VentooModule> |