@@ -26,6 +26,7 @@ LLVAR="extensions.https_everywhere.LogLevel";
2626Components . utils . import ( "resource://gre/modules/XPCOMUtils.jsm" ) ;
2727Components . utils . import ( "resource://gre/modules/ctypes.jsm" ) ;
2828
29+
2930const OS = Cc [ '@mozilla.org/observer-service;1' ] . getService ( CI . nsIObserverService ) ;
3031
3132const SERVICE_CTRID = "@eff.org/ssl-observatory;1" ;
@@ -72,6 +73,9 @@ function SSLObservatory() {
7273 * This is for UI notification purposes */
7374 this . proxy_test_successful = null ;
7475 this . proxy_test_callback = null ;
76+ this . cto_url = "https://check.torproject.org/?TorButton=true" ;
77+ // a regexp to match the above URL
78+ this . cto_search = "^https://check.torproject.org/" ;
7579
7680 this . public_roots = root_ca_hashes ;
7781
@@ -676,7 +680,7 @@ SSLObservatory.prototype = {
676680 try {
677681 var req = Components . classes [ "@mozilla.org/xmlextras/xmlhttprequest;1" ]
678682 . createInstance ( Components . interfaces . nsIXMLHttpRequest ) ;
679- var url = "https://check.torproject.org/?TorButton=true" + this . csrf_nonce ;
683+ var url = this . cto_url + this . csrf_nonce ;
680684 req . open ( 'GET' , url , true ) ;
681685 req . channel . loadFlags |= Ci . nsIRequest . LOAD_BYPASS_CACHE ;
682686 req . overrideMimeType ( "text/xml" ) ;
@@ -730,7 +734,9 @@ SSLObservatory.prototype = {
730734
731735 getProxySettings : function ( ) {
732736 var proxy_settings = [ "direct" , "" , 0 ] ;
737+ this . log ( INFO , "in getProxySettings()" ) ;
733738 if ( this . torbutton_installed && this . myGetBoolPref ( "use_tor_proxy" ) ) {
739+ this . log ( INFO , "CASE: use_tor_proxy" ) ;
734740 // extract torbutton proxy settings
735741 proxy_settings [ 0 ] = "http" ;
736742 proxy_settings [ 1 ] = this . prefs . getCharPref ( "extensions.torbutton.https_proxy" ) ;
@@ -745,43 +751,58 @@ SSLObservatory.prototype = {
745751 /* XXX: Should we have a separate pref for use_direct? Or should "direct" be a subcase of custom
746752 * proxy hardcoded by the UI? Assuming the latter for now.
747753 */
754+ this . log ( INFO , "CASE: use_custom_proxy" ) ;
748755 proxy_settings [ 0 ] = this . prefs . getCharPref ( "extensions.https_everywhere._observatory.proxy_type" ) ;
749756 proxy_settings [ 1 ] = this . prefs . getCharPref ( "extensions.https_everywhere._observatory.proxy_host" ) ;
750757 proxy_settings [ 2 ] = this . prefs . getIntPref ( "extensions.https_everywhere._observatory.proxy_port" ) ;
751758 } else {
752759 /* Take a guess at default tor proxy settings */
760+ this . log ( INFO , "CASE: try localhost:9050" ) ;
753761 proxy_settings [ 0 ] = "socks" ;
754762 proxy_settings [ 1 ] = "localhost" ;
755763 proxy_settings [ 2 ] = 9050 ;
756764 }
757765 return proxy_settings ;
758766 } ,
759767
760- applyFilter : function ( aProxyService , aURI , aProxy ) {
761- if ( aURI . spec . search ( "^" + this . submit_url ) != - 1 &&
762- aURI . path . search ( this . csrf_nonce + "$" ) != - 1 ) {
763-
764- this . log ( INFO , "Got observatory url + nonce: " + aURI . spec ) ;
765- var proxy_settings = null ;
766- var proxy = null ;
768+ applyFilter : function ( aProxyService , inURI , aProxy ) {
767769
768- // Send it through tor by creating an nsIProxy instance
769- // for the torbutton proxy settings.
770- try {
771- proxy_settings = this . getProxySettings ( ) ;
772- proxy = this . pps . newProxyInfo ( proxy_settings [ 0 ] , proxy_settings [ 1 ] ,
773- proxy_settings [ 2 ] ,
774- Ci . nsIProxyInfo . TRANSPARENT_PROXY_RESOLVES_HOST ,
775- 0xFFFFFFFF , null ) ;
776- } catch ( e ) {
777- this . log ( WARN , "Error specifying proxy for observatory: " + e ) ;
770+ try {
771+ if ( inURI instanceof Ci . nsIURI ) {
772+ var aURI = inURI . QueryInterface ( Ci . nsIURI ) ;
773+ if ( ! aURI ) this . log ( WARN , "Failed to QI to nsIURI!" ) ;
774+ } else {
775+ this . log ( WARN , "applyFilter called without URI" ) ;
778776 }
777+ } catch ( e ) {
778+ this . log ( WARN , "EXPLOSION: " + e ) ;
779+ }
779780
780- this . log ( INFO , "Specifying proxy: " + proxy ) ;
781+ if ( aURI . spec . search ( "^" + this . submit_url ) != - 1 || aURI . spec . search ( this . cto_search ) != - 1 ) {
782+ if ( aURI . path . search ( this . csrf_nonce + "$" ) != - 1 ) {
783+
784+ this . log ( INFO , "Got observatory url + nonce: " + aURI . spec ) ;
785+ var proxy_settings = null ;
786+ var proxy = null ;
787+
788+ // Send it through tor by creating an nsIProxy instance
789+ // for the torbutton proxy settings.
790+ try {
791+ proxy_settings = this . getProxySettings ( ) ;
792+ proxy = this . pps . newProxyInfo ( proxy_settings [ 0 ] , proxy_settings [ 1 ] ,
793+ proxy_settings [ 2 ] ,
794+ Ci . nsIProxyInfo . TRANSPARENT_PROXY_RESOLVES_HOST ,
795+ 0xFFFFFFFF , null ) ;
796+ } catch ( e ) {
797+ this . log ( WARN , "Error specifying proxy for observatory: " + e ) ;
798+ }
781799
782- // TODO: Use new identity or socks u/p to ensure we get a unique
783- // tor circuit for this request
784- return proxy ;
800+ this . log ( INFO , "Specifying proxy: " + proxy ) ;
801+
802+ // TODO: Use new identity or socks u/p to ensure we get a unique
803+ // tor circuit for this request
804+ return proxy ;
805+ }
785806 }
786807 return aProxy ;
787808 } ,
0 commit comments