aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/hosts/ipMatch.py15
-rw-r--r--modules/hosts/main.xml4
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>