[tor-commits] [snowflake-webext/master] Wait for ice gathering to complete before probetest

cohosh at torproject.org cohosh at torproject.org
Tue Nov 17 01:30:09 UTC 2020


commit 09a3dccbb91e868c2cad0e369eb0d904972d7097
Author: Cecylia Bocovich <cohosh at torproject.org>
Date:   Mon Nov 16 16:27:11 2020 -0500

    Wait for ice gathering to complete before probetest
    
    This fixes a bug whether proxies behind unrestricted NATs appeared
    restricted because they were sending an offer to the probe service
    without any ice candidates.
---
 package.json |  2 +-
 util.js      | 21 +++++++++++++++------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/package.json b/package.json
index fc60414..65acb90 100644
--- a/package.json
+++ b/package.json
@@ -32,4 +32,4 @@
     "ws": "^3.3.1",
     "xmlhttprequest": "^1.8.0"
   }
-}
\ No newline at end of file
+}
diff --git a/util.js b/util.js
index c9dd7ef..35be73c 100644
--- a/util.js
+++ b/util.js
@@ -38,15 +38,24 @@ class Util {
         channel.close();
         pc.close();
       };
+      pc.onicecandidate = (evt) => {
+        if (evt.candidate == null) {
+          //ice gathering is finished
+          Util.sendOffer(pc.localDescription)
+          .then((answer) => {
+            setTimeout(() => {if(!open) fulfill("restricted");}, timeout);
+            pc.setRemoteDescription(JSON.parse(answer));
+          }).catch((e) => {
+            console.log(e);
+            reject("Error receiving probetest answer");
+          });
+        }
+      };
       pc.createOffer()
       .then((offer) =>  pc.setLocalDescription(offer))
-      .then(() => Util.sendOffer(pc.localDescription))
-      .then((answer) => {
-        setTimeout(() => {if(!open) fulfill("restricted");}, timeout);
-        pc.setRemoteDescription(JSON.parse(answer));
-      }).catch((e) => {
+      .catch((e) => {
         console.log(e);
-        reject("Error checking NAT type");
+        reject("Error creating offer for probetest");
       });
     });
   }



More information about the tor-commits mailing list