[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [snowflake/master] Count the number of clients the webext has served
commit 85625e19f923a7f5eac071fcbafd2838525ac3fd
Author: Arlo Breault <arlolra@xxxxxxxxx>
Date: Wed Jun 19 16:02:12 2019 -0400
Count the number of clients the webext has served
---
proxy/ui.coffee | 14 ++++++++++++++
proxy/webext/popup.css | 1 +
proxy/webext/popup.html | 3 ++-
proxy/webext/popup.js | 6 ++++--
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/proxy/ui.coffee b/proxy/ui.coffee
index 0146abc..4148ea8 100644
--- a/proxy/ui.coffee
+++ b/proxy/ui.coffee
@@ -51,13 +51,26 @@ class DebugUI extends UI
class WebExtUI extends UI
port: null
+ stats: null
constructor: ->
+ @initStats()
chrome.runtime.onConnect.addListener @onConnect
+ initStats: ->
+ @stats = [0]
+ setInterval (() =>
+ @stats.unshift 0
+ @stats.splice 24
+ @postActive()
+ ), 60 * 60 * 1000
+
postActive: ->
@port?.postMessage
active: @active
+ total: @stats.reduce ((t, c) ->
+ t + c
+ ), 0
onConnect: (port) =>
@port = port
@@ -69,6 +82,7 @@ class WebExtUI extends UI
setActive: (connected) ->
super connected
+ if connected then @stats[0] += 1
@postActive()
chrome.browserAction.setIcon
path:
diff --git a/proxy/webext/popup.css b/proxy/webext/popup.css
index 8b3d5dc..dca805c 100644
--- a/proxy/webext/popup.css
+++ b/proxy/webext/popup.css
@@ -5,6 +5,7 @@ body {
#active {
padding: 2em;
text-align: center;
+ min-width: 128px;
}
.learn {
diff --git a/proxy/webext/popup.html b/proxy/webext/popup.html
index 3619b6c..6795b2e 100644
--- a/proxy/webext/popup.html
+++ b/proxy/webext/popup.html
@@ -8,7 +8,8 @@
<body>
<div id="active">
<img src="icons/status-off.png" />
- <p>Offline</p>
+ <p></p>
+ <p></p>
</div>
<div class="learn">
<a target="_blank" href="https://snowflake.torproject.org/">Learn more</a>
diff --git a/proxy/webext/popup.js b/proxy/webext/popup.js
index 9b68862..3869a5f 100644
--- a/proxy/webext/popup.js
+++ b/proxy/webext/popup.js
@@ -7,6 +7,8 @@ port.onMessage.addListener((m) => {
const div = document.getElementById('active');
const img = div.querySelector('img');
img.src = `icons/status-${active ? "on" : "off"}.png`;
- const p = div.querySelector('p');
- p.innerText = active ? "Connected" : "Offline";
+ const ps = div.querySelectorAll('p');
+ const clients = active ? 1 : 0;
+ ps[0].innerText = `${clients} client${(clients !== 1) ? 's' : ''} connected.`;
+ ps[1].innerText = `Your snowflake has helped ${m.total} user${(m.total !== 1) ? 's' : ''} circumvent censorship in the last 24 hours.`;
});
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits