API Reference

Models

class openvpn_status.models.Status[source]

The OpenVPN status model.

client_list

(OrderedDict)

The list of connected clients. The dictionary items have form of (client.real_address, client). See also Client.

routing_table
Type:OrderedDict

The list of routing table. The dictionary items have form of (routing.virtual_address, routing). See also Routing.

global_stats
Type:GlobalStats
updated_at
Type:datetime.datetime

The last updated time of log file in UTC.

class openvpn_status.models.Client[source]

The OpenVPN client model.

common_name
Type:str

The common name of OpenVPN client certificate. (e.g. foo@example.com)

real_address
Type:PeerAddress

The real IP address and port of client.

bytes_received
Type:FileSize
bytes_sent
Type:FileSize
connected_since
Type:datetime.datetime

The time in UTC since last connection established.

class openvpn_status.models.Routing[source]

The OpenVPN routing model.

virtual_address
Type:

Read more about TUN and TAP: Bridging vs. routing.

Read more about client-config-dir (CCD) and iroute: Lans behind OpenVPN.

common_name

Same as Client.common_name

real_address

Same as Client.real_address

last_ref
Type:datetime.datetime
class openvpn_status.models.GlobalStats[source]

The OpenVPN global stats model.

max_bcast_mcast_queue_len
Type:int

Parser

class openvpn_status.parser.LogParser(lines)[source]

The parser for parsing OpenVPN status log.

This kind of parser is stateful. So the LogParser.parse() could be called once in the same instance of parser.

classmethod fromstring(content)[source]

Creates a parser from content of log.

Parameters:content (str) – The log content.
Returns:The parser instance.
parse()[source]

Parses the status log.

Raises:ParsingError – if syntax error found in the log.
Returns:The models.Status with filled data.
exception openvpn_status.parser.ParsingError[source]

Shortcuts

openvpn_status.shortcuts.parse_status(status_log, encoding='utf-8')[source]

Parses the status log of OpenVPN.

Parameters:
  • status_log (str) – The content of status log.
  • encoding (str) – Optional. The encoding of status log.
Returns:

The instance of models.Status

Utilties

class openvpn_status.utils.PeerAddress[source]

The address of peer entity.

Parameters:
class openvpn_status.utils.FileSize[source]

The size of bytes.

humanize(**kwargs)[source]

Gets the human-friendly representation of file size.

Parameters:kwargs – All keyword arguments will be passed to humanize.filesize.naturalsize().