Parcourir la source

Implement the port_check function

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac353@3070 e5f2f494-b856-4b98-b285-d166d9295462
Michal Vaner il y a 14 ans
Parent
commit
df7d7460be
1 fichiers modifiés avec 8 ajouts et 1 suppressions
  1. 8 1
      src/lib/python/isc/net/check.py

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

@@ -23,7 +23,14 @@ def port_check(port):
     the port as int. If it is not a valid port (the string doesn't contain
     the port as int. If it is not a valid port (the string doesn't contain
     number or it is not in the valid range), it raises ValueError.
     number or it is not in the valid range), it raises ValueError.
     """
     """
-    pass
+    inted = int(port)
+    if inted < 0:
+        raise ValueError("Port value " + str(inted) +
+            " too small, allower range is 0-65535")
+    if inted > 65535:
+        raise ValueError("Port value " + str(inted) +
+            " too large, allowed range is 0-65535")
+    return inted
 
 
 def addr_check(addr):
 def addr_check(addr):
     """
     """