commit 9f2e9a6ecb696149708716ca06ce842df03cf492 Author: Serene H git@keroserene.net Date: Wed Mar 1 19:09:24 2017 -0800
disable for TBB user agents. closes #37 --- proxy/snowflake.coffee | 7 ++++++- proxy/util.coffee | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/proxy/snowflake.coffee b/proxy/snowflake.coffee index 0279ad7..1f5674b 100644 --- a/proxy/snowflake.coffee +++ b/proxy/snowflake.coffee @@ -48,7 +48,7 @@ MODE = WEBRTC_CONNECTING: 1 WEBRTC_READY: 2
-CONFIRMATION_MESSAGE = "You're currently serving a Tor user via Snowflake." +CONFIRMATION_MESSAGE = 'You're currently serving a Tor user via Snowflake.'
# Minimum viable snowflake for now - just 1 client. class Snowflake @@ -222,8 +222,13 @@ snowflakeIsDisabled = -> if cookies[COOKIE_NAME] != '1' log 'Not opted-in. Please click the badge to change options.' return true + # Also do nothing if running in Tor Browser. + if mightBeTBB() + log 'Will not run within Tor Browser.' + return true return false
+ ### Entry point. ### diff --git a/proxy/util.coffee b/proxy/util.coffee index e0d965b..3e0a08c 100644 --- a/proxy/util.coffee +++ b/proxy/util.coffee @@ -5,6 +5,20 @@ Contains helpers for parsing query strings and other utilities. ###
+# It would not be effective for Tor Browser users to run the proxy. +# Do we seem to be running in Tor Browser? Check the user-agent string and for +# no listing of supported MIME types. +TBB_UAS = [ + 'Mozilla/5.0 (Windows NT 6.1; rv:10.0) Gecko/20100101 Firefox/10.0' + 'Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0' + 'Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0' + 'Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Firefox/31.0' +] +mightBeTBB = -> + return TBB_UAS.indexOf(window.navigator.userAgent) > -1 and + (window.navigator.mimeTypes and + window.navigator.mimeTypes.length == 0) + genSnowflakeID = -> Math.random().toString(36).substring(2)