Skip to content

Commit 63509b7

Browse files
committed
📃 docs: add new API
1 parent 80a0434 commit 63509b7

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

docs/Reference.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This document lays out the current public properties and methods for the React N
1010
| ---------------------- | --- | ------- | -------------------------------------------------------- | ------- | ------------------------------------------- |
1111
| connect ||| options: [VpnOptions](#vpnoptions) | promise | Connecting to OpenVPN |
1212
| disconnect ||| none | promise | Close the OpenVPN connection |
13+
| getCurrentState ||| none | promise | Get current VPN status |
1314
| observeState ||| none | promise | Listening for VPN status |
1415
| stopObserveState ||| none | promise | Stop listening to VPN status |
1516
| addVpnStateListener ||| callback: (e: [VpnEventParams](#vpneventparams)) => void | void | Add VPN status change event listener |
@@ -31,10 +32,16 @@ interface VpnOptions {
3132
remoteAddress?: string;
3233
ovpnString?: string;
3334
ovpnFileName?: string;
35+
username?: string;
36+
password?: string;
3437
assetsPath?: string;
3538
notificationTitle?: string;
3639
compatMode?: RNSimpleOpenvpn.CompatMode;
3740
useLegacyProvider?: boolean;
41+
useCustomConfig?: boolean;
42+
customConfigOptions?: string;
43+
allowedAppsVpn?: Array<string>;
44+
allowedAppsVpnAreDisallowed?: boolean;
3845
providerBundleIdentifier: string;
3946
localizedDescription?: string;
4047
}
@@ -54,6 +61,14 @@ String format reference [example.ovpn](../example/android/app/src/main/assets/Ja
5461

5562
The name of the OpenVPN configuration file, without extensions, using the default name `client` if not passed in
5663

64+
#### username
65+
66+
The username for auth, using the default value `''` if not passed in
67+
68+
#### password
69+
70+
The password for auth, using the default value `''` if not passed in
71+
5772
#### assetsPath
5873

5974
**Android only**,the path to the OpenVPN configuration file under `android/app/src/main/assets/`
@@ -80,6 +95,31 @@ The name of the OpenVPN configuration file, without extensions, using the defaul
8095

8196
**Android only**,load OpenSSL legacy provider or not, using the default value `false` if not passed in
8297

98+
#### useCustomConfig
99+
100+
**Android only**, use custom config or not, using the default value `false` if not passed in
101+
102+
#### customConfigOptions
103+
104+
**Android only**, add your own configuration string like below, using the default value `''` if not passed in
105+
106+
```text
107+
http-proxy ...
108+
http-proxy-option ...
109+
```
110+
111+
#### allowedAppsVpn
112+
113+
**Android only**, list of application package names for VPN connection, the default value is an empty array
114+
115+
```js
116+
['com.app1', 'com.app2'];
117+
```
118+
119+
#### allowedAppsVpnAreDisallowed
120+
121+
**Android only**, the packages that we specify **allowedAppsVpn** use our VPN connection or not, and the rest is the opposite, using the default value `true` if not passed in
122+
83123
#### providerBundleIdentifier
84124

85125
**iOS only**,the bundle identifier of the Network Extension target

docs/Reference.zh-CN.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
| ---------------------- | --- | ------- | -------------------------------------------------------- | ------- | ------------------------- |
1111
| connect ||| options: [VpnOptions](#vpnoptions) | promise | 连接 OpenVPN |
1212
| disconnect |||| promise | 关闭 OpenVPN 连接 |
13+
| getCurrentState ||| none | promise | 获取 VPN 当前状态 |
1314
| observeState |||| promise | 监听 VPN 状态 |
1415
| stopObserveState |||| promise | 停止监听 VPN 状态 |
1516
| addVpnStateListener ||| callback: (e: [VpnEventParams](#vpneventparams)) => void | void | 添加 VPN 状态变更事件监听 |
@@ -31,10 +32,16 @@ interface VpnOptions {
3132
remoteAddress?: string;
3233
ovpnString?: string;
3334
ovpnFileName?: string;
35+
username?: string;
36+
password?: string;
3437
assetsPath?: string;
3538
notificationTitle?: string;
3639
compatMode?: RNSimpleOpenvpn.CompatMode;
3740
useLegacyProvider?: boolean;
41+
useCustomConfig?: boolean;
42+
customConfigOptions?: string;
43+
allowedAppsVpn?: Array<string>;
44+
allowedAppsVpnAreDisallowed?: boolean;
3845
providerBundleIdentifier: string;
3946
localizedDescription?: string;
4047
}
@@ -54,6 +61,14 @@ OpenVPN 配置文件内容的字符串形式,未传入时或传递空字符串
5461

5562
OpenVPN 配置文件的名称,不含扩展名,未传入时使用默认名称 `client`
5663

64+
#### username
65+
66+
鉴权用户名, 未传入时使用默认名称 `''`
67+
68+
#### password
69+
70+
鉴权密码, 未传入时使用默认名称 `''`
71+
5772
#### assetsPath
5873

5974
**Android 专用**,OpenVPN 配置文件在 `android/app/src/main/assets/` 下的路径
@@ -80,6 +95,31 @@ OpenVPN 配置文件的名称,不含扩展名,未传入时使用默认名称
8095

8196
**Android 专用**,是否加载 OpenSSL legacy provider,未传入时使用默认值 `false`
8297

98+
#### useCustomConfig
99+
100+
**Android 专用**, 是否使用自定义配置,未传入时使用默认值 `false`
101+
102+
#### customConfigOptions
103+
104+
**Android 专用**,添加类似下方的配置字符串,未传入时使用默认值 `''`
105+
106+
```text
107+
http-proxy ...
108+
http-proxy-option ...
109+
```
110+
111+
#### allowedAppsVpn
112+
113+
**Android 专用**, 进行 VPN 连接的应用包名列表, 默认值为空数组
114+
115+
```js
116+
['com.app1', 'com.app2'];
117+
```
118+
119+
#### allowedAppsVpnAreDisallowed
120+
121+
**Android 专用**, 控制 **allowedAppsVpn** 中所列的应用是否使用 VPN 连接, 而剩下的应用则相反, 未传入时使用默认值 `true`
122+
83123
#### providerBundleIdentifier
84124

85125
**iOS 专用**,Network Extension target 的 bundle identifier

0 commit comments

Comments
 (0)