[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [pluggable-transports/snowflake-webext] 06/08: refactor: remove some unused `return`
This is an automated email from the git hooks/post-receive script.
meskio pushed a commit to branch main
in repository pluggable-transports/snowflake-webext.
commit 3c2215a8039db91837235ff51897a82299095d17
Author: WofWca <wofwca@xxxxxxxxxxxxxx>
AuthorDate: Sat Jun 18 19:28:38 2022 +0300
refactor: remove some unused `return`
---
broker.js | 12 +++++++-----
init-badge.js | 6 ++++--
init-node.js | 2 +-
init-webext.js | 10 ++++++----
proxypair.js | 30 +++++++++++++++---------------
util.js | 4 ++--
6 files changed, 35 insertions(+), 29 deletions(-)
diff --git a/broker.js b/broker.js
index 128eda7..2431630 100644
--- a/broker.js
+++ b/broker.js
@@ -77,7 +77,7 @@ class Broker {
Clients: clients,
AcceptedRelayPattern: this.config.allowedRelayPattern,
};
- return this._postRequest(xhr, 'proxy', JSON.stringify(data));
+ this._postRequest(xhr, 'proxy', JSON.stringify(data));
});
}
@@ -96,14 +96,16 @@ class Broker {
switch (xhr.status) {
case Broker.CODE.OK:
dbg('Broker: Successfully replied with answer.');
- return dbg(xhr.responseText);
+ dbg(xhr.responseText);
+ break;
default:
dbg('Broker ERROR: Unexpected ' + xhr.status + ' - ' + xhr.statusText);
- return snowflake.ui.setStatus(' failure. Please refresh.');
+ snowflake.ui.setStatus(' failure. Please refresh.');
+ break;
}
};
var data = {"Version": "1.0", "Sid": id, "Answer": JSON.stringify(answer)};
- return this._postRequest(xhr, 'answer', JSON.stringify(data));
+ this._postRequest(xhr, 'answer', JSON.stringify(data));
}
setNATType(natType) {
@@ -127,7 +129,7 @@ class Broker {
log('Broker: exception while connecting: ' + err.message);
return;
}
- return xhr.send(payload);
+ xhr.send(payload);
}
}
diff --git a/init-badge.js b/init-badge.js
index c74038c..ec62b5d 100644
--- a/init-badge.js
+++ b/init-badge.js
@@ -50,7 +50,7 @@ class BadgeUI extends UI {
initNATType() {
this.natType = "unknown";
this.checkNAT();
- return setInterval(() => {this.checkNAT();}, config.natCheckInterval);
+ setInterval(() => {this.checkNAT();}, config.natCheckInterval);
}
setStatus() {}
@@ -139,7 +139,9 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
// log to console.
log = function(msg) {
console.log('Snowflake: ' + msg);
- return snowflake != null ? snowflake.ui.log(msg) : void 0;
+ if (snowflake != null) {
+ snowflake.ui.log(msg);
+ }
};
dbg = function(msg) {
diff --git a/init-node.js b/init-node.js
index b5a60d8..e5c2e32 100644
--- a/init-node.js
+++ b/init-node.js
@@ -13,7 +13,7 @@ var broker = new Broker(config);
var snowflake = new Snowflake(config, ui, broker);
var log = function(msg) {
- return console.log('Snowflake: ' + msg);
+ console.log('Snowflake: ' + msg);
};
var dbg = log;
diff --git a/init-webext.js b/init-webext.js
index dd67b98..dfd776a 100644
--- a/init-webext.js
+++ b/init-webext.js
@@ -27,7 +27,7 @@ class WebExtUI extends UI {
initNATType() {
this.natType = "unknown";
this.checkNAT();
- return setInterval(() => {this.checkNAT();}, config.natCheckInterval);
+ setInterval(() => {this.checkNAT();}, config.natCheckInterval);
}
tryProbe() {
@@ -164,12 +164,14 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
// log to console.
log = function(msg) {
console.log('Snowflake: ' + msg);
- return snowflake != null ? snowflake.ui.log(msg) : void 0;
+ if (snowflake != null) {
+ snowflake.ui.log(msg);
+ }
};
dbg = function(msg) {
if (debug) {
- return log(msg);
+ log(msg);
}
};
@@ -194,7 +196,7 @@ var debug, snowflake, config, broker, ui, log, dbg, init, update, silenceNotific
dbg('Contacting Broker at ' + broker.url);
log('Starting snowflake');
snowflake.setRelayAddr(config.relayAddr);
- return snowflake.beginWebRTC();
+ snowflake.beginWebRTC();
};
window.onunload = function() {
diff --git a/proxypair.js b/proxypair.js
index 880f202..d230e76 100644
--- a/proxypair.js
+++ b/proxypair.js
@@ -45,11 +45,11 @@ class ProxyPair {
}
};
// OnDataChannel triggered remotely from the client when connection succeeds.
- return this.pc.ondatachannel = (dc) => {
+ this.pc.ondatachannel = (dc) => {
const channel = dc.channel;
dbg('Data Channel established...');
this.prepareDataChannel(channel);
- return this.client = channel;
+ this.client = channel;
};
}
@@ -76,7 +76,7 @@ class ProxyPair {
this.counted = true;
// This is the point when the WebRTC datachannel is done, so the next step
// is to establish websocket to the server.
- return this.connectRelay();
+ this.connectRelay();
};
channel.onclose = () => {
log('WebRTC DataChannel closed.');
@@ -86,13 +86,13 @@ class ProxyPair {
this.counted = false;
}
this.flush();
- return this.close();
+ this.close();
};
channel.onerror = function () {
- return log('Data channel error!');
+ log('Data channel error!');
};
channel.binaryType = "arraybuffer";
- return channel.onmessage = this.onClientToRelayMessage;
+ channel.onmessage = this.onClientToRelayMessage;
}
/** Assumes WebRTC datachannel is connected. */
@@ -122,7 +122,7 @@ class ProxyPair {
this.timer = 0;
}
log(relay.label + ' connected!');
- return snowflake.ui.setStatus('connected');
+ snowflake.ui.setStatus('connected');
};
this.relay.onclose = () => {
log(relay.label + ' closed.');
@@ -132,17 +132,17 @@ class ProxyPair {
this.counted = false;
}
this.flush();
- return this.close();
+ this.close();
};
this.relay.onerror = this.onError;
this.relay.onmessage = this.onRelayToClientMessage;
// TODO: Better websocket timeout handling.
- return this.timer = setTimeout((() => {
+ this.timer = setTimeout((() => {
if (0 === this.timer) {
return;
}
log(relay.label + ' timed out connecting.');
- return relay.onclose();
+ relay.onclose();
}), 5000);
}
@@ -161,20 +161,20 @@ class ProxyPair {
this.flush();
this.close();
}), this.config.messageTimeout);
- return this.flush();
+ this.flush();
}
/** websocket --> WebRTC */
onRelayToClientMessage(event) {
dbg('websocket --> WebRTC data: ' + event.data.byteLength + ' bytes');
this.r2cSchedule.push(event.data);
- return this.flush();
+ this.flush();
}
onError(event) {
const ws = event.target;
log(ws.label + ' error.');
- return this.close();
+ this.close();
}
/** Close both WebRTC and websocket. */
@@ -220,14 +220,14 @@ class ProxyPair {
const chunk = this.r2cSchedule.shift();
this.rateLimit.update(chunk.byteLength);
this.client.send(chunk);
- return busy = true;
+ busy = true;
}
};
while (busy && !this.rateLimit.isLimited()) {
checkChunks();
}
if (this.r2cSchedule.length > 0 || this.c2rSchedule.length > 0 || (this.relayIsReady() && this.relay.bufferedAmount > 0) || (this.webrtcIsReady() && this.client.bufferedAmount > 0)) {
- return this.flush_timeout_id = setTimeout(this.flush, this.rateLimit.when() * 1000);
+ this.flush_timeout_id = setTimeout(this.flush, this.rateLimit.when() * 1000);
}
}
diff --git a/util.js b/util.js
index bf73571..58d6512 100644
--- a/util.js
+++ b/util.js
@@ -95,7 +95,7 @@ class Util {
console.log('Signaling Server: exception while connecting: ' + error.message);
return reject('unable to connect to signaling server');
}
- return xhr.send(JSON.stringify(data));
+ xhr.send(JSON.stringify(data));
});
}
}
@@ -291,7 +291,7 @@ class BucketRateLimit {
this.lastUpdate = now;
this.amount -= delta * this.capacity / this.time;
if (this.amount < 0.0) {
- return this.amount = 0.0;
+ this.amount = 0.0;
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits