Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openvpn-client

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openvpn-client

Create OpenVPN client instances.

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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.

FAQs

Package last updated on 09 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc