base Package

auth Module

class leap.base.auth.LeapSRPRegister(schema='https', provider=None, verify=True, register_path='1/users', method='POST', fetcher=<module 'requests' from '/usr/lib/python2.7/dist-packages/requests/__init__.pyc'>, srp=<module 'srp' from '/usr/lib/python2.7/dist-packages/srp/__init__.pyc'>, hashfun=2, ng_constant=0)

Bases: object

get_registration_uri()
init_session()
register_user(username, password, keep=False)

@rtype: tuple @rparam: (ok, request)

leap.base.auth.SIGNUP_TIMEOUT = 5

Registration and authentication classes for the SRP auth mechanism used in the leap platform.

We’re using the srp library which uses a c-based implementation of the protocol if the c extension is available, and a python-based one if not.

class leap.base.auth.SRPAuth(username, password, server=None, verify=None)

Bases: requests.auth.AuthBase

authenticate()
get_auth_data()
get_init_data()
get_server_proof_data()
init_srp()
exception leap.base.auth.SRPAuthenticationError

Bases: exceptions.Exception

exception raised for authentication errors

leap.base.auth.get_leap_credentials()
leap.base.auth.magick_srpauth(fn)

decorator that gets user and password from the config file and adds those to the decorated request

leap.base.auth.safe_unhexlify(x)
leap.base.auth.srpauth_protected(user=None, passwd=None, server=None, verify=True)

decorator factory that accepts user and password keyword arguments and add those to the decorated request

authentication Module

Authentication Base Class

class leap.base.authentication.Authentication

Bases: object

I have no idea how Authentication (certs,?) will be done, but stub it here.

checks Module

class leap.base.checks.LeapNetworkChecker(*args, **kwargs)

Bases: object

all network related checks

check_internet_connection()
check_name_resolution(domain_name)
check_tunnel_default_interface()

Raises an TunnelNotDefaultRouteError if tun0 is not the chosen default route (including when no routes are present)

get_default_interface_gateway()

gets the interface we are going thru. (this should be merged with check tunnel default interface, imo...)

is_internet_up()
parse_log_and_react(log, error_matrix=None)

compares the recent openvpn status log to strings passed in and executes the callbacks passed in. @param log: openvpn log @type log: list of strings @param error_matrix: tuples of strings and tuples of callbacks @type error_matrix: tuples strings and call backs

ping_gateway(gateway)
run_all(checker=None)

config Module

Configuration Base Class

class leap.base.config.BaseLeapConfig

Bases: object

config
get_config(*kwargs)
get_value(*kwargs)
load()
save()
slug = None
class leap.base.config.JSONLeapConfig(*args, **kwargs)

Bases: leap.base.config.BaseLeapConfig

exists()
fetch(uri, fetcher=None, verify=True, force_dl=False)
filename
get_config()
get_filename()
get_mtime()
load(fromfile=None, from_uri=None, fetcher=None, force_download=False, verify=True)
save(to=None, force=False)

force param will skip the dirty check. :type force: bool

spec

alias of JSONLeapConfigSpec

validate(data)
class leap.base.config.MetaConfigWithSpec

Bases: type

metaclass for JSONLeapConfig classes. It creates a configuration spec out of the spec dictionary. The properties attribute of the spec dict is turn into the schema attribute of the new class (which will be used to validate against).

leap.base.config.get_config_dir()

get the base dir for all leap config @rparam: config path @rtype: string

leap.base.config.get_config_file(filename, folder=None)

concatenates the given filename with leap config dir. @param filename: name of the file @type filename: string @rparam: full path to config file

leap.base.config.get_default_provider_path()
leap.base.config.get_groupname()
leap.base.config.get_provider_path(domain)
leap.base.config.get_username()
leap.base.config.validate_ip(ip_str)

raises exception if the ip_str is not a valid representation of an ip

connection Module

Base Connection Classs

class leap.base.connection.Connection(*args, **kwargs)

Bases: leap.base.authentication.Authentication

connect()

entry point for connection process

connection_state()

returns the current connection state

desired_connection_state()

returns the desired_connection state

disconnect()

disconnects client

get_icon_name()

get icon name from status object

exception leap.base.connection.ConnectionError

Bases: exceptions.Exception

generic connection error

exception leap.base.connection.UnrecoverableError

Bases: leap.base.connection.ConnectionError

we cannot do anything about it, sorry

constants Module

constants to be used in base module

exceptions Module

Exception attributes and their meaning/uses

  • critical: if True, will abort execution prematurely,

    after attempting any cleaning action.

  • failfirst: breaks any error_check loop that is examining

    the error queue.

  • message: the message that will be used in the __repr__ of the exception.

  • usermessage: the message that will be passed to user in ErrorDialogs

    in Qt-land.

exception leap.base.exceptions.CannotResolveDomainError

Bases: leap.base.exceptions.LeapException

message = 'Cannot resolve domain'
usermessage = u'Domain cannot be found'
exception leap.base.exceptions.CriticalError

Bases: leap.base.exceptions.LeapException

we cannot do anything about it

critical = True
failfirst = True
exception leap.base.exceptions.ImproperlyConfigured

Bases: exceptions.Exception

exception leap.base.exceptions.InterfaceNotFoundError

Bases: leap.base.exceptions.LeapException

message = 'interface not found'
usermessage = u'Interface not found'
exception leap.base.exceptions.LeapException

Bases: exceptions.Exception

base LeapClient exception sets some parameters that we will check during error checking routines

critical = False
failfirst = False
warning = False
exception leap.base.exceptions.MissingConfigFileError

Bases: exceptions.Exception

exception leap.base.exceptions.NoConnectionToGateway

Bases: leap.base.exceptions.LeapException

message = 'no connection to gateway'
usermessage = u'Looks like there are problems with your internet connection'
exception leap.base.exceptions.NoDefaultInterfaceFoundError

Bases: leap.base.exceptions.LeapException

message = 'no default interface found'
usermessage = u'Looks like your computer is not connected to the internet'
exception leap.base.exceptions.NoInternetConnection

Bases: leap.base.exceptions.LeapException

message = 'No Internet connection found'
usermessage = u'It looks like there is no internet connection.'
exception leap.base.exceptions.TunnelNotDefaultRouteError

Bases: leap.base.exceptions.LeapException

message = 'Tunnel connection dissapeared. VPN down?'
usermessage = u'The Encrypted Connection was lost.'

network Module

class leap.base.network.NetworkCheckerThread(*args, **kwargs)

Bases: object

Manages network checking thread that makes sure we have a working network connection.

run_checks()
start()
stop()

pluggableconfig Module

generic configuration handlers

class leap.base.pluggableconfig.PluggableConfig(adaptors={'json': <leap.base.pluggableconfig.JSONAdaptor object at 0xb3d142c>}, types={'date': <leap.base.pluggableconfig.DateType object at 0xb3d15cc>, 'https-uri': <leap.base.pluggableconfig.HTTPSURIType object at 0xb3d160c>, 'uri': <leap.base.pluggableconfig.URIType object at 0xb3d15ec>, 'translatable': <leap.base.pluggableconfig.TranslatableType object at 0xb3d162c>}, format=None)

Bases: object

deserialize(string=None, fromfile=None, format=None)

load configuration from a file or string

filename2format(filename)
get_adaptor(format)

get specified format adaptor or guess for a given filename

get_default_values()

return a config options from configuration defaults

is_dirty()
items()

act like an iterator

load(*args, **kwargs)

load from string or file if no string of fromfile option is given, it will attempt to load from defaults defined in the schema.

option_dict
options = {}
prep_value(config)

the inverse of to_python method, called just before serialization

serialize(filename, format=None, full=False)
set_dirty()
to_python(config)

cast types following first type and then format indications.

touch_mtime(filename)
validate(config, format=None)

validate config

exception leap.base.pluggableconfig.UnknownOptionException

Bases: exceptions.Exception

exception raised when a non-configuration value is present in the configuration

exception leap.base.pluggableconfig.MissingValueException

Bases: exceptions.Exception

exception raised when a required value is missing

exception leap.base.pluggableconfig.ConfigurationProviderException

Bases: exceptions.Exception

exception raised when a configuration provider is missing, etc

exception leap.base.pluggableconfig.TypeCastException

Bases: exceptions.Exception

exception raised when a configuration item cannot be coerced to a type

providers Module

all dealing with leap-providers: definition files, updating

class leap.base.providers.LeapProviderDefinition(*args, **kwargs)

Bases: leap.base.config.JSONLeapConfig

slug
spec

alias of LeapProviderDefinitionSpec

class leap.base.providers.LeapProviderSet

Bases: object

specs Module