mirror of
https://github.com/akuker/RASCSI.git
synced 2024-08-19 22:29:05 +00:00
Improve the logic for checking the network bridge configuration (#894)
* Improve the logic for checking the network bridge configuration
This commit is contained in:
parent
efbfb54d26
commit
52259c374f
@ -610,11 +610,10 @@ def attach_device():
|
||||
error_msg = _("Please follow the instructions at %(url)s", url=error_url)
|
||||
|
||||
if "interface" in params.keys():
|
||||
# Note: is_bridge_configured returns False if the bridge is configured
|
||||
bridge_status = is_bridge_configured(params["interface"])
|
||||
if bridge_status:
|
||||
if not bridge_status["status"]:
|
||||
return response(error=True, message=[
|
||||
(bridge_status, "error"),
|
||||
(bridge_status["msg"], "error"),
|
||||
(error_msg, "error")
|
||||
])
|
||||
|
||||
|
@ -192,24 +192,30 @@ def auth_active(group):
|
||||
def is_bridge_configured(interface):
|
||||
"""
|
||||
Takes (str) interface of a network device being attached.
|
||||
Returns (bool) False if the network bridge is configured.
|
||||
Returns (str) with an error message if the network bridge is not configured.
|
||||
Returns a (dict) with (bool) status and (str) msg
|
||||
"""
|
||||
status = True
|
||||
return_msg = ""
|
||||
sys_cmd = SysCmds()
|
||||
if interface.startswith("wlan"):
|
||||
if not sys_cmd.introspect_file("/etc/sysctl.conf", r"^net\.ipv4\.ip_forward=1$"):
|
||||
return _("Configure IPv4 forwarding before using a wireless network device.")
|
||||
if not Path("/etc/iptables/rules.v4").is_file():
|
||||
return _("Configure NAT before using a wireless network device.")
|
||||
status = False
|
||||
return_msg = _("Configure IPv4 forwarding before using a wireless network device.")
|
||||
elif not Path("/etc/iptables/rules.v4").is_file():
|
||||
status = False
|
||||
return_msg = _("Configure NAT before using a wireless network device.")
|
||||
else:
|
||||
if not sys_cmd.introspect_file(
|
||||
"/etc/dhcpcd.conf",
|
||||
r"^denyinterfaces " + interface + r"$",
|
||||
):
|
||||
return _("Configure the network bridge before using a wired network device.")
|
||||
if not Path("/etc/network/interfaces.d/rascsi_bridge").is_file():
|
||||
return _("Configure the network bridge before using a wired network device.")
|
||||
return False
|
||||
status = False
|
||||
return_msg = _("Configure the network bridge before using a wired network device.")
|
||||
elif not Path("/etc/network/interfaces.d/rascsi_bridge").is_file():
|
||||
status = False
|
||||
return_msg = _("Configure the network bridge before using a wired network device.")
|
||||
|
||||
return {"status": status, "msg": return_msg + f" ({interface})"}
|
||||
|
||||
|
||||
def upload_with_dropzonejs(image_dir):
|
||||
|
Loading…
Reference in New Issue
Block a user