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

Merge branch 'master' of https://github.com/Psiphon-Labs/psiphon-tunnel-core

Rod Hynes 5 лет назад
Родитель
Сommit
f4ea445cf9
2 измененных файлов с 11 добавлено и 4 удалено
  1. 7 3
      MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java
  2. 4 1
      psiphon/controller.go

+ 7 - 3
MobileLibrary/Android/PsiphonTunnel/PsiphonTunnel.java

@@ -1010,14 +1010,18 @@ public class PsiphonTunnel {
         candidates.put("192", new PrivateAddress("192.168.0.1", "192.168.0.0", 16, "192.168.0.2"));
         candidates.put("169", new PrivateAddress("169.254.1.1", "169.254.1.0", 24, "169.254.1.2"));
 
-        List<NetworkInterface> netInterfaces;
+        Enumeration<NetworkInterface> netInterfaces;
         try {
-            netInterfaces = Collections.list(NetworkInterface.getNetworkInterfaces());
+            netInterfaces = NetworkInterface.getNetworkInterfaces();
         } catch (SocketException e) {
             throw new Exception("selectPrivateAddress failed", e);
         }
 
-        for (NetworkInterface netInterface : netInterfaces) {
+        if (netInterfaces == null) {
+            throw new Exception("no network interfaces found");
+        }
+
+        for (NetworkInterface netInterface : Collections.list(netInterfaces)) {
             for (InetAddress inetAddress : Collections.list(netInterface.getInetAddresses())) {
                 if (inetAddress instanceof Inet4Address) {
                     String ipAddress = inetAddress.getHostAddress();

+ 4 - 1
psiphon/controller.go

@@ -1668,6 +1668,8 @@ loop:
 		// tunnel dial fails due to an upstream proxy error. As the upstream proxy
 		// is user configured, the error message may need to be relayed to the user.
 
+		callbackCandidateServerEntry := candidateServerEntry
+
 		upstreamProxyErrorCallback := func(err error) {
 
 			// Do not post the notice when overall context is canceled or timed-out:
@@ -1707,7 +1709,8 @@ loop:
 			// candidates have completed by checking that at least 2*workerPoolSize
 			// candidates have started.
 
-			elapsedTime := time.Since(candidateServerEntry.adjustedEstablishStartTime)
+			elapsedTime := time.Since(
+				callbackCandidateServerEntry.adjustedEstablishStartTime)
 
 			if elapsedTime < minWaitDuration ||
 				(elapsedTime < maxWaitDuration &&