[tor-commits] [torbutton/master] Bug 6156: Rate limit version check queries

mikeperry at torproject.org mikeperry at torproject.org
Fri Nov 16 03:54:21 UTC 2012


commit 1581678d45093f9ac08dd9e20152493a8fdaeddb
Author: Mike Perry <mikeperry-git at fscked.org>
Date:   Thu Nov 15 19:45:41 2012 -0800

    Bug 6156: Rate limit version check queries
    
    Patch from Pearl Crescent.
---
 src/chrome/content/torbutton.js |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/chrome/content/torbutton.js b/src/chrome/content/torbutton.js
index e629102..e305e4e 100644
--- a/src/chrome/content/torbutton.js
+++ b/src/chrome/content/torbutton.js
@@ -967,6 +967,23 @@ function torbutton_do_async_versioncheck() {
   if (!m_tb_tbb || !m_tb_prefs.getBoolPref("extensions.torbutton.versioncheck_enabled")) {
     return;
   }
+
+  // Suppress update check if done recently.
+  const kLastCheckPref = "extension.torbutton.lastUpdateCheck";
+  const kMinSecsBetweenChecks = 15 * 60; // 15 minutes
+  var now = Date.now() / 1000;
+  var lastCheckTime;
+  try {
+    lastCheckTime = parseFloat(m_tb_prefs.getCharPref(kLastCheckPref));
+    if (isNaN(lastCheckTime))
+      lastCheckTime = undefined;
+  } catch (e) {}
+
+  if (lastCheckTime && ((now - lastCheckTime) < kMinSecsBetweenChecks))
+    return;
+
+  m_tb_prefs.setCharPref(kLastCheckPref, now);
+
   torbutton_log(3, "Checking version with socks port: "
           +m_tb_prefs.getIntPref("extensions.torbutton.socks_port"));
   try {



More information about the tor-commits mailing list