mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Compile coffee files and remove them
With, ./node_modules/.bin/coffee -b -c Cakefile `find . -path ./node_modules -prune -o -name '*.coffee'`
This commit is contained in:
parent
82562fb21d
commit
31ad9566e6
38 changed files with 2277 additions and 1725 deletions
75
proxy/init-badge.js
Normal file
75
proxy/init-badge.js
Normal file
|
@ -0,0 +1,75 @@
|
|||
// Generated by CoffeeScript 2.4.1
|
||||
/*
|
||||
Entry point.
|
||||
*/
|
||||
var dbg, debug, init, log, query, silenceNotifications, snowflake;
|
||||
|
||||
if (((typeof TESTING === "undefined" || TESTING === null) || !TESTING) && !Util.featureDetect()) {
|
||||
console.log('webrtc feature not detected. shutting down');
|
||||
return;
|
||||
}
|
||||
|
||||
snowflake = null;
|
||||
|
||||
query = Query.parse(location);
|
||||
|
||||
debug = Params.getBool(query, 'debug', 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.
|
||||
log = function(msg) {
|
||||
console.log('Snowflake: ' + msg);
|
||||
return snowflake != null ? snowflake.ui.log(msg) : void 0;
|
||||
};
|
||||
|
||||
dbg = function(msg) {
|
||||
if (debug || ((snowflake != null ? snowflake.ui : void 0) instanceof DebugUI)) {
|
||||
return log(msg);
|
||||
}
|
||||
};
|
||||
|
||||
init = function() {
|
||||
var broker, config, ui;
|
||||
config = new Config;
|
||||
if ('off' !== query['ratelimit']) {
|
||||
config.rateLimitBytes = Params.getByteCount(query, 'ratelimit', config.rateLimitBytes);
|
||||
}
|
||||
ui = null;
|
||||
if (document.getElementById('badge') !== null) {
|
||||
ui = new BadgeUI();
|
||||
} else if (document.getElementById('status') !== null) {
|
||||
ui = new DebugUI();
|
||||
} else {
|
||||
ui = new UI();
|
||||
}
|
||||
broker = new Broker(config.brokerUrl);
|
||||
snowflake = new Snowflake(config, ui, broker);
|
||||
log('== snowflake proxy ==');
|
||||
if (Util.snowflakeIsDisabled(config.cookieName)) {
|
||||
// Do not activate the proxy if any number of conditions are true.
|
||||
log('Currently not active.');
|
||||
return;
|
||||
}
|
||||
// Otherwise, begin setting up WebRTC and acting as a proxy.
|
||||
dbg('Contacting Broker at ' + broker.url);
|
||||
snowflake.setRelayAddr(config.relayAddr);
|
||||
return snowflake.beginWebRTC();
|
||||
};
|
||||
|
||||
// Notification of closing tab with active proxy.
|
||||
window.onbeforeunload = function() {
|
||||
if (!silenceNotifications && Snowflake.MODE.WEBRTC_READY === snowflake.state) {
|
||||
return Snowflake.MESSAGE.CONFIRMATION;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
window.onunload = function() {
|
||||
snowflake.disable();
|
||||
return null;
|
||||
};
|
||||
|
||||
window.onload = init;
|
Loading…
Add table
Add a link
Reference in a new issue