10

我的nodejs文件中有代码,它为我提供了以下信息

host:"147.0.40.145"
method:"aes-256-cfb"
password:"9c359ad1ebeec200"
port:38473

我需要使用上述信息并想通过它连接VPN。我使用下面的代码来提取上述信息。

const connectServer = (serverId) => {
  const token = store('access_token')
  httpOptions.Authorization = token.token_type+' '+token.access_token
  return new Promise((resolve, reject) => {  
   const response = await axios.post(`${baseUrl}/servers/${serverId}/connect`, {'serverId':serverId},{headers: httpOptions})     
   console.log(response.data)
    resolve(response.data)
  })
}

所以我需要知道是否可以使用nodejs连接或创建 VPN

先感谢您!!!

4

1 回答 1

9

安装这个 npm

npm i node-openvpn --save

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

const opts = {
  host: '147.0.40.145',
  port: 38473,
  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
};
const auth = {
  user: '{{add user name}}',
  pass: '9c359ad1ebeec200',
};
const openvpn = openvpnmanager.connect(opts)


 openvpn.on('connected', () => {
   console.log("Connected to VPN successfully...");
 });

欲了解更多信息,请阅读此链接

另一个选项 链接

于 2019-04-03T13:08:56.690 回答