[tor-commits] [torbutton/master] Bug 6254: Listen for TOR_TRANSPROXY env var to enable transproxy mode

mikeperry at torproject.org mikeperry at torproject.org
Wed Sep 12 19:24:09 UTC 2012


commit d7c7c5770640619d2433a4ef70f7364401b2abaa
Author: Mike Perry <mikeperry-git at fscked.org>
Date:   Tue Sep 11 19:17:30 2012 -0700

    Bug 6254: Listen for TOR_TRANSPROXY env var to enable transproxy mode
    
    Listen for the existence of the TOR_TRANSPROXY env var, and set prefs
    appropriately.
---
 src/chrome/content/torbutton_util.js |   23 +++++++++++++++++++----
 src/components/crash-observer.js     |   21 ++++++++++++++++++++-
 2 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/src/chrome/content/torbutton_util.js b/src/chrome/content/torbutton_util.js
index b6b4966..7d1effd 100644
--- a/src/chrome/content/torbutton_util.js
+++ b/src/chrome/content/torbutton_util.js
@@ -151,7 +151,14 @@ function torbutton_check_status() {
     else
          remote_dns = true;
 
-    return ((liveprefs.getIntPref("type")          == 1)              &&
+    var proxy_type = 1;
+    if (torprefs.getCharPref('settings_method') == 'transparent') {
+        remote_dns = true; // Hack. Transparent has remote_dns disabled
+        proxy_type = 0;
+    } 
+
+    return (
+         (liveprefs.getIntPref("type")          == proxy_type)              &&
          torbutton_log(1, "Type is true") &&
          (liveprefs.getCharPref("http")         == torprefs.getCharPref('http_proxy'))   &&
          torbutton_log(1, "Http proxy") &&
@@ -207,10 +214,18 @@ function torbutton_activate_tor_settings()
   liveprefs.setIntPref('socks_version', torprefs.getIntPref('socks_version'));
   liveprefs.setCharPref('no_proxies_on', torprefs.getCharPref('no_proxies_on'));
   liveprefs.setBoolPref('share_proxy_settings', false);
-  if (torbutton_check_socks_remote_dns()) {
-      liveprefs.setBoolPref('socks_remote_dns', true);
+
+  if (torprefs.getCharPref('settings_method') == 'transparent') {
+    liveprefs.setIntPref('type', 0);
+    if (torbutton_check_socks_remote_dns()) {
+        liveprefs.setBoolPref('socks_remote_dns', false);
+    }
+  } else {
+    liveprefs.setIntPref('type', 1);
+    if (torbutton_check_socks_remote_dns()) {
+        liveprefs.setBoolPref('socks_remote_dns', true);
+    }
   }
-  liveprefs.setIntPref('type', 1);
   torbutton_log(2, 'Done activating tor settings');
 }
 
diff --git a/src/components/crash-observer.js b/src/components/crash-observer.js
index ab97fba..5ecac6a 100644
--- a/src/components/crash-observer.js
+++ b/src/components/crash-observer.js
@@ -124,6 +124,12 @@ CrashObserver.prototype = {
                 parseInt(environ.get("TOR_SOCKS_PORT")));
         if (this.is_tbb) {
             this._prefs.setIntPref('network.proxy.socks_port', parseInt(environ.get("TOR_SOCKS_PORT")));
+
+            // XXX: Hack for TBB people who alternate between transproxy and non
+            this._prefs.setCharPref('extensions.torbutton.settings_method', 'recommended');
+            this._prefs.setBoolPref('extensions.torbutton.saved.transparentTor', false);
+            this._prefs.setBoolPref('network.proxy.socks_remote_dns', true);
+            this._prefs.setIntPref('network.proxy.type', 1);
         }
       } else if (this._prefs.getCharPref('extensions.torbutton.settings_method') == 'recommended') {
         this._prefs.setIntPref('extensions.torbutton.socks_port', 9050);
@@ -137,7 +143,20 @@ CrashObserver.prototype = {
       } else if (this._prefs.getCharPref('extensions.torbutton.settings_method') == 'recommended') {
         this._prefs.setCharPref('extensions.torbutton.socks_host', '127.0.0.1');
       }
- 
+
+      if (environ.exists("TOR_TRANSPROXY")) {
+        this.logger.log(3, "Resetting Tor settings to transproxy");
+        this._prefs.setCharPref('extensions.torbutton.settings_method', 'transparent');
+        this._prefs.setBoolPref('extensions.torbutton.saved.transparentTor', true);
+        this._prefs.setIntPref('extensions.torbutton.socks_port', 0);
+        this._prefs.setCharPref('extensions.torbutton.socks_host', "");
+        if (this.is_tbb) {
+            this._prefs.setBoolPref('network.proxy.socks_remote_dns', false);
+            this._prefs.setIntPref('network.proxy.type', 0);
+            this._prefs.setIntPref('network.proxy.socks_port', 0);
+            this._prefs.setCharPref('network.proxy.socks', "");
+        }
+      }
     },
 
     observe: function(subject, topic, data) {





More information about the tor-commits mailing list