openvpn-bin
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -5,2 +5,3 @@ var Promise = require('bluebird'); | ||
var path = require('path'); | ||
var runas = require('runas'); | ||
var getPort = Promise.promisify(require('get-port')); | ||
@@ -10,6 +11,3 @@ var fs = Promise.promisifyAll(require('fs')); | ||
var sudo = Promise.promisifyAll(require('sudo-prompt')); | ||
var wincmd = require('node-windows'); | ||
fs.existsAsync = function(path) { | ||
@@ -33,18 +31,4 @@ return fs.openAsync(path, "r").then(function(stats) { | ||
new Promise(function(resolve, reject) { | ||
wincmd.list(function(svc) { | ||
resolve(svc); | ||
}); | ||
}) | ||
.then(function(svc) { | ||
return _.pluck(_.filter(svc, { | ||
ImageName: 'openvpn.exe' | ||
}), 'PID'); | ||
}) | ||
.then(function(pids) { | ||
return pids.forEach(function(pid) { | ||
wincmd.kill(pid, function() { | ||
console.log('Killed:', pid); | ||
}); | ||
}); | ||
}).then(resolve).catch(reject) | ||
}); | ||
@@ -75,15 +59,7 @@ } | ||
.then(function(setargs) { | ||
console.log(openvpnpath, setargs) | ||
return new Promise(function(resolve, reject) { | ||
switch (process.platform) { | ||
case 'win32': | ||
wincmd.elevate(openvpnpath + ' ' + setargs); | ||
resolve(); | ||
break; | ||
case 'darwin': | ||
sudo.exec(openvpnpath + ' ' + setargs).then(resolve); | ||
break; | ||
case 'linux': | ||
break; | ||
} | ||
console.log(openvpnpath, setargs); | ||
return runas(openvpnpath, setargs, { | ||
admin: true, | ||
hide: false, | ||
catchOutput: true | ||
}); | ||
@@ -110,9 +86,9 @@ }) | ||
case 'win32': | ||
return util.format(new Array('--management %s %s', '--config %s', '--script-security %d', '--management-query-passwords', '--management-hold').join(' '), args.host, args.port, args.config, args.scriptSecurity); | ||
return util.format(new Array('--management %s %d', '--config %s', '--script-security %d', '--management-query-passwords', '--management-hold').join(' '), args.host, args.port, args.config, args.scriptSecurity); | ||
break; | ||
case 'darwin': | ||
return util.format(new Array('--management %s %s', '--config %s', '--script-security %d', '--log %s', '--cd %s', '--up %s', '--down %s', '--daemon', '--management-query-passwords', '--management-hold').join(' '), args.host, args.port, args.config, args.scriptSecurity, args.logpath, args.cwd, args.up, args.down); | ||
return util.format(new Array('--management %s %d', '--config %s', '--script-security %d', '--log %s', '--cd %s', '--up %s', '--down %s', '--daemon', '--management-query-passwords', '--management-hold').join(' '), args.host, args.port, args.config, args.scriptSecurity, args.logpath, args.cwd, args.up, args.down); | ||
break; | ||
case 'linux': | ||
return util.format(new Array('--management %s %d', '--config %s', '--script-security %d', '--daemon', '--management-query-passwords', '--management-hold', '--dev', 'tun0').join(' '), args.host, args.port, args.config, args.scriptSecurity); | ||
return util.format(new Array('--management %s %d', '--config %s', '--script-security %d', '--up %s', '--down %s', '--daemon', '--management-query-passwords', '--management-hold', '--dev', 'tun0').join(' '), args.host, args.port, args.config, args.scriptSecurity, args.up, args.down); | ||
break; | ||
@@ -119,0 +95,0 @@ } |
{ | ||
"name": "openvpn-bin", | ||
"version": "0.0.3", | ||
"description": "Initialize a openvpn instance for mac, windows & linux", | ||
"author": { | ||
"name": "Luigi Poole", | ||
"email": "luigipoole@outlook.com" | ||
}, | ||
"keywords": [ | ||
"node openvpn", | ||
"node vpn", | ||
"openvpn client", | ||
"openvpn", | ||
"client", | ||
"vpn" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/luigiplr/openvpn-bin.git" | ||
}, | ||
"main": "index.js", | ||
"license": "GPL-3.0", | ||
"dependencies": { | ||
"bluebird": "^2.9.34", | ||
"get-port": "^1.0.0", | ||
"lodash": "^3.10.1", | ||
"node-windows": "^0.1.10", | ||
"sudo-prompt": "^1.1.7" | ||
} | ||
} | ||
"name": "openvpn-bin", | ||
"version": "0.0.4", | ||
"description": "Initialize a openvpn instance for mac, windows & linux", | ||
"author": { | ||
"name": "Luigi Poole", | ||
"email": "luigipoole@outlook.com" | ||
}, | ||
"keywords": [ | ||
"node openvpn", | ||
"node vpn", | ||
"openvpn client", | ||
"openvpn", | ||
"client", | ||
"vpn" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/luigiplr/openvpn-bin.git" | ||
}, | ||
"main": "index.js", | ||
"license": "GPL-3.0", | ||
"dependencies": { | ||
"bluebird": "^2.9.34", | ||
"get-port": "^1.0.0", | ||
"lodash": "^3.10.1", | ||
"runas": "^3.1.0" | ||
} | ||
} |
# openvpn-bin | ||
Initialize a openvpn instance for mac, windows & linux | ||
Recommended https://github.com/luigiplr/node-openvpn is used as management console (designed to be chainable) | ||
``` | ||
@@ -9,3 +11,3 @@ var openvpnbin = require('openvpn-bin'); | ||
host: '127.0.0.1', | ||
port: 1337, //port should *always* be set at this point but we will defualt it anyway to 1337 just incase. | ||
port: 1337, | ||
scriptSecurity: 2, | ||
@@ -12,0 +14,0 @@ config: 'config.ovpn', |
4
27
5217
83
+ Addedrunas@^3.1.0
+ Addednan@2.22.0(transitive)
+ Addedrunas@3.1.1(transitive)
- Removednode-windows@^0.1.10
- Removedsudo-prompt@^1.1.7
- Removedminimist@0.0.10(transitive)
- Removednode-windows@0.1.14(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedsudo-prompt@1.1.8(transitive)
- Removedwordwrap@0.0.3(transitive)
- Removedxml@0.0.12(transitive)