mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 14:11:23 -04:00
Count the number of clients the webext has served
This commit is contained in:
parent
91255463c6
commit
85625e19f9
4 changed files with 21 additions and 3 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue