test: Test that client picks the right HSDir for service.
This test is important because it tests that upload_descriptor_to_all()
is in synch with pick_hsdir_v3(). That's not the case for the
reachability test which just compares the responsible hsdir sets.
prop224: Pick the right hsdir index based on descriptor.
There was a bug in upload_descriptor_to_all() where we picked between
first and second hsdir index based on which time segment we are. That's
not right and instead we should be uploading our two descriptors using a
different hsdir index every time. That is, upload first descriptor using
first hsdir index, and upload second descriptor using second hdsir index.
Also simplify stuff in pick_hdsir_v3() since that's only used to fetch
descriptors and hence we can just always use the fetch hsdir index.
David Goulet [Thu, 7 Sep 2017 13:28:24 +0000 (09:28 -0400)]
test: Improve our rotation and build descriptor tests
Because of the latest changes on when we rotate, longer lifetime of
descriptors and no more overlap period, the tests needed to be improved to
test more functionnalities.
Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet [Thu, 7 Sep 2017 12:58:55 +0000 (08:58 -0400)]
test: Fix use out of scope and consensus timings
First, this fixes #23372.
Second, the consensus timings for the build descriptor have been changed to
the current test can pass. More extensive tests of descriptor rotation are
coming in a commit near you because the rotation and time period logic has
been changed.
Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet [Tue, 5 Sep 2017 16:02:16 +0000 (12:02 -0400)]
test: Add an HS v3 reachability unit test
This is a large and important unit test for the hidden service version
3! It tests the service reachability for a client using different
consensus timings and makes sure that the computed hashring is the same
on both side so it is actually reachable.
Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet [Wed, 6 Sep 2017 15:12:28 +0000 (11:12 -0400)]
prop224: Make client and service pick same HSDir
With the latest change on how we use the HSDir index, the client and service
need to pick their responsible HSDir differently that is depending on if they
are before or after a new time period.
The overlap mode is active function has been renamed for this and test added.
Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet [Tue, 5 Sep 2017 19:52:05 +0000 (15:52 -0400)]
prop224: Expand the overlap period concept to be a full SRV protocol run
Because of #23387, we've realized that there is one scenario that makes
the client unable to reach the service because of a desynch in the time
period used. The scenario is as follows:
In this scenario the HS has a newer consensus than the client, and the
HS just moved to the next TP but the client is still stuck on the old
one. However, the service is not in any sort of overlap mode so it
doesn't cover the old TP anymore, so the client is unable to fetch a
descriptor.
We've decided to solve this by extending the concept of overlap period
to be permanent so that the service always publishes two descriptors and
aims to cover clients with both older and newer consensuses. See the
spec patch in #23387 for more details.
David Goulet [Wed, 6 Sep 2017 14:25:21 +0000 (10:25 -0400)]
prop224: Use fetch and store HSDir indexes.
Based on our #23387 findings, it seems like to maintain 24/7
reachability we need to employ different logic when computing hsdir
indices for fetching vs storing. That's to guarantee that the client
will always fetch the current descriptor, while the service will always
publish two descriptors aiming to cover all possible edge cases.
For more details see the next commit and the spec branch.
Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet [Thu, 7 Sep 2017 18:24:49 +0000 (14:24 -0400)]
hs: Do not assert on rend_data while iterating over circuits
The pruning process and the deleting ephemeral service function iterates over
all circuits and were asserting on rend_data for a matching circuit. This is
not good because now we have v3 circuits without a rend_data.
Fixes #23429
Signed-off-by: David Goulet <dgoulet@torproject.org>
Nick Mathewson [Wed, 6 Sep 2017 18:23:47 +0000 (14:23 -0400)]
Better error on failure to load seccomp2 sandbox
There are two reasons this is likeliest to happen -- no kernel
support, and some bug in Tor. We'll ask people to check the former
before they report. Closes 23090.
Nick Mathewson [Wed, 6 Sep 2017 15:39:11 +0000 (11:39 -0400)]
Reject torrc if RunAsDaemon is given with relative paths.
The chdir() call in RunAsDaemon makes the behavior here surprising,
and either way of trying to resolve the surprise seems sure to
startle a significant fraction of users. Instead, let's refuse to
guess, and refuse these configurations.
Nick Mathewson [Sun, 20 Aug 2017 16:35:26 +0000 (12:35 -0400)]
Add stream isolation support for HTTP CONNECT tunnels
I'm doing this using the Proxy-Authorization: header to support
clients that understand it, and with a new tor-specific header that
makes more sense for our use.
Nick Mathewson [Tue, 8 Aug 2017 19:54:15 +0000 (15:54 -0400)]
Refactor buffer APIs to put a buf_t first.
By convention, a function that frobs a foo_t should be called
foo_frob, and it should have a foo_t * as its first argument. But
for many of the buf_t functions, the buf_t was the final argument,
which is silly.
Nick Mathewson [Tue, 8 Aug 2017 19:16:39 +0000 (15:16 -0400)]
Repair buffer API so everything starts with buf_.
Our convention is that functions which manipulate a type T should be
named T_foo. But the buffer functions were super old, and followed
all kinds of conventions. Now they're uniform.
Nick Mathewson [Tue, 8 Aug 2017 16:07:25 +0000 (12:07 -0400)]
Make buf_pullup() expose the pulled-up data.
This lets us drop the testing-only function buf_get_first_chunk_data(),
and lets us implement proto_http and proto_socks without looking at
buf_t internals.
David Goulet [Fri, 25 Aug 2017 18:03:15 +0000 (14:03 -0400)]
hs: Don't enter the HS v3 subsystem without a live consensus
The service needs the latest SRV and set of relays for the best accurate
hashring to upload its descriptor to so it needs a live consensus thus don't
do anything until we have it.
Fixes #23331
Signed-off-by: David Goulet <dgoulet@torproject.org>
David Goulet [Wed, 30 Aug 2017 12:34:02 +0000 (08:34 -0400)]
hs: Remove dead code and uneeded feature
When merging #20657, somehow hs_service_dir_info_changed() became unused
leading to not use the re-upload to HSDir when we were missing information
feature.
Turns out that it is not possible to pick an HSDir with a missing descriptor
because in order to compute the HSDir index, the descriptor is mandatory to
have so we can know its position on the hashring.
This commit removes that dead feature and fix the
hs_service_dir_info_changed() not being used.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Nick Mathewson [Mon, 4 Sep 2017 15:54:49 +0000 (11:54 -0400)]
22752: Improve comments to explain why we're doing this fix.
Based on questions and comments from dgoulet, I've tried to fill
in the reasoning about why these functions work in the way that they
do, so that it will be easier for future programmers to understand
why this code exists and works the way it does.
David Goulet [Thu, 31 Aug 2017 15:40:22 +0000 (11:40 -0400)]
hs: Set rendezvous circuit timestamp_dirty all the time
We used to check if it was set to 0 which is what unused circuit have but when
the rendezvous circuit was cannibalized, the timestamp_dirty is not 0 but we
still need to reset it so we can actually use it without having the chance of
expiring the next second (or very soon).
Fixes #23123
Signed-off-by: David Goulet <dgoulet@torproject.org>
prop224: Clear list of prev hsdirs before we upload all descs.
This fixes a serious bug in our hsdir set change logic:
We used to add nodes in the list of previous hsdirs everytime we
uploaded to a new hsdir and we only cleared the list when we built a new
descriptor. This means that our prev_hsdirs list could end up with 7
hsdirs, if for some reason we ended up uploading our desc to 7 hsdirs
before rebuilding our descriptor (e.g. this can happen if the set of
hsdirs changed).
After our previous hdsir set had 7 nodes, then our old algorithm would
always think that the set has changed since it was comparing a smartlist
with 7 elements against a smartlist with 6 elements.
This commit fixes this bug, by clearning the prev_hsdirs list before we
upload to all hsdirs. This makes sure that our prev_hsdirs list always
contains the latest hsdirs!
Our logic for detecting hsdir set changes was needlessly compicated: we
had to sort smartlists and compare them.
Instead, we can simplify things by employing the following logic:
"We should reupload our descriptor if the latest HSDir set contains
nodes that were not previously there"