VPN

async OPNsenseClient.get_openvpn()

Return OpenVPN server and client status information.

Returns:

Mapping with servers and clients

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, returns None when 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-derived clients and connected_clients are omitted when routes cannot be fetched or have missing or malformed rows, rather than reporting zero clients.

Return type:

MutableMapping[str, Any] | None

Raises:

OPNsenseError – Raised when self._throw_errors is True and 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 return None rather than raising.

async OPNsenseClient.get_wireguard()

Return WireGuard server and client status information.

Returns:

Mapping with servers and clients

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, returns None when 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. When self._throw_errors is True, request or endpoint-probe failures can raise OPNsenseError, 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 return None regardless of error mode.

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:
  • vpn_type (str) – Vpn type used by this operation.

  • clients_servers (str) – WireGuard collection to toggle. Use clients for a client entry or servers for a server entry. IPsec only supports connections. Ignored for OpenVPN.

  • uuid (str) – UUID of the VPN instance to toggle.

Returns:

True when the toggle operation completes successfully; otherwise, False.

Return type:

bool

async OPNsenseClient.get_ipsec()

Return IPsec phase 1 (IKE) connection status information.

Returns:

Mapping with connections keyed 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. enabled comes from the IPsec connections configuration: it is None for 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 default throw_errors=False, returns None when 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 with enabled=None in this mode. Configured connections without a session, including disabled ones, are reported as disconnected. children holds phase 2 status keyed by child UUID, with install_time as the age of the oldest installed SA. A transient child-configuration or phase 2 read failure, or a decoded response without a valid rows list, omits children. Invalid JSON from the child-configuration endpoint instead makes this method return None by default and raise OPNsenseError when self._throw_errors is True. Returns None when 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. When self._throw_errors is True, request or endpoint-probe failures can raise OPNsenseError, 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 return None regardless of error mode.

Return type:

MutableMapping[str, Any] | None