mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 12:57:56 +00:00
Add REUSE flag to socket when scanning for unused ports.
This commit is contained in:
parent
89e80fd74b
commit
4d23c5917c
@ -58,9 +58,11 @@ def find_unused_port(start_port, end_port, host='127.0.0.1', socket_type="TCP",
|
||||
if ":" in host:
|
||||
# IPv6 address support
|
||||
with socket.socket(socket.AF_INET6, socket_type) as s:
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind((host, port)) # the port is available if bind is a success
|
||||
else:
|
||||
with socket.socket(socket.AF_INET, socket_type) as s:
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
s.bind((host, port)) # the port is available if bind is a success
|
||||
return port
|
||||
except OSError as e:
|
||||
|
@ -630,8 +630,7 @@ class Qemu(IModule):
|
||||
paths.append(os.path.join(os.environ["PROGRAMFILES"], "qemu"))
|
||||
elif sys.platform.startswith("darwin"):
|
||||
# add specific locations on Mac OS X regardless of what's in $PATH
|
||||
paths.append("/usr/local/bin")
|
||||
paths.append("/opt/local/bin")
|
||||
paths.extend(["/usr/local/bin", "/opt/local/bin"])
|
||||
for path in paths:
|
||||
try:
|
||||
for f in os.listdir(path):
|
||||
@ -639,7 +638,8 @@ class Qemu(IModule):
|
||||
qemu_path = os.path.join(path, f)
|
||||
version = self._get_qemu_version(qemu_path)
|
||||
qemus.append({"path": qemu_path, "version": version})
|
||||
except OSError:
|
||||
except (OSError, QemuError) as e:
|
||||
log.warn("Could not find QEMU version for {}: {}".format(path, e))
|
||||
continue
|
||||
|
||||
response = {"server": self._host,
|
||||
|
Loading…
Reference in New Issue
Block a user