[tor-commits] [bridgedb/develop] Call schedule.intervalStart() to get epoch for HTTPS bridge request.
isis at torproject.org
isis at torproject.org
Wed May 28 21:50:18 UTC 2014
commit f73deeace636c2ce91d81fc16d9d0097708b35f0
Author: Isis Lovecruft <isis at torproject.org>
Date: Wed May 28 18:42:00 2014 +0000
Call schedule.intervalStart() to get epoch for HTTPS bridge request.
The ``epoch`` of a request is a value that is supposed to be the
interval of time which the request occurred within, i.e. a request at
14:18 is in the 10-minute interval of 14:10-14:20. This ``epoch`` is
used to obtain bridges in response to a client's request, specifically,
it's a parameter to the ``bridgedb.Dist.getBridgesForIP()`` method,
which does all the real work.
In implementation (up until a couple weeks ago), there was an odd thing
in that a request's ``epoch`` was always hardcoded to be ``"1970"``. I
changed the part which returns ``"1970"`` to return an ISO-8601
timestamp, under the assumtion that anything asking for an interval
would use the ``intervalStart()`` or ``nextIntervalStarts()`` methods to
compare the curr ent timestamp to the interval it should reside
within. My assumption was wrong; in ``bridgedb.Dist.getBridgesForIP()``,
in the first line of that method, ``schedule.getInterval()`` is called
instead. I had even made an XXX note a long time ago stating that this
was a dumb thing to do. I forgot to change it. Oops.
The fix is to change the first line of
``bridgedb.Dist.getBridgesForIP()`` from ``self.schedule.getInterval()``
to ``self.schedule.intervalStarts()` `. This was also preventing the
CAPTCHA expiration from functioning correctly.
After making this change, it exhibits the correct behaviour, which is,
first, to only respond after determining that we're within the 10-minute
interval in which the CAPTCHA was issued, and second, determine if the
solution to the CATPCHA is correct (and if so give the bridges that we
would give to that IP address cluster, ignoring time intervals
altogether).
* FIXES #12147
* THANKS to arma for forwarding to the original bug report to
tor-assistants at lists.torproject.org.
* THANKS TO Francisco on IRC for discovering and reporting the issue.
---
lib/bridgedb/HTTPServer.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index 9d76e28..6ece4d6 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -676,7 +676,7 @@ class WebResourceBridges(resource.Resource):
"""
# XXX why are we getting the interval if our distributor might be
# using bridgedb.schedule.Unscheduled?
- interval = self.schedule.getInterval(time.time())
+ interval = self.schedule.intervalStart(time.time())
bridges = ( )
ip = None
countryCode = None
More information about the tor-commits
mailing list