Node JS VPN连接到端点

时间:2017-02-20 15:23:35

标签: javascript node.js amazon-web-services amazon-ec2

我希望你能帮忙!

我有设置和Amazon echo applcation,应用程序向AWS EC2实例发出请求并获取JSON数据作为响应,这是按预期工作但最终应用程序的用例是连接到私有IP发送API的参数,以返回相同的JSON数据。

由于许多原因,遗憾的是我无法共享任何端点信息。

我需要我的NODE.js应用程序通过VPN连接向私有IP发出请求,我当前正在使用OPENVPN向端点发出本地请求。

我查看了节点包,看看是否可以,但我似乎找不到一个,除了这个包在这里

https://www.npmjs.com/package/node-openvpn

This package is has a dependancy thats fails to download, so i got the node_module manually but Im getting an error when i try to execute the code 


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

var opts = {
    host: 'xx.xx.xx.xx', // normally '127.0.0.1', will default to if undefined
    port: 443, //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
};

var auth = {
    user: '*******',
    pass: '*******',
};

var openvpn = openvpnmanager.connect(opts)

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

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

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

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

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

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

这只是给我一个错误

Unhandled rejection TypeError: Cannot read property 'writable' of undefined
            at Telnet.exec (C:\Users\user\Desktop\alexa-    po\node_modules\node-openvpn\node_modules\telnet-client\lib\telnet-    client.js:90:24)

如果有人对如何做到这一点有任何建议,我将非常感激。

0 个答案:

没有答案