This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

openvpn-client

0.0.2 • Public • Published

openvpn-client

npm version dependencies

Create an OpenVPN client instance, using "openvpn" command.

Installation

$ npm install openvpn-client

Documentation

OpenVPNClient class

OpenVPNClient represents an instance of openvpn running as client It passes the array of options passed to the constructor as arguments to the openvpn command. Apart from that, it supports writing to a temporary authentication file that is then passed as --auth-user-pass argument.

The class is not exposed publicly, but instantiated through other exported functions.

Event: 'data'

function (buffer)

When data are received from the server.

Event: 'connect'

function ()

When connection to server is initialized successfully.

Event: 'disconnect'

function (exitCode)

When connection to server is closed.

Constructor

Argument: vpnOpts The arguments passed to openvpn command.

.authenticate(user, pass)

Pass a username and password to use as authentication.

If this function is used, then the --auth-user-pass argument is added automatically.

parameters:

  • user username
  • pass password

.connect([cb])

Start OpenVPN process.

It returns a Promise that is fulfilled when "Inititialization Sequence Completed" message is received from the server.

Instead of promises you can use callbacks by passing a callback function.

parameters:

  • cb An optional callback function.

.disconnect()

    # Kill the OpenVPN process.
    disconnect: ->
            new Promise (resolve, reject) =>
                    @proc.kill()
                    @proc.on 'exit', ->
                            resolve()

module.defaultOpts

Default array of options. Any options passed to subsequent functions are merged with this array.

module.create([vpnOpts]) => OpenVPNClient

Create an openvpn client.

module.connect([auth], [vpnOpts]) => Disposer

Create an OpenVPNClient that connects immediately, and return a disposer that disconnects the client.

It will setup authentication based on the first parameter, and it will return a disposer that when cleaned up disconnects the process. Use this function when a connection is needed for a specific period of time.

Use it in combination with bluebird's resource management through Promise.using function.

Support

If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.

Contribute

Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning.

License

The project is licensed under the MIT license.

Readme

Keywords

none

Package Sidebar

Install

npm i openvpn-client

Weekly Downloads

32

Version

0.0.2

License

MIT

Last publish

Collaborators

  • balena.io