From d66c8e97cad060f9f7479773b29f220ed49638d8 Mon Sep 17 00:00:00 2001 From: "Iain R. Learmonth" Date: Tue, 28 Nov 2017 22:11:35 +0000 Subject: [PATCH] Redirect all queries to Relay Search --- app.py | 58 +--------------- static/js/angularize.js | 86 ++++++++++-------------- templates/index.html | 173 ++++++++---------------------------------------- 3 files changed, 65 insertions(+), 252 deletions(-) diff --git a/app.py b/app.py index 8c04292..a25955f 100644 --- a/app.py +++ b/app.py @@ -123,63 +123,7 @@ def index(): @app.route('/result.json', methods=['GET']) def json_result(): - options = Opt(dict(request.args.items())) - - if "TESTING_DATAFILE" in app.config and "TESTING" in app.config: - stats = compass.RelayStats(options,app.config['TESTING_DATAFILE']) - else: - stats = compass.RelayStats(options) - - results = stats.select_relays(stats.relays, options) - - relays = stats.sort_and_reduce(results, - options) - - return Response(json.dumps(relays, cls=ResultEncoder), mimetype='application/json') - -@app.route('/result', methods=['GET']) -def result(): - options = Opt() - sort_key = None - relays = [] - - for key, value in request.args.items(): - if key == "top": - try: - options.top = int(value) - except: - options.top = -1 - elif key == "sort": - sort_key = value - elif key in ["country", "ases"]: - if value: - setattr(options, key, [value]) - else: - setattr(options, key, None) - elif key == "exits": - setattr(options, value, True) - else: - setattr(options, key, value) - - stats = compass.RelayStats(options) - sorted_groups = stats.format_and_sort_groups(stats.relays, - by_country=options.by_country, - by_as_number=options.by_as, - links=options.links) - output_string = stats.print_groups(sorted_groups, options.top, - by_country=options.by_country, - by_as_number=options.by_as, - short=None, - links=None) - results = parse(output_string, options.by_country or options.by_as, sort_key) - if sort_key: - for key in sorted(results.iterkeys(), reverse=True): - for value in results[key]: - relays.append(value) - else: - relays = results - - return render_template('result.html', results=relays, grouping=options.by_as or options.by_country) + return jsonify({"error": "The Compass service has been partially shut down. See https://trac.torproject.org/projects/tor/ticket/24445."}) if __name__ == '__main__': # Bind to PORT if defined, otherwise default to 5000. diff --git a/static/js/angularize.js b/static/js/angularize.js index 780e279..2fd04f5 100644 --- a/static/js/angularize.js +++ b/static/js/angularize.js @@ -11,11 +11,6 @@ compassModule.controller('CompassCtrl',function CompassCtrl($scope,$http,$locati $scope.state = "hidden" $scope.query = { - exit_filter:"all_relays", - links:true, - sort:'cw', - sort_reverse: true, - country: null } /** Watch the location bar to allow us to load saved searches **/ @@ -26,59 +21,48 @@ compassModule.controller('CompassCtrl',function CompassCtrl($scope,$http,$locati } }) - /** Make a sorting request - * - * Call 'success_cb' if the request is successful - */ - $scope.ajax_sort = function(sortBy, invert, success_cb) { - $scope.query.sort = sortBy - $scope.query.sort_reverse = invert - - //Update the location bar to track sorting - $location.search($scope.query) - - $http.get('result.json',{"params":$scope.query}) - .success(function(data) { - if (data.results.length > 0) { - $scope.data = data - - if (success_cb !== null){ - success_cb() - } - - $('body').animate({scrollTop:$("div#result_table").offset().top},500) - } - else { - $scope.state = "result_empty" - } - }) - - } - /** Make a data request from the form * * Call 'success_cb' if the request is successful */ $scope.request = function(success_cb) { - $scope.state = 'loading' + var rs_query = ""; + + if ((typeof $scope.query["country"]) !== "undefined" && $scope.query["country"] !== "") { + rs_query += "country:" + $scope.query["country"] + " "; + } + if ((typeof $scope.query["ases"]) !== "undefined" && $scope.query["ases"] !== "") { + rs_query += "as:" + $scope.query["ases"] + " "; + } + if ((typeof $scope.query["family"]) !== "undefined" && $scope.query["family"] !== "") { + rs_query += "family:" + $scope.query["family"] + " "; + } + if ((typeof $scope.query["exits_only"]) !== "undefined" && $scope.query["exits_only"] == true) { + rs_query += "flag:exit" + " "; + } else if ((typeof $scope.query["guards_only"]) !== "undefined" && $scope.query["guards_only"] == true) { + rs_query += "flag:guard" + " "; + } - //Set the location bar for this search - $location.search($scope.query) + var by_country = ((typeof $scope.query["by_country"]) !== "undefined" && $scope.query["by_country"] == true); + var by_as = ((typeof $scope.query["by_as"]) !== "undefined" && $scope.query["by_as"] == true); + + var rs_url = "https://atlas.torproject.org/"; + + if (!by_country) { + if (!by_as) { + rs_url += "#search/running:true " + rs_query.trim(); + } else { + rs_url += "#aggregate/as/" + rs_query.trim(); + } + } else { + if (!by_as) { + rs_url += "#aggregate/cc/" + rs_query.trim(); + } else { + rs_url += "#aggregate/ascc/" + rs_query.trim(); + } + } - $http.get('result.json',{"params":$scope.query}) - .success(function(data) { - if (data.results.length > 0) { - $scope.data = data - $scope.state = "loaded" - if (success_cb != null){ - success_cb() - } - $('body').animate({scrollTop:$("div#result_table").offset().top},500) - } - else { - $scope.state = "result_empty" - } - }) + document.location = rs_url; }; $scope.reset = function() { diff --git a/templates/index.html b/templates/index.html index 54d6137..8962dd6 100644 --- a/templates/index.html +++ b/templates/index.html @@ -68,28 +68,24 @@
-

The Tor Metrics team plans to shut down the Compass service at the - end of December 2017. Aggregated search functionality has been +

The Compass service has now been partially shut down. + Aggregated search functionality has been integrated into Relay Search (formerly known as Atlas) to give a unified tool for - exploring both single relays and aggregations of relays.

+ exploring both single relays and aggregations of relays. Any queries + made will redirect to Relay Search to display results.

Please ensure that all the functionality you require is available in Relay Search before Compass is shut down. If any functionality is missing, please file a ticket to request that it be added.

+

This search form will no longer be available from 15th January 2018.

Compass

Filter

- -
- -
- -
- - - - -

Group

@@ -158,8 +131,8 @@
- - group relays by AS +
@@ -168,8 +141,8 @@
- display only the top results (-1 for all) + placeholder="-1" value="-1" ng-model="query.top" disabled="disabled"> + limiting of results is disabled
@@ -180,111 +153,6 @@
-
-
-
-
-

No results found

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - Consensus Weights - Advertised BandwidthGuard Probability Middle Probability Exit ProbabilityNicknameFingerprintExitGuardCountryAutonomous System
{{ data.excluded.index }} {{ data.excluded.cw | number:4 }}% {{ data.excluded.adv_bw | number:4}}%{{ data.excluded.p_guard | number:4 }}%{{ data.excluded.p_middle | number:4 }}%{{ data.excluded.p_exit | number:4 }}%{{ data.excluded.nick }} {{data.excluded.fp }} {{ data.excluded.exit }}{{ data.excluded.guard }}{{ data.excluded.cc }}{{ data.excluded.as_info }}
{{ data.total.index }} {{ data.total.cw | number:4 }}% {{ data.total.adv_bw | number:4}}%{{ data.total.p_guard | number:4 }}%{{ data.total.p_middle | number:4 }}%{{ data.total.p_exit | number:4 }}%{{ data.total.nick }} {{data.total.fp }} {{ data.total.exit }}{{ data.total.guard }}{{ data.total.cc }}{{ data.total.as_info }}
{{ relay.index }} {{ relay.cw | number:4 }}% {{ relay.adv_bw | number:4}}%{{ relay.p_guard | number:4 }}%{{ relay.p_middle | number:4 }}%{{ relay.p_exit | number:4 }}%{{ relay.nick }} - - {{relay.fp | truncate:8:30}} - - {{relay.fp | truncate:8:30}} - {{ relay.exit }}{{ relay.guard }}{{ relay.cc }}{{ relay.as_info }}
-
-
-