sirup.VPNConnector
Connect to a server with OpenVPN
Classes
Class to connect and disconnect to a single VPN server. |
Module Contents
- class sirup.VPNConnector.VPNConnector(config_file, auth_file, track_ip=True)[source]
Class to connect and disconnect to a single VPN server.
- Parameters:
config_file (str) – Full path and file name of the OpenVPN configuration file to connect to a server.
auth_file (str) – Full path and file name of the file with the authentication credentials for VPN connections.
track_ip (bool, optional) – If True, the IP address is queried after each connect and disconnect. For long-running programs, it is better to set track_ip=False in order to respect the query limits of the IP address API.
- config_file
Full path and file name of the OpenVPN configuration file to connect to a server.
- Type:
- auth_file
Full path and file name of the file with the authentication credentials for VPN connections.
- Type:
- current_ip
If track_ip is True, the IP address of the machine that is currently visible.
- Type:
None or str
- track_ip
If True, queries the IP address of the machine after each connect and disconnect.
- Type:
- is_connected()[source]
Indicates whether a VPN connection is active.
- Returns:
True if a VPN connection is running.
- Return type:
- start_vpn(pwd, proc_id=None)[source]
Start an OpenVPN connection.
Starts an OpenVPN process. The log is written to a temporary file. The process is opened as a daemon: This means that the process runs in the background and releases the terminal after start-up.
- Parameters:
- Raises:
Exceptions when opening the connection fails. – The exceptions are specified in sirup.raise_ovpn_exceptions.