mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Restrict the list of available Ethernet/TAP adapters. Fixes #352.
This commit is contained in:
1 parent
fb3bcf3b8f
commit
08493871a5
3 files changed
+12
-1
No files matched your search
@@ -23,6 +23,8 @@ import socket
|
||||
import struct
|
||||
import psutil
|
||||
|
||||
from gns3server.config import Config
|
||||
|
||||
if psutil.version_info < (3, 0, 0):
|
||||
raise Exception("psutil version should >= 3.0.0. If you are under Ubuntu/Debian install gns3 via apt instead of pip")
|
||||
|
||||
@@ -198,8 +200,14 @@ def interfaces():
|
||||
|
||||
results = []
|
||||
if not sys.platform.startswith("win"):
|
||||
allowed_interfaces = Config.instance().get_section_config("Server").get("allowed_interfaces", None)
|
||||
if allowed_interfaces:
|
||||
allowed_interfaces = allowed_interfaces.split(',')
|
||||
net_if_addrs = psutil.net_if_addrs()
|
||||
for interface in sorted(net_if_addrs.keys()):
|
||||
if allowed_interfaces and interface not in allowed_interfaces:
|
||||
log.warning("Interface '{}' is not allowed to be used on this server".format(interface))
|
||||
continue
|
||||
ip_address = ""
|
||||
mac_address = ""
|
||||
netmask = ""
|
||||
|
||||
Reference in new issue
Block a user