node-openvpn
Communicate with a openvpn instance via telnet
Last updated 2 years ago by luigiplr .
GPL-3.0 · Repository · Original npm · Tarball · package.json
$ cnpm install node-openvpn 
SYNC missed versions from official npm registry.

node-openvpn

NPM version Dependency Status npm

Communicate with an OpenVPN client instance via telnet using node.

Installation

$ npm install node-openvpn --save

Usage

const openvpnmanager = require('node-openvpn');

const opts = {
  host: '127.0.0.1', // normally '127.0.0.1', will default to if undefined
  port: 1337, //port openvpn management console
  timeout: 1500, //timeout for connection - optional, will default to 1500ms if undefined
  logpath: 'log.txt' //optional write openvpn console output to file, can be relative path or absolute
};
const auth = {
  user: 'vpnUserName',
  pass: 'vpnPassword',
};
const openvpn = openvpnmanager.connect(opts)

// will be emited on successful interfacing with openvpn instance
openvpn.on('connected', () => {
  openvpnmanager.authorize(auth);
});

// emits console output of openvpn instance as a string
openvpn.on('console-output', output => {
  console.log(output)
});

// emits console output of openvpn state as a array
openvpn.on('state-change', state => {
  console.log(state)
});

// emits console output of openvpn state as a string
openvpn.on('error', error => {
  console.log(error)
});

// get all console logs up to this point
openvpnmanager.getLog(console.log)

// and finally when/if you want to
openvpnmanager.disconnect();

// emits on disconnect
openvpn.on('disconnected', () => {
  // finally destroy the disconnected manager 
  openvpnmanager.destroy()
});

Current Tags

  • 0.1.1                                ...           latest (2 years ago)

11 Versions

  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.8                                ...           5 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.6                                ...           5 years ago
  • 0.0.5                                ...           5 years ago
  • 0.0.4                                ...           5 years ago
  • 0.0.3                                ...           5 years ago
  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 11
This Month 13
Last Day 0
Last Week 1
Last Month 1
Dependencies (4)
Dev Dependencies (1)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |