Update public source
This commit is contained in:
+63
@@ -613,6 +613,69 @@ def get_nm_wifi_devices():
|
||||
|
||||
return devices, None
|
||||
|
||||
def get_active_vpn_connections():
|
||||
|
||||
command = [
|
||||
"nmcli",
|
||||
"--terse",
|
||||
"--escape",
|
||||
"yes",
|
||||
"--fields",
|
||||
"TYPE,DEVICE",
|
||||
"connection",
|
||||
"show",
|
||||
"--active"
|
||||
]
|
||||
|
||||
try:
|
||||
|
||||
result = subprocess.run(
|
||||
command,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=10,
|
||||
env={
|
||||
**os.environ,
|
||||
"LC_ALL": "C"
|
||||
}
|
||||
)
|
||||
|
||||
except Exception as error:
|
||||
|
||||
return [], f"NetworkManager VPN query failed: {error}"
|
||||
|
||||
if result.returncode != 0:
|
||||
|
||||
error = (
|
||||
result.stderr.strip()
|
||||
or
|
||||
f"nmcli exited with code {result.returncode}"
|
||||
)
|
||||
|
||||
return [], error
|
||||
|
||||
vpn_connections = []
|
||||
|
||||
for line in result.stdout.splitlines():
|
||||
|
||||
parts = line.split(":", 1)
|
||||
|
||||
if len(parts) != 2:
|
||||
continue
|
||||
|
||||
connection_type, device = parts
|
||||
|
||||
if connection_type in ("vpn", "wireguard"):
|
||||
|
||||
vpn_connections.append(
|
||||
{
|
||||
"type": connection_type,
|
||||
"device": device
|
||||
}
|
||||
)
|
||||
|
||||
return vpn_connections, None
|
||||
|
||||
def get_wifi_interfaces():
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user