Giter VIP home page Giter VIP logo

openvpn-client's Introduction

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.

openvpn-client's People

Contributors

abresas avatar

Watchers

James Cloos avatar vulcanoIO - Open Source Sandbox and RE malwares avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.