Parcourir la source

Merge pull request #496 from amirkhan5/master

Export current network reachability status
Rod Hynes il y a 7 ans
Parent
commit
05c605f663

+ 8 - 0
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.h

@@ -369,6 +369,14 @@ Swift: @code func onInternetReachabilityChanged(_ currentReachability: Reachabil
  */
 - (PsiphonConnectionState)getConnectionState;
 
+/*!
+ Returns the current network reachability status, if Psiphon tunnel is not in a
+ disconnected state.
+ @return The current reachability status.
+ Swift: @code func getNetworkReachabilityStatus(_ status: UnsafeMutablePointer<NetworkStatus>!) -> Bool  @endcode
+ */
+- (BOOL)getNetworkReachabilityStatus:(NetworkStatus * _Nonnull)status;
+
 /*!
  Provides the port number of the local SOCKS proxy. Only valid when currently connected (will return 0 otherwise).
  @return  The current local SOCKS proxy port number.

+ 9 - 0
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -376,6 +376,15 @@
     return atomic_load(&self->connectionState);
 }
 
+- (BOOL)getNetworkReachabilityStatus:(NetworkStatus * _Nonnull)status {
+    PsiphonConnectionState connState = [self getConnectionState];
+    if (connState == PsiphonConnectionStateDisconnected) {
+        return FALSE;
+    }
+    (*status) = atomic_load(&self->currentNetworkStatus);
+    return TRUE;
+}
+
 // See comment in header.
 - (NSInteger)getLocalSocksProxyPort {
     return atomic_load(&self->localSocksProxyPort);