itkach / ovpn-py

Automatically exported from code.google.com/p/ovpn-py
0 stars 0 forks source link

OpenVPN embedded Python plugin.

This plugin implements V1 OpenVPN plugin interface, thus in other words getting many info from OpenVPN and returning only TRUE/FALSE values.

It is loaded as other plugins. Plugin parameters are:

  1. module name which will be imported the same way as if it was "import ..." from Python. Mandatory. By default it prepends plugin (.so) path to sys.path.
  2. Path which will be prepended to Python "sys.path" and where also module noted in 1-st parameter will be searched for. Optional. In this case plugin (.so) path is not in sys.path, but this parameter path.

Module. Module should contain anything, but at least two callback functions must be declared:

  1. plugin_up() which is called on initialization of plugin.
  2. plugin_down() which is called on OpenVPN shutdown.

Next callbacks which are optional: route_up() ipchange() tls_verify() auth_user_pass_verify() client_connect() client_disconnect() learn_address() tls_final() enable_pf()

During initialization of plugin those optional callbacks are searched for presence and if they are Python callable. If so, OpenVPN type mask is set for particular callbacks, so only those, which are declared, are advertised to OpenVPN. Every callback has at least one parameter, environment which is Python dictionary. It is not system env., but OpenVPN environment. Callbacks are expected to return only True/False values. Look at sample module in sources.

Import and use what you wish, but threading is not anyhow handled. In fact may be it is not a problem for this plugin cause of its behavior, but keep it on mind.