diff --git a/gns3server/modules/dynamips/__init__.py b/gns3server/modules/dynamips/__init__.py index 0b4bd4d7..74192881 100644 --- a/gns3server/modules/dynamips/__init__.py +++ b/gns3server/modules/dynamips/__init__.py @@ -25,6 +25,7 @@ import base64 import tempfile import shutil import glob +import socket from gns3server.modules import IModule import gns3server.jsonrpc as jsonrpc @@ -363,6 +364,12 @@ class Dynamips(IModule): lport = request["nio"]["lport"] rhost = request["nio"]["rhost"] rport = request["nio"]["rport"] + try: + #TODO: handle IPv6 + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: + sock.connect((rhost, rport)) + except OSError as e: + raise DynamipsError("Could not create an UDP connection to {}:{}: {}".format(rhost, rport, e)) # check if we have an allocated NIO UDP auto nio = node.hypervisor.get_nio_udp_auto(lport) if not nio: diff --git a/gns3server/modules/iou/__init__.py b/gns3server/modules/iou/__init__.py index 3d6da02c..4834c145 100644 --- a/gns3server/modules/iou/__init__.py +++ b/gns3server/modules/iou/__init__.py @@ -658,6 +658,12 @@ class IOU(IModule): lport = request["nio"]["lport"] rhost = request["nio"]["rhost"] rport = request["nio"]["rport"] + try: + #TODO: handle IPv6 + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: + sock.connect((rhost, rport)) + except OSError as e: + raise IOUError("Could not create an UDP connection to {}:{}: {}".format(rhost, rport, e)) nio = NIO_UDP(lport, rhost, rport) elif request["nio"]["type"] == "nio_tap": tap_device = request["nio"]["tap_device"] diff --git a/gns3server/modules/vpcs/__init__.py b/gns3server/modules/vpcs/__init__.py index dd8d2827..423b614b 100644 --- a/gns3server/modules/vpcs/__init__.py +++ b/gns3server/modules/vpcs/__init__.py @@ -625,6 +625,12 @@ class VPCS(IModule): lport = request["nio"]["lport"] rhost = request["nio"]["rhost"] rport = request["nio"]["rport"] + try: + #TODO: handle IPv6 + with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock: + sock.connect((rhost, rport)) + except OSError as e: + raise VPCSError("Could not create an UDP connection to {}:{}: {}".format(rhost, rport, e)) nio = NIO_UDP(lport, rhost, rport) elif request["nio"]["type"] == "nio_tap": tap_device = request["nio"]["tap_device"]