package documentation

Library for common VPN functions.

From __init__.py:

Function generate_random_network Generate a random network.
Function generate_random_port Generate a random port.
Function get_local_networks Return a list of local networks.
Function get_public_addresses Return a list of public addresses.
Function is_used_network Check if a network is already used by another OpenVPN.
Function is_used_port Check if a port is already used by another OpenVPN.
Function list_cipher Return a list of OpenVPN ciphers.
Function list_connected_clients List connected clients.
Function list_digest Return a list of OpenVPN digests.
Function opt2cidr Convert an OpenVPN option to CIDR notation.
Function random_network Generate a random private network address.
Function to_cidr Convert a netmask to CIDR notation.
Function to_netmask Convert a CIDR notation to netmask.
def generate_random_network(u): (source)

Generate a random network.

Arguments:
  • u -- EUci instance
Returns:
  • a random unused network
def generate_random_port(uci, limit_min, limit_max): (source)

Generate a random port.

Arguments:
  • uci -- EUci instance
  • limit_min -- minimum port number
  • limit_max -- maximum port number
Returns:
  • a random port number
def get_local_networks(u): (source)

Return a list of local networks.

Arguments:
  • u -- EUci instance
Returns:
  • a list of local networks
def get_public_addresses(u): (source)

Return a list of public addresses.

Arguments:
  • u -- EUci instance
Returns:
  • a list of public addresses
def is_used_network(u, network): (source)

Check if a network is already used by another OpenVPN.

Arguments:
  • u -- EUci instance
  • network -- network to check
Returns:
  • True if the network is already used, False otherwise
def is_used_port(uci, port): (source)

Check if a port is already used by another OpenVPN.

Arguments:
  • uci -- EUci instance
  • port -- port to check
Returns:
  • True if the port is already used, False otherwise
def list_cipher(): (source)

Return a list of OpenVPN ciphers.

Returns:
  • a list of OpenVPN ciphers, each element is a dicttionary with the following keys:
    • name: cipher name
    • description: cipher description (weak or strong)
def list_connected_clients(openvpninstance, type='subnet'): (source)

List connected clients.

Arguments:
  • openvpninstance -- OpenVPN instance name
  • type -- type of list (subnet or p2p)
Returns:
  • a list of connected clients
def list_digest(): (source)

Return a list of OpenVPN digests.

Returns:
  • a list of OpenVPN digests, each element is a dicttionary with the following keys: - name: digest name - description: digest description (weak or strong)
def opt2cidr(opt): (source)

Convert an OpenVPN option to CIDR notation.

Arguments:
  • opt -- OpenVPN option
Returns:
  • CIDR notation
def random_network(): (source)

Generate a random private network address.

Returns:
  • a random private network address
def to_cidr(netmask): (source)

Convert a netmask to CIDR notation.

Arguments:
  • netmask -- netmask in dotted decimal notation
Returns:
  • CIDR notation
def to_netmask(prefix): (source)

Convert a CIDR notation to netmask.

Arguments:
  • prefix -- CIDR notation
Returns:
  • netmask in dotted decimal notation