I have an .ovpn
config file with a built-in username and password that was uploaded to a server through my API. While I obtained this file via the API, I now need to use it in conjunction with a username and password entered into text fields. My goal is to utilize all of this information to establish a connection to my OpenVPN server using Electron.js. Is there a way to achieve this?
I use the following code, but it doesn't work:
const electron = require('electron')
var openvpnmanager = require('node-openvpn')
var opts = {
host: 'my server ip address', // normally '127.0.0.1', will default to if undefined
port: my server port, //port openvpn management console
timeout: 60000, //timeout for connection - optional, will default to 1500ms if undefined
config: 'http://mydomain/configs/client.ovpn'
};
var auth = {
user: 'user@gmail.com',
pass: 'secret'
};
var openvpn = openvpnmanager.connect(opts)
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)
});