[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Convert the director status into a property so the IP and ASN get's updated



commit c7970d24f0285e08a57a3b362889f308dbcdbf3c
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date:   Mon Aug 1 19:02:23 2016 +0200

    Convert the director status into a property so the IP and ASN get's updated
    
    * Make another call to resolveGeodata after we fetch the inputs
    
    (this should fix the issue @agrabeli reported in erroneous IP lookups)
---
 ooni/agent/scheduler.py |  1 +
 ooni/ui/web/server.py   | 22 ++++++++++++----------
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/ooni/agent/scheduler.py b/ooni/agent/scheduler.py
index 0d8689c..a6d689f 100644
--- a/ooni/agent/scheduler.py
+++ b/ooni/agent/scheduler.py
@@ -84,6 +84,7 @@ class UpdateInputsAndResources(ScheduledTask):
         yield probe_ip.lookup()
         yield resources.check_for_update(probe_ip.geodata['countrycode'])
         yield input_store.update(probe_ip.geodata['countrycode'])
+        yield probe_ip.resolveGeodata()
 
 
 class UploadReports(ScheduledTask):
diff --git a/ooni/ui/web/server.py b/ooni/ui/web/server.py
index 50db3ad..a03daa4 100644
--- a/ooni/ui/web/server.py
+++ b/ooni/ui/web/server.py
@@ -127,13 +127,7 @@ class WebUIAPI(object):
         self._xsrf_token = ''.join([rng.choice(token_space)
                                     for _ in range(30)])
 
-        self.status = {
-            "software_version": ooniprobe_version,
-            "software_name": "ooniprobe",
-            "asn": probe_ip.geodata['asn'],
-            "country_code": probe_ip.geodata['countrycode'],
-            "director_started": False
-        }
+        self._director_started = False
 
         self.status_poller = LongPoller(
             self._long_polling_timeout, _reactor)
@@ -150,14 +144,22 @@ class WebUIAPI(object):
         d.addCallback(self.director_started)
         d.addBoth(lambda _: self.status_poller.notify())
 
+    @property
+    def status(self):
+        return {
+            "software_version": ooniprobe_version,
+            "software_name": "ooniprobe",
+            "asn": probe_ip.geodata['asn'],
+            "country_code": probe_ip.geodata['countrycode'],
+            "director_started": self._director_started
+        }
+
     def handle_director_event(self, event):
         log.msg("Handling event {0}".format(event.type))
         self.director_event_poller.notify(event)
 
     def director_started(self, _):
-        self.status['director_started'] = True
-        self.status["asn"] = probe_ip.geodata['asn']
-        self.status["country_code"] = probe_ip.geodata['countrycode']
+        self._director_started = True
 
     @app.handle_errors(NotFound)
     @xsrf_protect(check=False)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits