Просмотр исходного кода

Merge pull request #518 from mirokuratczyk/master

Fix: handle all connection states
Rod Hynes 6 лет назад
Родитель
Сommit
328bcc0889
1 измененных файлов с 5 добавлено и 2 удалено
  1. 5 2
      MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

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

@@ -325,6 +325,10 @@
 - (BOOL)startIfNeeded {
 - (BOOL)startIfNeeded {
     PsiphonConnectionState connState = [self getConnectionState];
     PsiphonConnectionState connState = [self getConnectionState];
 
 
+    if (connState == PsiphonConnectionStateDisconnected) {
+        return [self start];
+    }
+
     // We have found that on iOS, the local proxies will get killed before the
     // 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
     // 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.
     // 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]);
         needRestart = (httpProxyPort != 0 && ![self isLocalProxyAliveAtPort:httpProxyPort]);
     }
     }
 
 
-    if ((connState == PsiphonConnectionStateDisconnected) ||
-        (connState == PsiphonConnectionStateConnected && needRestart)) {
+    if (needRestart) {
         return [self start];
         return [self start];
     }
     }