Create an OpenVPN client instance, using "openvpn" command.
$ npm install openvpn-client
- Class: OpenVPNClient
- vpnclient.defaultOpts
- vpnclient.create([vpnOpts])
- vpnclient.connect([auth], [vpnOpts])
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.
function (buffer)
When data are received from the server.
function ()
When connection to server is initialized successfully.
function (exitCode)
When connection to server is closed.
Argument: vpnOpts The arguments passed to openvpn command.
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
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.
# Kill the OpenVPN process.
disconnect: ->
new Promise (resolve, reject) =>
@proc.kill()
@proc.on 'exit', ->
resolve()
Default array of options. Any options passed to subsequent functions are merged with this array.
Create an openvpn client.
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.
If you're having any problem, please raise an issue on GitHub and the Resin.io team will be happy to help.
- Issue Tracker: github.com/resin-io/openvpn-client/issues
- Source Code: github.com/resin-io/openvpn-client
Before submitting a PR, please make sure that you include tests, and that coffeelint runs without any warning.
The project is licensed under the MIT license.