mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
UDP connection checks.
This commit is contained in:
parent
0f8d1bc6da
commit
f4ab8e2dd0
@ -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:
|
||||
|
@ -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"]
|
||||
|
@ -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"]
|
||||
|
Loading…
Reference in New Issue
Block a user