OpenVPN with node, How it works?

人盡茶涼 提交于 2019-12-06 07:06:45

问题


I am able to connect to a VPN from terminal easily with the following openVPN command:

openvpn --config conf.ovpn

I need connect to the same VPN with Javascript (for selenium test), I already have installed openvpn.client with NPM:

npm install openvpn-client

However, I don't know how it works. I would like how to achieve a terminal application with similar functionalities of openvpn.

Documentation and source code

  • https://www.npmjs.com/package/openvpn-client

  • https://github.com/resin-io/openvpn-client


回答1:


Solved, more or less...

After install openvpn in the system just add bit s to the openvpn bin (sudo chmod +s /usr/sbin/openvpn), then you can connect openvpn with this:

var exec = require("child_process").exec;

cmd = `openvpn --config ${conf.ovpn}&`;
exec(cmd);

Just that. Maybe isn't the most secure solution, but it works for my purpose.

Thanks.



来源:https://stackoverflow.com/questions/36864219/openvpn-with-node-how-it-works

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!