gpt4 book ai didi

javascript - 如何在ubuntu中使用nodejs连接VPN

转载 作者:数据小太阳 更新时间:2023-10-29 04:16:30 25 4
gpt4 key购买 nike

我的 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

提前致谢!!!

最佳答案

安装这个 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...");
});

更多信息,请阅读此link

另一种选择 Link

关于javascript - 如何在ubuntu中使用nodejs连接VPN,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55449569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com