commit b07b9572aa85353595e36c44d81af6c120da10b1 Author: Cecylia Bocovich cohosh@torproject.org Date: Thu Oct 29 12:26:34 2020 -0400
Adjust timeouts for NAT probe --- package.json | 2 +- util.js | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/package.json b/package.json index 28d2707..1cbbff4 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 8ab65d9..c9dd7ef 100644 --- a/util.js +++ b/util.js @@ -41,12 +41,13 @@ class Util { pc.createOffer() .then((offer) => pc.setLocalDescription(offer)) .then(() => Util.sendOffer(pc.localDescription)) - .then((answer) => pc.setRemoteDescription(JSON.parse(answer))) - .catch((e) => { + .then((answer) => { + setTimeout(() => {if(!open) fulfill("restricted");}, timeout); + pc.setRemoteDescription(JSON.parse(answer)); + }).catch((e) => { console.log(e); reject("Error checking NAT type"); }); - setTimeout(() => {if(!open) fulfill("restricted");}, timeout); }); }
@@ -56,7 +57,7 @@ class Util { return new Promise((fulfill, reject) => { var xhr; xhr = new XMLHttpRequest(); - xhr.timeout = 10 * 1000; + xhr.timeout = 30 * 1000; xhr.onreadystatechange = function() { if (xhr.DONE !== xhr.readyState) { return;
tor-commits@lists.torproject.org