@@ -13,7 +13,7 @@ INFO=3;
1313NOTE = 4 ;
1414WARN = 5 ;
1515
16- // XXX: We should make the _observatory_prefs tree relative.
16+ // XXX: We should make the _observatory tree relative.
1717LLVAR = "extensions.https_everywhere.LogLevel" ;
1818
1919Components . utils . import ( "resource://gre/modules/XPCOMUtils.jsm" ) ;
@@ -84,23 +84,8 @@ function SSLObservatory() {
8484 this . wrappedJSObject = this ;
8585
8686 this . client_asn = - 1 ;
87- this . getClientASN ( ) ;
88-
89- this . max_ap = null ;
90-
91- // Observe network changes to get new ASNs
92- OS . addObserver ( this , "network:offline-status-changed" , false ) ;
93- var pref_service = Cc [ "@mozilla.org/preferences-service;1" ]
94- . getService ( Ci . nsIPrefBranchInternal ) ;
95- proxy_branch = pref_service . QueryInterface ( Ci . nsIPrefBranchInternal ) ;
96- proxy_branch . addObserver ( "network.proxy" , this , false ) ;
97-
98- try {
99- var wifi_service = Cc [ "@mozilla.org/wifi/monitor;1" ] . getService ( Ci . nsIWifiMonitor ) ;
100- wifi_service . startWatching ( this ) ;
101- } catch ( e ) {
102- this . log ( INFO , "Failed to register ASN change monitor: " + e ) ;
103- }
87+ if ( this . prefs . getBoolPref ( "extensions.https_everywhere._observatory.send_asn" ) )
88+ this . setupASNWatcher ( ) ;
10489
10590 this . log ( DBUG , "Loaded observatory component!" ) ;
10691}
@@ -145,6 +130,31 @@ SSLObservatory.prototype = {
145130 }
146131 } ,
147132
133+ setupASNWatcher : function ( ) {
134+ this . getClientASN ( ) ;
135+
136+ this . max_ap = null ;
137+
138+ // Observe network changes to get new ASNs
139+ OS . addObserver ( this , "network:offline-status-changed" , false ) ;
140+ var pref_service = Cc [ "@mozilla.org/preferences-service;1" ]
141+ . getService ( Ci . nsIPrefBranchInternal ) ;
142+ proxy_branch = pref_service . QueryInterface ( Ci . nsIPrefBranchInternal ) ;
143+ proxy_branch . addObserver ( "network.proxy" , this , false ) ;
144+
145+ try {
146+ var wifi_service = Cc [ "@mozilla.org/wifi/monitor;1" ] . getService ( Ci . nsIWifiMonitor ) ;
147+ wifi_service . startWatching ( this ) ;
148+ } catch ( e ) {
149+ this . log ( INFO , "Failed to register ASN change monitor: " + e ) ;
150+ }
151+ } ,
152+
153+ stopASNWatcher : function ( ) {
154+ // XXX FIXME need to unhook the observers above, or do something more crude...
155+ this . client_asn = - 1 ;
156+ } ,
157+
148158 getClientASN : function ( ) {
149159 // XXX: Fetch a new client ASN..
150160 return ;
@@ -210,15 +220,15 @@ SSLObservatory.prototype = {
210220 if ( this . torbutton_installed ) {
211221 // Allow Tor users to choose if they want to submit
212222 // during tor and/or non-tor
213- if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .submit_during_tor" )
223+ if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory .submit_during_tor" )
214224 && this . prefs . getBoolPref ( "extensions.torbutton.tor_enabled" ) ) {
215225 return ;
216226 }
217- if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .submit_during_nontor" )
227+ if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory .submit_during_nontor" )
218228 && ! this . prefs . getBoolPref ( "extensions.torbutton.tor_enabled" ) ) {
219229 return ;
220230 }
221- } else if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .use_custom_proxy" ) ) {
231+ } else if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory .use_custom_proxy" ) ) {
222232 this . log ( WARN , "No torbutton installed, but no custom proxies either. Not submitting certs" ) ;
223233 return ;
224234 }
@@ -256,14 +266,15 @@ SSLObservatory.prototype = {
256266 }
257267 }
258268
259- if ( rootidx == - 1 || ( fps . length > 1 && ! ( fps [ rootidx ] in this . public_roots ) ) ) {
260- if ( rootidx == - 1 ) {
261- rootidx = fps . length - 1 ;
269+ if ( ! this . prefs . getBoolPref ( "extensions.https_everywhere._observatory.alt_roots" ) )
270+ if ( rootidx == - 1 || ( fps . length > 1 && ! ( fps [ rootidx ] in this . public_roots ) ) ) {
271+ if ( rootidx == - 1 ) {
272+ rootidx = fps . length - 1 ;
273+ }
274+ this . log ( INFO , "Got a private root cert. Ignoring domain "
275+ + domain + " with root " + fps [ rootidx ] ) ;
276+ return ;
262277 }
263- this . log ( INFO , "Got a private root cert. Ignoring domain "
264- + domain + " with root " + fps [ rootidx ] ) ;
265- return ;
266- }
267278
268279 if ( fps [ 0 ] in this . already_submitted ) {
269280 this . log ( INFO , "Already submitted cert for " + domain + ". Ignoring" ) ;
@@ -289,7 +300,7 @@ SSLObservatory.prototype = {
289300 var reqParams = [ ] ;
290301 reqParams . push ( "domain=" + domain ) ;
291302 reqParams . push ( "server_ip=-1" ) ;
292- if ( this . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .testing" ) ) {
303+ if ( this . prefs . getBoolPref ( "extensions.https_everywhere._observatory .testing" ) ) {
293304 // The server can compute these, but they're a nice test suite item!
294305 reqParams . push ( "fplist=" + this . compatJSON . encode ( fps ) ) ;
295306 }
@@ -339,7 +350,7 @@ SSLObservatory.prototype = {
339350 // XXX: Handle errors properly?
340351 if ( req . status == 200 ) {
341352 that . log ( INFO , "Successful cert submission" ) ;
342- if ( ! that . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .cache_submitted" ) ) {
353+ if ( ! that . prefs . getBoolPref ( "extensions.https_everywhere._observatory .cache_submitted" ) ) {
343354 if ( fps [ 0 ] in that . already_submitted )
344355 delete that . already_submitted [ fps [ 0 ] ] ;
345356 }
@@ -363,7 +374,7 @@ SSLObservatory.prototype = {
363374 getProxySettings : function ( ) {
364375 var proxy_settings = [ "direct" , "" , 0 ] ;
365376 if ( this . torbutton_installed &&
366- this . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .use_tor_proxy" ) ) {
377+ this . prefs . getBoolPref ( "extensions.https_everywhere._observatory .use_tor_proxy" ) ) {
367378 // extract torbutton proxy settings
368379 proxy_settings [ 0 ] = "http" ;
369380 proxy_settings [ 1 ] = this . prefs . getCharPref ( "extensions.torbutton.https_proxy" ) ;
@@ -374,10 +385,10 @@ SSLObservatory.prototype = {
374385 proxy_settings [ 1 ] = this . prefs . getCharPref ( "extensions.torbutton.socks_host" ) ;
375386 proxy_settings [ 2 ] = this . prefs . getIntPref ( "extensions.torbutton.socks_port" ) ;
376387 }
377- } else if ( this . prefs . getBoolPref ( "extensions.https_everywhere._observatory_prefs .use_custom_proxy" ) ) {
378- proxy_settings [ 0 ] = this . prefs . getCharPref ( "extensions.https_everywhere._observatory_prefs .proxy_type" ) ;
379- proxy_settings [ 1 ] = this . prefs . getCharPref ( "extensions.https_everywhere._observatory_prefs .proxy_host" ) ;
380- proxy_settings [ 2 ] = this . prefs . getIntPref ( "extensions.https_everywhere._observatory_prefs .proxy_port" ) ;
388+ } else if ( this . prefs . getBoolPref ( "extensions.https_everywhere._observatory .use_custom_proxy" ) ) {
389+ proxy_settings [ 0 ] = this . prefs . getCharPref ( "extensions.https_everywhere._observatory .proxy_type" ) ;
390+ proxy_settings [ 1 ] = this . prefs . getCharPref ( "extensions.https_everywhere._observatory .proxy_host" ) ;
391+ proxy_settings [ 2 ] = this . prefs . getIntPref ( "extensions.https_everywhere._observatory .proxy_port" ) ;
381392 } else {
382393 this . log ( WARN , "Proxy settings are strange: No Torbutton found, but no proxy specified. Using direct." ) ;
383394 }
0 commit comments