Forráskód Böngészése

Fix notice handling for ConnectedServerRegion callback

- Add new notice `NoticeConnectedServerRegion` to handle server region callbacks separately from `ActiveTunnel`
- Update mobile libraries to handle `ConnectedServerRegion` notices
Eugene Fryntov 1 éve
szülő
commit
6d8f9a6414

+ 1 - 1
MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java

@@ -1084,7 +1084,7 @@ public class PsiphonTunnel {
                       enableUdpGwKeepalive();
                     }
                 }
-                // Also report the tunnel's egress region to the host service
+            } else if (noticeType.equals("ConnectedServerRegion")) {
                 mHostService.onConnectedServerRegion(
                         notice.getJSONObject("data").getString("serverRegion"));
             } else if (noticeType.equals("ApplicationParameters")) {

+ 1 - 1
MobileLibrary/iOS/PsiphonTunnel/PsiphonTunnel/PsiphonTunnel.m

@@ -1174,7 +1174,7 @@ typedef NS_ERROR_ENUM(PsiphonTunnelErrorDomain, PsiphonTunnelErrorCode) {
             });
         }
     }
-    else if ([noticeType isEqualToString:@"ActiveTunnel"]) {
+    else if ([noticeType isEqualToString:@"ConnectedServerRegion"]) {
         id region = [notice valueForKeyPath:@"data.serverRegion"];
         if (![region isKindOfClass:[NSString class]]) {
             [self logMessage:[NSString stringWithFormat: @"ActiveTunnel notice missing data.serverRegion: %@", noticeJSON]];

+ 2 - 0
psiphon/controller.go

@@ -1004,6 +1004,8 @@ loop:
 				connectedTunnel.dialParams.ServerEntry.SupportsSSHAPIRequests(),
 				connectedTunnel.dialParams.ServerEntry.Region)
 
+			NoticeConnectedServerRegion(connectedTunnel.dialParams.ServerEntry.Region)
+
 			if isFirstTunnel {
 
 				// Signal a connected request on each 1st tunnel establishment. For

+ 7 - 0
psiphon/notice.go

@@ -687,6 +687,13 @@ func NoticeActiveTunnel(diagnosticID, protocol string, isTCS bool, serverRegion
 		"serverRegion", serverRegion)
 }
 
+// NoticeConnectedServerRegion reports the region of the connected server
+func NoticeConnectedServerRegion(serverRegion string) {
+	singletonNoticeLogger.outputNotice(
+		"ConnectedServerRegion", 0,
+		"serverRegion", serverRegion)
+}
+
 // NoticeSocksProxyPortInUse is a failure to use the configured LocalSocksProxyPort
 func NoticeSocksProxyPortInUse(port int) {
 	singletonNoticeLogger.outputNotice(