Skip to content

Commit

Permalink
Merge pull request #293 from Snuffy2/Fix-OpenVPN-Client-error-in-v0.3…
Browse files Browse the repository at this point in the history
….8-beta.1

Fix OpenVPN Client Error in v0.3.8-beta.1
  • Loading branch information
Snuffy2 authored Oct 25, 2024
2 parents ff6c62b + 7264d0f commit dc1fc33
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
11 changes: 6 additions & 5 deletions custom_components/opnsense/pyopnsense/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,11 +1460,12 @@ async def get_openvpn(self) -> Mapping[str, Any]:
or instance.get("role", "").lower() != "client"
):
continue
openvpn["clients"][client["uuid"]] = {
"name": instance.get("description", None),
"uuid": instance.get("uuid", None),
"enabled": bool(instance.get("enabled", "0") == "1"),
}
if instance.get("uuid", None):
openvpn["clients"][instance.get("uuid")] = {
"name": instance.get("description", None),
"uuid": instance.get("uuid", None),
"enabled": bool(instance.get("enabled", "0") == "1"),
}

# for connect in sessions_info.get("rows", []):
# if not isinstance(connect, Mapping) or not connect:
Expand Down
8 changes: 4 additions & 4 deletions custom_components/opnsense/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ async def _compile_vpn_switches(
coordinator: OPNsenseDataUpdateCoordinator,
state: Mapping[str, Any],
) -> list:
if not isinstance(state, Mapping):
return []
entities: list = []
for vpn_type in ["openvpn", "wireguard"]:
for clients_servers in ["clients", "servers"]:
if not isinstance(state, Mapping):
return []
for uuid, instance in (
state.get(vpn_type, {}).get(clients_servers, {}) or {}
).items():
state.get(vpn_type, {}).get(clients_servers, {}).items()
):
if (
not isinstance(instance, Mapping)
or instance.get("enabled", None) is None
Expand Down

0 comments on commit dc1fc33

Please sign in to comment.