File tree Expand file tree Collapse file tree 4 files changed +15
-0
lines changed
android/src/main/java/com/norcod/rnovpn
vpnLib/src/main/java/de/blinkt/openvpn/core Expand file tree Collapse file tree 4 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -194,6 +194,11 @@ public void disconnect(Promise promise) {
194194 }
195195 }
196196
197+ @ ReactMethod
198+ public void getCurrentState (Promise promise ) {
199+ promise .resolve (getVpnState (VpnStatus .getStatus ()));
200+ }
201+
197202 private void prepareVpn (final Promise promise ) {
198203 Activity currentActivity = getCurrentActivity ();
199204
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ interface VpnEventParams {
4242declare namespace RNSimpleOpenvpn {
4343 function connect ( options : VpnOptions ) : Promise < void > ;
4444 function disconnect ( ) : Promise < void > ;
45+ function getCurrentState ( ) : Promise < VpnState > ;
4546 function observeState ( ) : Promise < void > ;
4647 function stopObserveState ( ) : Promise < void > ;
4748 enum VpnState {
Original file line number Diff line number Diff line change @@ -177,6 +177,11 @@ - (void)startVpn:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock
177177 resolve (nil );
178178}
179179
180+ RCT_EXPORT_METHOD (getCurrentState : (RCTPromiseResolveBlock)resolve rejecter : (RCTPromiseRejectBlock)reject) {
181+ NSDictionary *vpnState = [self getVpnState: self .providerManager.connection.status];
182+ resolve (vpnState[@" state" ]);
183+ }
184+
180185- (NSDictionary *)getVpnState : (NEVPNStatus)status {
181186 VpnState state;
182187 NSString *message;
Original file line number Diff line number Diff line change @@ -73,6 +73,10 @@ public static boolean isVPNActive() {
7373 return mLastLevel != ConnectionStatus .LEVEL_AUTH_FAILED && !(mLastLevel == ConnectionStatus .LEVEL_NOTCONNECTED );
7474 }
7575
76+ public static ConnectionStatus getStatus () {
77+ return mLastLevel ;
78+ }
79+
7680 public static String getLastCleanLogMessage (Context c ) {
7781 String message = mLaststatemsg ;
7882 switch (mLastLevel ) {
You can’t perform that action at this time.
0 commit comments