react-native-wireguard-vpn-patched 1.0.22-patch.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +238 -0
- package/android/build.gradle +60 -0
- package/android/src/main/java/com/wireguardvpn/WireGuardVpnModule.kt +353 -0
- package/android/src/main/java/com/wireguardvpn/WireGuardVpnPackage.kt +16 -0
- package/app.plugin.js +4 -0
- package/ios/WireGuardVpn.h +5 -0
- package/ios/WireGuardVpn.m +294 -0
- package/lib/index.d.ts +53 -0
- package/lib/index.js +46 -0
- package/lib/index.js.map +1 -0
- package/package.json +56 -0
- package/plugin/withWireGuardVpn.js +105 -0
- package/react-native-wireguard-vpn-patched.podspec +21 -0
- package/src/index.d.ts +41 -0
- package/src/index.ts +99 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const LINKING_ERROR =
|
|
4
|
+
`The package 'react-native-wireguard-vpn-patched' doesn't seem to be linked. Make sure: \n\n` +
|
|
5
|
+
Platform.select({ ios: "- You have run 'pod install'\n", default: '' }) +
|
|
6
|
+
'- You rebuilt the app after installing the package\n' +
|
|
7
|
+
'- You are not using Expo Go\n';
|
|
8
|
+
|
|
9
|
+
const WireGuardVpnModule = NativeModules.WireGuardVpnModule
|
|
10
|
+
? NativeModules.WireGuardVpnModule
|
|
11
|
+
: new Proxy(
|
|
12
|
+
{},
|
|
13
|
+
{
|
|
14
|
+
get() {
|
|
15
|
+
throw new Error(LINKING_ERROR);
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export interface WireGuardConfig {
|
|
21
|
+
privateKey: string;
|
|
22
|
+
publicKey: string;
|
|
23
|
+
serverAddress: string;
|
|
24
|
+
serverPort: number;
|
|
25
|
+
/** Interface address(es), e.g. "10.64.0.1/32". If omitted, defaults to 10.64.0.1/32. Do not use 0.0.0.0/0 or ::/0 here (use allowedIPs for routing). */
|
|
26
|
+
address?: string | string[];
|
|
27
|
+
allowedIPs: string[];
|
|
28
|
+
dns?: string[];
|
|
29
|
+
mtu?: number;
|
|
30
|
+
presharedKey?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Split tunneling — Android only.
|
|
33
|
+
* Package names of apps whose traffic should bypass the VPN tunnel.
|
|
34
|
+
* Example: ["com.google.android.apps.maps", "com.example.bankingapp"]
|
|
35
|
+
*/
|
|
36
|
+
excludedApps?: string[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface WireGuardStatus {
|
|
40
|
+
isConnected: boolean;
|
|
41
|
+
tunnelState:
|
|
42
|
+
| 'ACTIVE'
|
|
43
|
+
| 'INACTIVE'
|
|
44
|
+
| 'CONNECTING'
|
|
45
|
+
| 'DISCONNECTING'
|
|
46
|
+
| 'ERROR'
|
|
47
|
+
| 'UNKNOWN';
|
|
48
|
+
/**
|
|
49
|
+
* Connection status as a simpler string for app UI logic.
|
|
50
|
+
* - CONNECTED when tunnel is up
|
|
51
|
+
* - DISCONNECTED when tunnel is down
|
|
52
|
+
* - CONNECTING/DISCONNECTING/ERROR/UNKNOWN for intermediate states
|
|
53
|
+
*/
|
|
54
|
+
status:
|
|
55
|
+
| 'CONNECTED'
|
|
56
|
+
| 'DISCONNECTED'
|
|
57
|
+
| 'CONNECTING'
|
|
58
|
+
| 'DISCONNECTING'
|
|
59
|
+
| 'ERROR'
|
|
60
|
+
| 'UNKNOWN';
|
|
61
|
+
error?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
/**
|
|
66
|
+
* Initialize the VPN service
|
|
67
|
+
*/
|
|
68
|
+
initialize(): Promise<void> {
|
|
69
|
+
return WireGuardVpnModule.initialize();
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Connect to VPN using provided configuration
|
|
74
|
+
*/
|
|
75
|
+
connect(config: WireGuardConfig): Promise<void> {
|
|
76
|
+
return WireGuardVpnModule.connect(config);
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Disconnect from VPN
|
|
81
|
+
*/
|
|
82
|
+
disconnect(): Promise<void> {
|
|
83
|
+
return WireGuardVpnModule.disconnect();
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get current VPN status
|
|
88
|
+
*/
|
|
89
|
+
getStatus(): Promise<WireGuardStatus> {
|
|
90
|
+
return WireGuardVpnModule.getStatus();
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Check if VPN is supported on the device
|
|
95
|
+
*/
|
|
96
|
+
isSupported(): Promise<boolean> {
|
|
97
|
+
return WireGuardVpnModule.isSupported();
|
|
98
|
+
},
|
|
99
|
+
};
|