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

tun2socks: toggleable client keep-alives
- Add 'isTCS' to 'ActiveServer' notice
- Add JNI calls to enable/disable udpgw client keep-alives

Michael Goldberger 9 лет назад
Родитель
Сommit
880dde4486

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

@@ -497,7 +497,12 @@ public class PsiphonTunnel extends Psi.PsiphonProvider.Stub {
             } else if(noticeType.equals("ClientVerificationRequired")) {
                 JSONObject data = notice.getJSONObject("data");
                 mHostService.onClientVerificationRequired(data.getString("nonce"), data.getInt("ttlSeconds"), data.getBoolean("resetCache"));
-
+            } else if (noticeType.equals("ActiveTunnel")) {
+                if (notice.getJSONObject("data").getBoolean("isTCS")) {
+                  disableUdpGwKeepalive();
+                } else {
+                  enableUdpGwKeepalive();
+                }
             }
 
             if (diagnostic) {
@@ -678,6 +683,9 @@ public class PsiphonTunnel extends Psi.PsiphonProvider.Stub {
 
     private native static int terminateTun2Socks();
 
+    private native static int enableUdpGwKeepalive();
+    private native static int disableUdpGwKeepalive();
+
     //----------------------------------------------------------------------------------------------
     // Implementation: Network Utils
     //----------------------------------------------------------------------------------------------

+ 1 - 1
psiphon/controller.go

@@ -603,7 +603,7 @@ loop:
 				break
 			}
 
-			NoticeActiveTunnel(establishedTunnel.serverEntry.IpAddress, establishedTunnel.protocol)
+			NoticeActiveTunnel(establishedTunnel.serverEntry.IpAddress, establishedTunnel.protocol, establishedTunnel.serverEntry.SupportsSSHAPIRequests())
 
 			if tunnelCount == 1 {
 

+ 2 - 2
psiphon/notice.go

@@ -204,8 +204,8 @@ func NoticeConnectedServer(ipAddress, region, protocol string, tunnelDialStats *
 }
 
 // NoticeActiveTunnel is a successful connection that is used as an active tunnel for port forwarding
-func NoticeActiveTunnel(ipAddress, protocol string) {
-	outputNotice("ActiveTunnel", noticeIsDiagnostic, "ipAddress", ipAddress, "protocol", protocol)
+func NoticeActiveTunnel(ipAddress, protocol string, isTCS bool) {
+	outputNotice("ActiveTunnel", noticeIsDiagnostic, "ipAddress", ipAddress, "protocol", protocol, "isTCS", isTCS)
 }
 
 // NoticeSocksProxyPortInUse is a failure to use the configured LocalSocksProxyPort