[or-cvs] r20181: {torbutton} Create a protocol proxy filter to allow "localhost" to bypas (torbutton/trunk/src/chrome/content)

mikeperry at seul.org mikeperry at seul.org
Tue Jul 28 19:49:05 UTC 2009


Author: mikeperry
Date: 2009-07-28 15:49:04 -0400 (Tue, 28 Jul 2009)
New Revision: 20181

Modified:
   torbutton/trunk/src/chrome/content/torbutton.js
Log:

Create a protocol proxy filter to allow "localhost" to bypass
the proxy as opposed to using Firefox's logic. Based on patch
from optimist.



Modified: torbutton/trunk/src/chrome/content/torbutton.js
===================================================================
--- torbutton/trunk/src/chrome/content/torbutton.js	2009-07-28 06:32:58 UTC (rev 20180)
+++ torbutton/trunk/src/chrome/content/torbutton.js	2009-07-28 19:49:04 UTC (rev 20181)
@@ -2246,6 +2246,40 @@
 }
 }
 
+var torbutton_proxyservice = {
+  applyFilter : function(ps, uri, proxy) {
+    try {
+      torbutton_eclog(3, 'apply: '+uri.host+' '+uri.scheme+', '+proxy);
+      if (m_tb_prefs.getBoolPref("extensions.torbutton.tor_enabled")) {
+        if (uri.host == "localhost") return null;
+      }
+      return proxy;
+    }
+    catch (e) {
+      torbutton_eclog(3, 'applyFilter failed:' +e);
+    }
+  },
+  register : function() {
+    torbutton_eclog(3, 'Proxy filter Registering...');
+    try {
+    var proxyservice = Components.classes["@mozilla.org/network/protocol-proxy-service;1"]
+      .getService(Components.interfaces.nsIProtocolProxyService);
+    proxyservice.registerFilter(this, 0);
+    } catch (e) {
+      torbutton_eclog(3, 'RegisterFilter failed:'+e);
+    }
+  },
+  unregister : function() {
+    torbutton_eclog(3, 'Proxy filter Unregistering...');
+    try {
+    var proxyservice = Components.classes["@mozilla.org/network/protocol-proxy-service;1"]
+      .getService(Components.interfaces.nsIProtocolProxyService);
+    proxyservice.unregisterFilter(this, 0);
+    } catch (e) {
+      torbutton_eclog(3, 'UnregisterFilter failed:'+e);
+    }
+  }
+}
 
 function torbutton_do_main_window_startup()
 {
@@ -2266,6 +2300,7 @@
     torbutton_unique_pref_observer.register();
     torbutton_uninstall_observer.register();
     torbutton_http_observer.register();
+    torbutton_proxyservice.register();
 }
 
 function torbutton_set_initial_state() {
@@ -2529,6 +2564,7 @@
         torbutton_unique_pref_observer.unregister();
         torbutton_uninstall_observer.unregister();
         torbutton_http_observer.unregister();
+        torbutton_proxyservice.unregister();
 
         if(m_tb_is_main_window) { // main window not reset above
             // This happens on Mac OS because they allow firefox



More information about the tor-commits mailing list