VPN
- async OPNsenseClient.get_openvpn()
Return OpenVPN server and client status information.
- Returns:
- Mapping with
serversandclients keyed by UUID. Server entries combine instance, provider, session, route, tunnel-address, DNS, status, byte-counter, and connected-client data when available. With the default
throw_errors=False, returnsNonewhen the sessions endpoint is unavailable or its rows are missing or malformed, or when the instance or provider inventory cannot be read reliably. A known missing (404) or forbidden (403) inventory endpoint allows partial results in this mode. Route-derivedclientsandconnected_clientsare omitted when routes cannot be fetched or have missing or malformed rows, rather than reporting zero clients.
- Mapping with
- Return type:
MutableMapping[str, Any] | None
- Raises:
OPNsenseError – Raised when
self._throw_errorsisTrueand a request or endpoint probe fails, including a forbidden (403) instance or provider configuration endpoint. A known missing (404) instance or provider endpoint still allows partial results. Structurally malformed required payloads returnNonerather than raising.
- async OPNsenseClient.get_wireguard()
Return WireGuard server and client status information.
- Returns:
- Mapping with
serversandclients keyed by UUID. Entries combine configured tunnel addresses, peer links, enabled state, interface names, handshake status, byte counters, and connected peer counts where available. With the default
throw_errors=False, returnsNonewhen the summary endpoint is unavailable or its rows are missing or malformed, or either configuration inventory cannot be read reliably. A known missing (404) or forbidden (403) configuration endpoint is treated as empty in this mode. A valid empty summary still reports configured peers as disconnected with zero counters. Whenself._throw_errorsisTrue, request or endpoint-probe failures can raiseOPNsenseError, including a forbidden (403) configuration endpoint. A known missing (404) endpoint is treated as empty for the clients and servers configuration inventories. Structurally malformed required payloads returnNoneregardless of error mode.
- Mapping with
- Return type:
MutableMapping[str, Any] | None
- async OPNsenseClient.toggle_vpn_instance(vpn_type, clients_servers, uuid)
Toggle the specified VPN instance on or off.
- Parameters:
- Returns:
True when the toggle operation completes successfully; otherwise, False.
- Return type:
- async OPNsenseClient.get_ipsec()
Return IPsec phase 1 (IKE) connection status information.
- Returns:
- Mapping with
connectionskeyed by the IKE connection UUID. Entries combine the connection description, IKE version, local and remote addresses and identities, the connected state, install age, routing state, and byte and packet counters reported by the OPNsense IPsec sessions API.
enabledcomes from the IPsec connections configuration: it isNonefor sessions without a configured connection (legacy tunnels, or an API user without access to the connections configuration) and the key is omitted when the configuration reports an unrecognized value. With the defaultthrow_errors=False, returnsNonewhen the connections configuration cannot be read this time, so a partial inventory cannot be mistaken for a complete one. A known missing (404) or forbidden (403) configuration endpoint allows session-only results withenabled=Nonein this mode. Configured connections without a session, including disabled ones, are reported as disconnected.childrenholds phase 2 status keyed by child UUID, withinstall_timeas the age of the oldest installed SA. A transient child-configuration or phase 2 read failure, or a decoded response without a validrowslist, omitschildren. Invalid JSON from the child-configuration endpoint instead makes this method returnNoneby default and raiseOPNsenseErrorwhenself._throw_errorsisTrue. ReturnsNonewhen the phase 1 sessions endpoint is unavailable or its rows are missing or malformed. A valid empty session list still reports configured connections and children as disconnected with zero counters. Whenself._throw_errorsisTrue, request or endpoint-probe failures can raiseOPNsenseError, including a forbidden (403) connections configuration endpoint. A known missing (404) connections configuration endpoint still allows session-only results. Structurally malformed phase 1 or connections configuration payloads returnNoneregardless of error mode.
- Mapping with
- Return type:
MutableMapping[str, Any] | None