Browse Source

Implement the addr_check function

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac353@3073 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner 14 years ago
parent
commit
c0c672e3a4
1 changed files with 8 additions and 1 deletions
  1. 8 1
      src/lib/python/isc/net/check.py

+ 8 - 1
src/lib/python/isc/net/check.py

@@ -17,6 +17,9 @@
 Checking and parsing of ports and IP addresses.
 Checking and parsing of ports and IP addresses.
 """
 """
 
 
+from isc.net.addr import IPAddr
+import socket
+
 def port_check(port):
 def port_check(port):
     """
     """
     Takes a port as an int or string and checks if it is valid. It returns
     Takes a port as an int or string and checks if it is valid. It returns
@@ -38,4 +41,8 @@ def addr_check(addr):
     the IPAddr object. It raises ValueError if the passed string is not
     the IPAddr object. It raises ValueError if the passed string is not
     valid IP address.
     valid IP address.
     """
     """
-    pass
+    try:
+        return IPAddr(addr)
+    except socket.error:
+        raise ValueError('Value ' + addr +
+            ' is not valid IPv4 or IPv6 address')