summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2014-07-03 12:27:19 +0400
committerDmitry Eremin-Solenikov <dbaryshkov@gmail.com>2014-07-10 02:12:28 +0400
commitba56727fad15316814a7caf4acee4e49c173b86c (patch)
treefbda57ff2e356a22efd0dc671ca05ca8730adf99
parent33c45776d7180a82e559f0efc8139c7de419cff7 (diff)
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>
-rw-r--r--js/router.js18
1 files 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();