Przeglądaj źródła

Merge pull request #518 from mirokuratczyk/master

Fix: handle all connection states
Rod Hynes 6 lat temu
rodzic
commit
328bcc0889

+ 5 - 2
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -325,6 +325,10 @@
 - (BOOL)startIfNeeded {
     PsiphonConnectionState connState = [self getConnectionState];
 
+    if (connState == PsiphonConnectionStateDisconnected) {
+        return [self start];
+    }
+
     // We have found that on iOS, the local proxies will get killed before the
     // tunnel gets disconnected (or before it realizes it's dead). So we need to
     // start if we either in a disconnected state or if our local proxies are dead.
@@ -341,8 +345,7 @@
         needRestart = (httpProxyPort != 0 && ![self isLocalProxyAliveAtPort:httpProxyPort]);
     }
 
-    if ((connState == PsiphonConnectionStateDisconnected) ||
-        (connState == PsiphonConnectionStateConnected && needRestart)) {
+    if (needRestart) {
         return [self start];
     }