Commit b526f9ae authored by Stratos Psomadakis's avatar Stratos Psomadakis Committed by root

Catch IPy exceptions for invalid networks/subnets

Signed-off-by: default avatarStratos Psomadakis <psomas@grnet.gr>
parent d9361b6e
...@@ -195,9 +195,13 @@ def parse_binding_file(path): ...@@ -195,9 +195,13 @@ def parse_binding_file(path):
elif line.startswith("EUI64="): elif line.startswith("EUI64="):
eui64 = get_value(line) eui64 = get_value(line)
return Client(tap=tap, mac=mac, ip=ip, try:
client = Client(tap=tap, mac=mac, ip=ip,
hostname=hostname, indev=indev, subnet=subnet, hostname=hostname, indev=indev, subnet=subnet,
gateway=gateway, subnet6=subnet6, gateway6=gateway6, eui64=eui64 ) gateway=gateway, subnet6=subnet6, gateway6=gateway6, eui64=eui64 )
return client
except:
return None
class ClientFileHandler(pyinotify.ProcessEvent): class ClientFileHandler(pyinotify.ProcessEvent):
def __init__(self, server): def __init__(self, server):
...@@ -245,7 +249,10 @@ class Client(object): ...@@ -245,7 +249,10 @@ class Client(object):
class Subnet(object): class Subnet(object):
def __init__(self, net=None, gw=None, dev=None): def __init__(self, net=None, gw=None, dev=None):
if isinstance(net, str): if isinstance(net, str):
self.net = IPy.IP(net) try:
self.net = IPy.IP(net)
except:
raise Exception
else: else:
self.net = net self.net = net
self.gw = gw self.gw = gw
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment