首页 > 解决方案 > 以编程方式连接 vpn 为 android ios 做出本机反应

问题描述

我是原生反应新手,我想为 Android 和 IOS 制作一个 VPN 客户端应用程序。VPN 协议应该是 IPSec 或 IKEv2 或任何其他协议。我试过这些:

1.OpenVPN

node-openvpnopenvpn-bin但没有运气

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

const opts = {

  host: '127.0.0.1', // normally '127.0.0.1', will default to if undefined

  port: 1337, //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
};



const auth = {

  user: 'vpnUserName',

  pass: 'vpnPassword',

};

const openvpn = openvpnmanager.connect(opts)

// will be emited on successful interfacing with openvpn instance

openvpn.on('connected', () => {

  openvpnmanager.authorize(auth);

})

2. react原生开启设置

react-native-device-settingreact-native-open-settings,他们已经展示了以编程方式打开 android 手机设置,例如:

安装包:npm install react-native-device-settings --save

用法:

import DeviceSettings from 'react-native-device-settings';

DeviceSettings.open(); // Open settings menu

DeviceSettings.app(); // Open app settings menu

DeviceSettings.wifi(); // Open wifi settings menu

但是没有办法打开 VPN 设置和配置 VPN。47306057也问过同样的问题

我需要一些方向或方法来解决这个问题。有没有我应该在android studio中使用或制作VPN应用程序的库或其他东西,然后在此处导入aar文件。它会起作用吗?

谁能帮我解决这个问题?谢谢

标签: androidiosnode.jsreact-nativevpn

解决方案


推荐阅读