Эх сурвалжийг харах

Make notice handlers compatible with TunnelPoolSize > 1

Rod Hynes 5 жил өмнө
parent
commit
c5c94f313a

+ 4 - 6
MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java

@@ -845,9 +845,6 @@ public class PsiphonTunnel {
         File oslDownloadDir = new File(context.getFilesDir(), "osl");
         json.put("MigrateObfuscatedServerListDownloadDirectory", oslDownloadDir.getAbsolutePath());
 
-        // Note: onConnecting/onConnected logic assumes 1 tunnel connection
-        json.put("TunnelPoolSize", 1);
-
         // Continue to run indefinitely until connected
         if (!json.has("EstablishTunnelTimeoutSeconds")) {
             json.put("EstablishTunnelTimeoutSeconds", 0);
@@ -911,14 +908,15 @@ public class PsiphonTunnel {
 
             if (noticeType.equals("Tunnels")) {
                 int count = notice.getJSONObject("data").getInt("count");
-                if (count > 0) {
+                if (count == 0) {
+                    mHostService.onConnecting();
+                } else if (count == 1) {
                     if (isVpnMode() && mShouldRouteThroughTunnelAutomatically) {
                         routeThroughTunnel();
                     }
                     mHostService.onConnected();
-                } else {
-                    mHostService.onConnecting();
                 }
+                // count > 1 is an additional multi-tunnel establishment, and not reported.
 
             } else if (noticeType.equals("AvailableEgressRegions")) {
                 JSONArray egressRegions = notice.getJSONObject("data").getJSONArray("regions");

+ 4 - 6
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -831,9 +831,6 @@ typedef NS_ERROR_ENUM(PsiphonTunnelErrorDomain, PsiphonTunnelErrorCode) {
         
     config[@"DeviceRegion"] = [PsiphonTunnel getDeviceRegion];
     
-    // This library expects a pool size of 1
-    config[@"TunnelPoolSize"] = [NSNumber numberWithInt:1];
-
     // We don't support upgrade downloading
     config[@"UpgradeDownloadURLs"] = nil;
     config[@"UpgradeDownloadUrl"] = nil;
@@ -899,11 +896,12 @@ typedef NS_ERROR_ENUM(PsiphonTunnelErrorDomain, PsiphonTunnelErrorCode) {
             return;
         }
 
-        if ([count integerValue] > 0) {
-            [self changeConnectionStateTo:PsiphonConnectionStateConnected evenIfSameState:NO];
-        } else {
+        if ([count integerValue] == 0) {
             [self changeConnectionStateTo:PsiphonConnectionStateConnecting evenIfSameState:NO];
+        } else if ([count integerValue] == 1) {
+            [self changeConnectionStateTo:PsiphonConnectionStateConnected evenIfSameState:NO];
         }
+        // count > 1 is an additional multi-tunnel establishment, and not reported.
     }
     else if ([noticeType isEqualToString:@"Exiting"]) {
         if ([self.tunneledAppDelegate respondsToSelector:@selector(onExiting)]) {