mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Close over init so that we can return if a feature isn't detected
I guess alternatively, just use an if/else block.
This commit is contained in:
parent
f97c37fe5d
commit
27a92ab03a
2 changed files with 130 additions and 121 deletions
|
@ -2,34 +2,38 @@
|
|||
Entry point.
|
||||
*/
|
||||
|
||||
var snowflake, query, debug, silenceNotifications, log, dbg, init;
|
||||
|
||||
;(function() {
|
||||
|
||||
if (((typeof TESTING === "undefined" || TESTING === null) || !TESTING) && !Util.featureDetect()) {
|
||||
console.log('webrtc feature not detected. shutting down');
|
||||
return;
|
||||
}
|
||||
|
||||
var snowflake = null;
|
||||
snowflake = null;
|
||||
|
||||
var query = Query.parse(location);
|
||||
query = Query.parse(location);
|
||||
|
||||
var debug = Params.getBool(query, 'debug', false);
|
||||
debug = Params.getBool(query, 'debug', false);
|
||||
|
||||
var silenceNotifications = Params.getBool(query, 'silent', false);
|
||||
silenceNotifications = Params.getBool(query, 'silent', false);
|
||||
|
||||
// Log to both console and UI if applicable.
|
||||
// Requires that the snowflake and UI objects are hooked up in order to
|
||||
// log to console.
|
||||
var log = function(msg) {
|
||||
log = function(msg) {
|
||||
console.log('Snowflake: ' + msg);
|
||||
return snowflake != null ? snowflake.ui.log(msg) : void 0;
|
||||
};
|
||||
|
||||
var dbg = function(msg) {
|
||||
dbg = function(msg) {
|
||||
if (debug || ((snowflake != null ? snowflake.ui : void 0) instanceof DebugUI)) {
|
||||
return log(msg);
|
||||
}
|
||||
};
|
||||
|
||||
var init = function() {
|
||||
init = function() {
|
||||
var broker, config, ui;
|
||||
config = new Config;
|
||||
if ('off' !== query['ratelimit']) {
|
||||
|
@ -71,3 +75,5 @@ window.onunload = function() {
|
|||
};
|
||||
|
||||
window.onload = init;
|
||||
|
||||
}());
|
||||
|
|
|
@ -2,25 +2,26 @@
|
|||
Entry point.
|
||||
*/
|
||||
|
||||
var debug = false;
|
||||
var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotifications;
|
||||
|
||||
var snowflake = null;
|
||||
;(function () {
|
||||
|
||||
var config = null;
|
||||
|
||||
var broker = null;
|
||||
|
||||
var ui = null;
|
||||
silenceNotifications = false;
|
||||
debug = false;
|
||||
snowflake = null;
|
||||
config = null;
|
||||
broker = null;
|
||||
ui = null;
|
||||
|
||||
// Log to both console and UI if applicable.
|
||||
// Requires that the snowflake and UI objects are hooked up in order to
|
||||
// log to console.
|
||||
var log = function(msg) {
|
||||
log = function(msg) {
|
||||
console.log('Snowflake: ' + msg);
|
||||
return snowflake != null ? snowflake.ui.log(msg) : void 0;
|
||||
};
|
||||
|
||||
var dbg = function(msg) {
|
||||
dbg = function(msg) {
|
||||
if (debug) {
|
||||
return log(msg);
|
||||
}
|
||||
|
@ -35,7 +36,7 @@ if (!Util.featureDetect()) {
|
|||
return;
|
||||
}
|
||||
|
||||
var init = function() {
|
||||
init = function() {
|
||||
config = new Config;
|
||||
ui = new WebExtUI();
|
||||
broker = new Broker(config.brokerUrl);
|
||||
|
@ -44,7 +45,7 @@ var init = function() {
|
|||
return ui.initToggle();
|
||||
};
|
||||
|
||||
var update = function() {
|
||||
update = function() {
|
||||
if (!ui.enabled) {
|
||||
// Do not activate the proxy if any number of conditions are true.
|
||||
snowflake.disable();
|
||||
|
@ -72,3 +73,5 @@ window.onunload = function() {
|
|||
};
|
||||
|
||||
window.onload = init;
|
||||
|
||||
}());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue