npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

telnet-openvpn

v0.1.9

Published

Connect to OpenVPN management port through telnet.

Downloads

1,660

Readme

telnet-openvpn

Connect to OpenVPN management port through telnet.

Installation

$ npm install telnet-openvpn --save

Usage

ECMAScript 5

var TelnetVPN = require('telnet-openvpn');
  
var vpn = new TelnetVPN();
  
var options = {
    host: '127.0.0.1',
    port: 1337,
    ors: '\r\n',
    sendTimeout: 2000
};
  
var auth = {
    username: 'username',
    password: 'password'
};
  
  
vpn.connect(options);
  
vpn.on('connect', function() {
    vpn.exec('log on all').then(function() {
        return vpn.exec('state on').then(function() {
            return vpn.exec('hold release').then(function() {
                return vpn.authorize(auth);
            });
        });
    }).catch(function(error) {
        console.error(error);
    });
});
  
vpn.on('log', function(result) {
    console.log(result);
});
  
vpn.on('error', function(result) {
    console.log(result);
    vpn.disconnect();
});
  
vpn.on('end', function(result) {
    console.log(result);
    vpn.destroy();
});
  
vpn.on('data', function(result) {
    console.log(result);
});

ECMAScript 6

import TelnetVPN from 'telnet-openvpn';
  
let vpn = new TelnetVPN();
  
let options = {
    host: '127.0.0.1',
    port: 1337,
    ors: '\r\n',
    sendTimeout: 2000
};
  
let auth = {
    username: 'username',
    password: 'password'
};
  
  
vpn.connect(options);
  
vpn.on('connect', () => {
    vpn.exec('log on all').then(() => {
        return vpn.exec('state on').then(() => {
            return vpn.exec('hold release').then(() => {
                return vpn.authorize(auth);
            });
        });
    }).catch((error) => {
        console.error(error);
    });
});
  
vpn.on('log', (result) => {
    console.log(result);
});
  
vpn.on('error', (error) => {
    console.log(error);
    vpn.disconnect();
});
  
vpn.on('end', (result) => {
    console.log(result);
    vpn.destroy();
});
  
vpn.on('data', (result) => {
    console.log(result);
});

API

vpn.connect(options) -> Promise

Connects to the management port specified in the .ovpn file.
More options can be found in the telnet-client docs.

options:

  • host: Management IP address specified under "management" in .ovpn file (default: '127.0.0.1').
  • port: Management port specified under "management" in .ovpn file (default: 1337).
  • negotiationMandatory: Enable to disable telnet negotiations (default: true).
  • ors: Output record separator. Used to execute commands from telnet console (default: '\r\n').
  • sendTimeout: Waits for input return character (default: 3000).

vpn.authorize(options) -> Promise

After user connects, vpn.authorize(auth) must be called if .ovpn file specifies auth-user-pass.

options:

  • username: Client username for VPN service.
  • password: Client password for VPN service

vpn.exec(event) -> Promise

Specify telnet console commands through this function.

vpn.on(event, [callback])

EventEmitter options emitted as information is received from telnet console.

events:

  • connect: Telnet console has successfully connected to management port.
  • log: Telnet console log outputs.
  • error: Telnet console error outputs.
  • end: Telnet console has ended session to management port.
  • data: Telnet console output data important to user (JSON Formatted).
    • state: (array) Current state of telnet console.
    • hold: Telnet console waiting for user commands.
    • success: Telnet data successfully obtained.
    • bytecount: Telnet byte count.
    • bytecount_cli: Per-client byte counts.
    • password: Password information sent through telnet console.
    • pid: Process id of session.

vpn.disconnect() -> Promise

Ends telnet session and triggers the 'end' event emitter.

vpn.destroy() -> Promise

Removes all instances of telnet console socket connection. Used for 'error' event emitter.

vpn.end() -> Promise

Closes telnet session but does not kill all telnet instances like vpn.destroy(). It is possible the server may send some data.

Important .ovpn file information:

# OpenVPN management IP and port (localhost 1337).
management 127.0.0.1 1337
# OpenVPN wait for hold release from telnet console (vpn.exec('hold release')).
management-hold
# OpenVPN wait for authentication from telnet console (vpn.authorize(auth)).
management-query-passwords
# OpenVPN authenticate using username and password from telnet console.
auth-user-pass

Start OpenVPN through command line (requires OpenVPN) :

$ openvpn myconfig.ovpn

For more OpenVPN management commands please follow OpenVPN's documentation

Credits

telnet-client
node-openvpn