|
@@ -42,6 +42,7 @@ import random
|
|
|
import time
|
|
|
import signal
|
|
|
from isc.config import ccsession
|
|
|
+import isc.net.check
|
|
|
import isc.utils.process
|
|
|
from optparse import OptionParser, OptionValueError
|
|
|
from hashlib import sha1
|
|
@@ -564,22 +565,17 @@ def run(addr = 'localhost', port = 8080, idle_timeout = 1200, verbose = False):
|
|
|
httpd.serve_forever()
|
|
|
|
|
|
def check_port(option, opt_str, value, parser):
|
|
|
- if (value < 0) or (value > 65535):
|
|
|
- raise OptionValueError('%s requires a port number (0-65535)' % opt_str)
|
|
|
- parser.values.port = value
|
|
|
+ try:
|
|
|
+ parser.values.port = isc.net.check.port_check(value)
|
|
|
+ except ValueError as e:
|
|
|
+ raise OptionValueError(str(e))
|
|
|
|
|
|
def check_addr(option, opt_str, value, parser):
|
|
|
- ipstr = value
|
|
|
- ip_family = socket.AF_INET
|
|
|
- if (ipstr.find(':') != -1):
|
|
|
- ip_family = socket.AF_INET6
|
|
|
-
|
|
|
try:
|
|
|
- socket.inet_pton(ip_family, ipstr)
|
|
|
- except:
|
|
|
- raise OptionValueError("%s invalid ip address" % ipstr)
|
|
|
-
|
|
|
- parser.values.addr = value
|
|
|
+ isc.net.check.addr_check(value)
|
|
|
+ parser.values.addr = value
|
|
|
+ except ValueError as e:
|
|
|
+ raise OptionValueError(str(e))
|
|
|
|
|
|
def set_cmd_options(parser):
|
|
|
parser.add_option('-p', '--port', dest = 'port', type = 'int',
|