This is an automated email from the git hooks/post-receive script.
cohosh pushed a change to branch i29 in repository pluggable-transports/snowflake-webext.
at cb68d6e Change long timers to alarms
This branch includes the following new commits:
new efd6462 Drop later: temporary submodule fix new 2b7e30b [WIP] Migrate to Manifest V3 new 9021607 Move from service worker to event page new cb68d6e Change long timers to alarms
The 4 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference.
This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch i29 in repository pluggable-transports/snowflake-webext.
commit efd64626ac01a44bf5147ae3dc8df567038b708a Author: Cecylia Bocovich cohosh@torproject.org AuthorDate: Tue Nov 1 14:40:45 2022 -0400
Drop later: temporary submodule fix --- translation | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/translation b/translation index 210820d..1d57027 160000 --- a/translation +++ b/translation @@ -1 +1 @@ -Subproject commit 210820ddf36553c1edb14ac9746ee428e58ed8da +Subproject commit 1d570277dce6aa33cb96f08974fa59965af4936b
This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch i29 in repository pluggable-transports/snowflake-webext.
commit 2b7e30bc1d12473c36c5b21fc2ca78c36d094039 Author: Arlo Breault arlolra@gmail.com AuthorDate: Fri Aug 6 14:36:06 2021 -0400
[WIP] Migrate to Manifest V3
Implements #29
Unfortunately, this runs in to a "ReferenceError: RTCPeerConnection is not defined" which is from, https://github.com/w3c/webrtc-extensions/issues/77 --- init-webext.js | 9 ++------- webext/manifest_base.json | 9 +++------ 2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/init-webext.js b/init-webext.js index 3bbdfde..a1126eb 100644 --- a/init-webext.js +++ b/init-webext.js @@ -197,7 +197,7 @@ class WebExtUI extends UI { 96: "assets/toolbar-on-96.png" }; } - chrome.browserAction.setIcon({ + chrome.action.setIcon({ path: path, }); } @@ -284,11 +284,6 @@ var snowflake.beginWebRTC(); };
- window.onunload = function() { - if (snowflake !== null) { snowflake.disable(); } - return null; - }; - - window.onload = init; + init();
}()); diff --git a/webext/manifest_base.json b/webext/manifest_base.json index 6de42ab..6d7d714 100644 --- a/webext/manifest_base.json +++ b/webext/manifest_base.json @@ -1,5 +1,5 @@ { - "manifest_version": 2, + "manifest_version": 3, "name": "Snowflake", "version": "0.6.3", "description": "__MSG_appDesc__", @@ -9,12 +9,9 @@ "96": "assets/toolbar-on-96.png" }, "background": { - "scripts": [ - "snowflake.js" - ], - "persistent": true + "service_worker": "snowflake.js" }, - "browser_action": { + "action": { "default_icon": { "48": "assets/toolbar-on-48.png", "96": "assets/toolbar-on-96.png"
This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch i29 in repository pluggable-transports/snowflake-webext.
commit 9021607de477dfab8a767a4d49c61ad91eb60594 Author: Cecylia Bocovich cohosh@torproject.org AuthorDate: Wed Aug 17 16:22:30 2022 -0400
Move from service worker to event page
Mozilla has decided to allow the use of non-persistent event pages in the move to V3 in an attempt to preserve functionality: https://blog.mozilla.org/addons/2022/05/18/manifest-v3-in-firefox-recap-next...
This allows us to call the WebRTC API, but we still may have to contend with the persistence issue, as our code relies on persistence to keep polling the broker. --- webext/manifest_base.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/webext/manifest_base.json b/webext/manifest_base.json index 6d7d714..d9080fb 100644 --- a/webext/manifest_base.json +++ b/webext/manifest_base.json @@ -9,7 +9,9 @@ "96": "assets/toolbar-on-96.png" }, "background": { - "service_worker": "snowflake.js" + "scripts": [ + "snowflake.js" + ] }, "action": { "default_icon": {
This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch i29 in repository pluggable-transports/snowflake-webext.
commit cb68d6ee34c93727b7afbf1b81821a81a6a13807 Author: Cecylia Bocovich cohosh@torproject.org AuthorDate: Tue Nov 1 14:21:24 2022 -0400
Change long timers to alarms
With manifest v3, our background page is not persistent. Longer timers set with setTimeout and setInterval are replaced with alarms and an alarm listener. --- config.js | 4 ++-- init-badge.js | 19 +++++++++++++++++++ init-webext.js | 21 ++++++++++++++++++++- package-lock.json | 2 +- package.json | 2 +- snowflake.js | 7 +++---- ui.js | 6 +----- webext/manifest_base.json | 8 +++++--- 8 files changed, 52 insertions(+), 17 deletions(-)
diff --git a/config.js b/config.js index 8f42176..3eaaf63 100644 --- a/config.js +++ b/config.js @@ -29,8 +29,8 @@ Config.prototype.slowestBrokerPollInterval = 6 * 60 * 60.0 * 1000; //1 poll ever Config.prototype.pollAdjustment = 100.0 * 1000; Config.prototype.fastBrokerPollInterval = 30 * 1000; //1 poll every 30 seconds
-// Recheck our NAT type once every 2 days -Config.prototype.natCheckInterval = 2 * 24 * 60 * 60 * 1000; +// Recheck our NAT type once every 2 days (note: this value is given in minutes) +Config.prototype.natCheckInterval = 2 * 24 * 60;
// Timeout after sending answer before datachannel is opened Config.prototype.datachannelTimeout = 20 * 1000; diff --git a/init-badge.js b/init-badge.js index a4305a2..9f9d46c 100644 --- a/init-badge.js +++ b/init-badge.js @@ -149,6 +149,25 @@ var /** @type {() => void} */ tryProbe;
+// Listeners for alarms +browser.alarms.onAlarm.addListener((alarmInfo) => { + switch(alarmInfo.name){ + case "poll": + snowflake.beginWebRTC(); + break; + case "NAT": + ui.checkNAT(); + break; + case "stats": + ui.stats.unshift(0); + ui.stats.splice(24); + ui.postActive(); + break; + default: + console.log("Unknown alarm name: ", alarmInfo.name); + } +}); + (function() {
snowflake = null; diff --git a/init-webext.js b/init-webext.js index a1126eb..9e0bfbd 100644 --- a/init-webext.js +++ b/init-webext.js @@ -65,7 +65,7 @@ class WebExtUI extends UI { initNATType() { this.natType = "unknown"; this.checkNAT(); - setInterval(() => {this.checkNAT();}, config.natCheckInterval); + browser.alarms.create("NAT", { "periodInMinutes": config.natCheckInterval } ); }
tryProbe() { @@ -235,6 +235,25 @@ var /** @type {boolean} */ silenceNotifications;
+// Listeners for alarms +browser.alarms.onAlarm.addListener((alarmInfo) => { + switch(alarmInfo.name){ + case "poll": + snowflake.beginWebRTC(); + break; + case "NAT": + ui.checkNAT(); + break; + case "stats": + ui.stats.unshift(0); + ui.stats.splice(24); + ui.postActive(); + break; + default: + console.log("Unknown alarm name: ", alarmInfo.name); + } +}); + (function () {
silenceNotifications = false; diff --git a/package-lock.json b/package-lock.json index e90c7f0..fb4aa4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "snowflake-pt", - "version": "0.6.0", + "version": "0.6.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fda82f9..1cfe3d9 100644 --- a/package.json +++ b/package.json @@ -33,4 +33,4 @@ "ws": "^5.2.3", "xmlhttprequest": "^1.8.0" } -} \ No newline at end of file +} diff --git a/snowflake.js b/snowflake.js index abb4c11..ed11c32 100644 --- a/snowflake.js +++ b/snowflake.js @@ -53,10 +53,9 @@ class Snowflake { * process. `pollBroker` automatically arranges signalling. */ beginWebRTC() { + console.log("polling broker.."); this.pollBroker(); - this.pollTimeoutId = setTimeout((() => { - this.beginWebRTC(); - }), this.pollInterval); + browser.alarms.create("poll", {"when": Date.now()+this.pollInterval } ); }
/** @@ -205,7 +204,7 @@ class Snowflake { /** Stop all proxypairs. */ disable() { log('Disabling Snowflake.'); - clearTimeout(this.pollTimeoutId); + browser.alarms.clear("pollTimeout"); while (this.proxyPairs.length > 0) { this.proxyPairs.pop().close(); } diff --git a/ui.js b/ui.js index 1af9b38..0f7e67e 100644 --- a/ui.js +++ b/ui.js @@ -10,11 +10,7 @@ class UI {
initStats() { this.stats = [0]; - setInterval((() => { - this.stats.unshift(0); - this.stats.splice(24); - this.postActive(); - }), 60 * 60 * 1000); + browser.alarms.create("stats", { "periodInMinutes" : 60 }); }
setStatus() {} diff --git a/webext/manifest_base.json b/webext/manifest_base.json index d9080fb..2b7d258 100644 --- a/webext/manifest_base.json +++ b/webext/manifest_base.json @@ -11,7 +11,8 @@ "background": { "scripts": [ "snowflake.js" - ] + ], + "persistent": false }, "action": { "default_icon": { @@ -22,6 +23,7 @@ "default_popup": "embed.html" }, "permissions": [ - "storage" + "storage", + "alarms" ] -} \ No newline at end of file +}
tor-commits@lists.torproject.org