OpenVPNServer¶
-
class
openvpn_server.OpenVPNServer(config, openvpn_binary='openvpn', runtime_base_dir=None, privesc_binary='sudo', startup_timeout=2)[source]¶ Class wrapping OpenVPN instance
- Parameters
config (
OpenVPNConfig) –openvpn_binary (
str) –runtime_base_dir (
Optional[Path]) –privesc_binary (
Optional[str]) –startup_timeout (
int) –
-
__init__(config, openvpn_binary='openvpn', runtime_base_dir=None, privesc_binary='sudo', startup_timeout=2)[source]¶ Spawn new OpenVPN instance, wait for it and allow for easy exiting
- Parameters
config (
OpenVPNConfig) – Object with OpenVPN configuration to be used.openvpn_binary (
str) – Callable name (or path) of OpenVPN binary to be used.runtime_base_dir (
Optional[Path]) – Optional Path object of dir to store various files related to our instance. Will be created if needed.privesc_binary (
Optional[str]) – Callable name (or path) of binary allowing to execute openvpn_binary with elevated priviledges to be used.startup_timeout (
int) – Wait up to startup_timeout seconds for OpenVPN instance to be ready after spawning it. Too small value can lead to orphaned OpenVPN instances.
- Raises
OVPNStartupTimeoutException: OVPN was not ready in expected time.
-
property
is_running¶ Check if OpenVPN is currently running
- Return type
bool
-
property
state¶ Get OpenVPN instance state
“NOT_RUNNING” means that the instance is not currently running. Other values have meaning as defined in https://openvpn.net/community-resources/management-interface/ under ‘COMMAND – state’
- Return type
str