commit ba56727fad15316814a7caf4acee4e49c173b86c Author: Dmitry Eremin-Solenikov dbaryshkov@gmail.com Date: Thu Jul 3 12:27:19 2014 +0400
Use hashed fingerprints for all searches
It is possible to issue search to Onionoo using hashes of fingerprints and hashes of hashes of fingerprints. Thus always hash a fingerprint before searching. Onionoo will return correct results in any case.
Signed-off-by: Dmitry Eremin-Solenikov dbaryshkov@gmail.com --- js/router.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/js/router.js b/js/router.js index bd89f9e..92b2647 100644 --- a/js/router.js +++ b/js/router.js @@ -6,8 +6,9 @@ define([ 'views/details/main', 'views/search/main', 'views/search/do', - 'views/about/main' -], function($, _, Backbone, mainDetailsView, mainSearchView, doSearchView, aboutView){ + 'views/about/main', + 'jssha' +], function($, _, Backbone, mainDetailsView, mainSearchView, doSearchView, aboutView, jsSHA){ var AppRouter = Backbone.Router.extend({ routes: { // Define the routes for the actions in Atlas @@ -17,6 +18,14 @@ define([ // Default '*actions': 'defaultAction' }, + + hashFingerprints: function(fp){ + if (fp.match(/^[a-f0-9]{40}/i) != null) + return new jsSHA(fp, "HEX").getHash("SHA-1", "HEX").toUpperCase(); + else + return fp + }, + // Show the details page of a node mainDetails: function(fingerprint){
@@ -26,7 +35,7 @@ define([ $("#loading").show(); $("#content").hide();
- mainDetailsView.model.fingerprint = fingerprint; + mainDetailsView.model.fingerprint = this.hashFingerprints(fingerprint); mainDetailsView.model.lookup({ success: function(relay) { $("#content").show(); @@ -54,7 +63,8 @@ define([ if (query == "") { doSearchView.error(0); } else { - doSearchView.collection.url = doSearchView.collection.baseurl + query; + doSearchView.collection.url = + doSearchView.collection.baseurl + this.hashFingerprints(query); doSearchView.collection.lookup({ success: function(relays){ $("#content").show();
tor-commits@lists.torproject.org