]> git.ipfire.org Git - thirdparty/tor.git/log
thirdparty/tor.git
8 years agohs: Move link specifier encoding to a function
David Goulet [Tue, 18 Jul 2017 17:56:19 +0000 (13:56 -0400)] 
hs: Move link specifier encoding to a function

This commit only moves code into a function. The client code will need a way
to take a bunch of descriptor link specifier object and encode them into link
specifiers objects.

Make this a public function so it can be used outside of hs_descriptor.c.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoconn: Add a function to return a list of connection by state
David Goulet [Tue, 18 Jul 2017 15:41:41 +0000 (11:41 -0400)] 
conn: Add a function to return a list of connection by state

This will be useful to the hidden service subsystem that needs to go over all
connections of a certain state to attach them to a hidden service circuit.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Add tests for fetching descs and handling SOCKS conns.
George Kadianakis [Thu, 1 Jun 2017 11:35:39 +0000 (14:35 +0300)] 
test: Add tests for fetching descs and handling SOCKS conns.

- Add tests that ensure that SOCKS requests for v2/v3 addresses get
  intercepted and handled.

- Add test that stores and lookups an HS descriptor in the client-side cache.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agohs: Fix comment of the get max size descriptor function
David Goulet [Tue, 27 Jun 2017 13:28:15 +0000 (09:28 -0400)] 
hs: Fix comment of the get max size descriptor function

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Rename hs_client_note_connection_attempt_succeeded()
David Goulet [Wed, 28 Jun 2017 18:20:28 +0000 (14:20 -0400)] 
prop224: Rename hs_client_note_connection_attempt_succeeded()

This is a static function so don't polute the hs_client_ namespace.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Add the dir purpose HAS_FETCHED
David Goulet [Tue, 27 Jun 2017 13:46:16 +0000 (09:46 -0400)] 
prop224: Add the dir purpose HAS_FETCHED

Once a descriptor has been successfully downloaded from an HSDir, we flag the
directory connection to "has fetched descriptor" so the connection subsystem
doesn't trigger a new fetch on success.

Same has DIR_PURPOSE_HAS_FETCHED_RENDDESC_V2 but for prop224.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Add client code to handle fetched HS descriptors.
George Kadianakis [Thu, 1 Jun 2017 11:25:46 +0000 (14:25 +0300)] 
prop224: Add client code to handle fetched HS descriptors.

This code handles received HS descriptors by storing them in the
client-side HS cache.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Introduce v2/v3 HS desc fetch retry functionality.
George Kadianakis [Thu, 1 Jun 2017 11:22:17 +0000 (14:22 +0300)] 
prop224: Introduce v2/v3 HS desc fetch retry functionality.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Connect to v3 services in connection_ap_handle_onion().
George Kadianakis [Thu, 1 Jun 2017 11:17:49 +0000 (14:17 +0300)] 
prop224: Connect to v3 services in connection_ap_handle_onion().

Recognize and handle v3 addresses.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Add code that launches v3 HS desc fetches.
George Kadianakis [Thu, 1 Jun 2017 11:12:33 +0000 (14:12 +0300)] 
prop224: Add code that launches v3 HS desc fetches.

Entry point is hs_client_refetch_v3_renddesc().

Will be used in subsequent commits.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Refactor pick_hsdir() to be used by both v2 and v3.
George Kadianakis [Thu, 1 Jun 2017 11:07:53 +0000 (14:07 +0300)] 
prop224: Refactor pick_hsdir() to be used by both v2 and v3.

Also refactor rendclient.c to use the new hs_pick_hdsir() func.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Refactor rendclient.c to use the new hsdir_req code.
George Kadianakis [Thu, 1 Jun 2017 11:01:48 +0000 (14:01 +0300)] 
prop224: Refactor rendclient.c to use the new hsdir_req code.

- Also add tests for the hidserv_req subsystem.
- Introduce purge_v2_hidserv_req() wrapper to simplify v2 code.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Fix hidserv request code to work for both v2 and v3.
George Kadianakis [Thu, 1 Jun 2017 10:56:43 +0000 (13:56 +0300)] 
prop224: Fix hidserv request code to work for both v2 and v3.

See documentation of `last_hid_serv_requests_` for how it works. strmaps are
cool!

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Move some rendclient.c code to hs_common.c
George Kadianakis [Thu, 1 Jun 2017 10:48:03 +0000 (13:48 +0300)] 
prop224: Move some rendclient.c code to hs_common.c

Specifically move the pick_hsdir() function and all the HSDir request tracking
code. We plan to use all that code both for v2 and v3.

This commit only moves code.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Add client-side HS descriptor cache.
George Kadianakis [Thu, 1 Jun 2017 10:37:11 +0000 (13:37 +0300)] 
prop224: Add client-side HS descriptor cache.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Decouple the HS part of connection_ap_handshake_rewrite_and_attach().
George Kadianakis [Thu, 1 Jun 2017 10:24:28 +0000 (13:24 +0300)] 
prop224: Decouple the HS part of connection_ap_handshake_rewrite_and_attach().

We will need to edit this function, and it's already pretty huge. Let's make
it a bit smaller.

This commit moves code, fixes a 80 char line and add two lines at the start to
make it compile. Trivial change.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Refactor parse_extended_hostname() to parse v3 addrs.
George Kadianakis [Thu, 1 Jun 2017 10:21:03 +0000 (13:21 +0300)] 
prop224: Refactor parse_extended_hostname() to parse v3 addrs.

We need this func so that we recognize SOCKS conns to v3 addresses.

- Also rename rend_valid_service_id() to rend_valid_v2_service_id()

- Also move parse_extended_hostname() tests to their own unittest, and
  add a v3 address to the test as well.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Recompute all HSDir indices when we enter overlap mode.
George Kadianakis [Sat, 19 Aug 2017 13:00:58 +0000 (16:00 +0300)] 
prop224: Recompute all HSDir indices when we enter overlap mode.

When we enter overlap mode we start using the next hsdir index of
relays. However, we only compute the next hsdir index of relays when we
receive a consensus or their descriptor. This means that there is a
window of time between entering the overlap period and fetching the
consensus where relays have their next hsdir index uninitialized. This
patch fixes this by recomputing all hsdir indices when we first enter
the overlap period.

8 years agoprop224: Improve descriptor reupload logic.
George Kadianakis [Sat, 19 Aug 2017 13:26:46 +0000 (16:26 +0300)] 
prop224: Improve descriptor reupload logic.

We want to reupload our descriptor if its set of responsible HSDirs
changed to minimize reachability issues.

This patch adds a callback everytime we get new dirinfo which checks if
the hash ring changed and reuploads descriptor if needed.

8 years agotest: Improve get_responsible_hsdirs test.
George Kadianakis [Sun, 13 Aug 2017 20:25:08 +0000 (23:25 +0300)] 
test: Improve get_responsible_hsdirs test.

8 years agoprop224: Only upload descriptor if we have good hash ring and SRV.
George Kadianakis [Sun, 13 Aug 2017 17:16:21 +0000 (20:16 +0300)] 
prop224: Only upload descriptor if we have good hash ring and SRV.

Make sure we have a live consensus (for SRV) and enough descriptors (for
hash ring).

Also fix unittests that broke.

8 years agoprop224: Improve our checks for unset HSDir index.
George Kadianakis [Sat, 12 Aug 2017 10:05:25 +0000 (13:05 +0300)] 
prop224: Improve our checks for unset HSDir index.

We used to not check next hsdir index.

8 years agosr: Log voting schedule at debug level
David Goulet [Wed, 9 Aug 2017 15:25:53 +0000 (11:25 -0400)] 
sr: Log voting schedule at debug level

Because the HS subsystem calls it every second, change the log level to debug
so it doesn't spam the info log.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoMake Windows happy for time_t printf format
David Goulet [Fri, 11 Aug 2017 19:08:45 +0000 (15:08 -0400)] 
Make Windows happy for time_t printf format

Our Windows compiler treats "time_t" as long long int but Linux likes it
long int so cast those to make Windows happy.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Fix typing issues found by clang
David Goulet [Fri, 11 Aug 2017 18:59:28 +0000 (14:59 -0400)] 
test: Fix typing issues found by clang

Partially fix #23224.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Fix memory leak in test_hs_common.c
David Goulet [Fri, 11 Aug 2017 18:46:27 +0000 (14:46 -0400)] 
test: Fix memory leak in test_hs_common.c

Partially fixes #23223

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Fix hs common test for Windows
David Goulet [Fri, 11 Aug 2017 18:42:20 +0000 (14:42 -0400)] 
test: Fix hs common test for Windows

Use the PATH_SEPARATOR for a path comparaison so it works with Windows as
well.

Partially fix #23223

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoMerge branch 'ticket23220'
Nick Mathewson [Fri, 11 Aug 2017 18:08:26 +0000 (14:08 -0400)] 
Merge branch 'ticket23220'

8 years agoRaise MIN_DL_PER_REQUEST to 32
Nick Mathewson [Fri, 11 Aug 2017 17:54:01 +0000 (13:54 -0400)] 
Raise MIN_DL_PER_REQUEST to 32

This change should improve overhead for downloading small numbers of
descriptors and microdescriptors by improving compression
performance and lowering directory request overhead.

Closes ticket 23220.

8 years agoMerge branch 'bug18982'
Nick Mathewson [Fri, 11 Aug 2017 16:11:42 +0000 (12:11 -0400)] 
Merge branch 'bug18982'

8 years agoAdd # to "hop N" messages to disambiguate from old messages.
Nick Mathewson [Fri, 11 Aug 2017 16:11:27 +0000 (12:11 -0400)] 
Add # to "hop N" messages to disambiguate from old messages.

8 years agoMerge branch 'maint-0.3.1'
Nick Mathewson [Fri, 11 Aug 2017 15:51:06 +0000 (11:51 -0400)] 
Merge branch 'maint-0.3.1'

8 years agoMerge remote-tracking branch 'dgoulet/bug23091_032_01'
Nick Mathewson [Fri, 11 Aug 2017 13:39:57 +0000 (09:39 -0400)] 
Merge remote-tracking branch 'dgoulet/bug23091_032_01'

8 years agofix description of PublishServerDescriptor
Roger Dingledine [Wed, 9 Aug 2017 19:07:49 +0000 (15:07 -0400)] 
fix description of PublishServerDescriptor

the values of "v3" and "bridge" have to do with *where* you publish to,
not whether you publish.

8 years agoDocument all the arguments of PublishServerDescriptor.
Nick Mathewson [Wed, 9 Aug 2017 15:17:27 +0000 (11:17 -0400)] 
Document all the arguments of PublishServerDescriptor.

Implements 15645.

8 years agofix another 32-bit warning
Nick Mathewson [Wed, 9 Aug 2017 12:32:39 +0000 (08:32 -0400)] 
fix another 32-bit warning

8 years agoFix a warning on 32-bit clang
Nick Mathewson [Wed, 9 Aug 2017 12:31:44 +0000 (08:31 -0400)] 
Fix a warning on 32-bit clang

8 years agoprop224: Fix coverity warnings from #20657 merge.
George Kadianakis [Wed, 9 Aug 2017 10:45:37 +0000 (13:45 +0300)] 
prop224: Fix coverity warnings from #20657 merge.

- Fix various ssize_t/size_t confusions in the tests.

- Fix a weird memset argument:
  "bad_memset: Argument -16 in memset loses precision in
  memset(&desc_two->blinded_kp.pubkey.pubkey, -16, 32UL)."

- Fix check_after_deref instance in check_state_line_for_service_rev_counter():
  "check_after_deref: Null-checking items suggests that it may be null,
  but it has already been dereferenced on all paths leading to the
  check."

8 years agoRe-run trunnel.
Nick Mathewson [Wed, 9 Aug 2017 00:34:39 +0000 (20:34 -0400)] 
Re-run trunnel.

8 years agoMerge branch 'ticket20657_nickm_bugfixes_squashed'
Nick Mathewson [Wed, 9 Aug 2017 00:31:57 +0000 (20:31 -0400)] 
Merge branch 'ticket20657_nickm_bugfixes_squashed'

8 years agoPut comment in the trunnel file, so it wont go away.
Nick Mathewson [Wed, 9 Aug 2017 00:31:47 +0000 (20:31 -0400)] 
Put comment in the trunnel file, so it wont go away.

8 years agoprop224: Add XXX about opaqueness of link_specifier_t.
George Kadianakis [Tue, 8 Aug 2017 18:25:04 +0000 (21:25 +0300)] 
prop224: Add XXX about opaqueness of link_specifier_t.

8 years agoprop224: Function to inc/decrement num rendezvous stream
George Kadianakis [Mon, 31 Jul 2017 14:59:12 +0000 (17:59 +0300)] 
prop224: Function to inc/decrement num rendezvous stream

Add a common function for both legacy and prop224 hidden service to increment
and decrement the rendezvous stream counter on an origin circuit.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Always note down the use of internal circuit
David Goulet [Fri, 4 Aug 2017 16:06:34 +0000 (12:06 -0400)] 
prop224: Always note down the use of internal circuit

Also, this removes all the callsite of this rephist in the hs subsystem

Fixes #23097

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoAdd note about handling INTRODUCE2 cells.
George Kadianakis [Tue, 8 Aug 2017 08:51:16 +0000 (11:51 +0300)] 
Add note about handling INTRODUCE2 cells.

Also fix a check-spaces instance.

8 years agoStart caching disaster SRV values.
George Kadianakis [Tue, 8 Aug 2017 08:45:45 +0000 (11:45 +0300)] 
Start caching disaster SRV values.

Also add some unittests.

8 years agoFix the build_hs_index() function.
George Kadianakis [Mon, 7 Aug 2017 15:58:13 +0000 (18:58 +0300)] 
Fix the build_hs_index() function.

Also add a unittest for hs_get_responsible_hsdirs() which was used to
find and fix the bug.

8 years agoprop224: Improve comments and tests for ed25519 keys in IPs/RPs.
George Kadianakis [Mon, 7 Aug 2017 13:17:33 +0000 (16:17 +0300)] 
prop224: Improve comments and tests for ed25519 keys in IPs/RPs.

Also make sure we are not gonna advertise the ed25519 key of an intro
point that doesn't support it.

8 years agoImprove docs on rendezvous circ relaunch.
George Kadianakis [Mon, 7 Aug 2017 09:02:45 +0000 (12:02 +0300)] 
Improve docs on rendezvous circ relaunch.

8 years agoIncrease HS desc cert lifetime.
George Kadianakis [Sun, 6 Aug 2017 19:24:07 +0000 (22:24 +0300)] 
Increase HS desc cert lifetime.

We used to have a small HS desc cert lifetime but those certs can stick
around for 36 hours if they get initialized in the beginning of overlap
period.

[warn] Bug: Non-fatal assertion !(hs_desc_encode_descriptor(desc->desc, &desc->signing_kp, &encoded_desc) < 0) failed in
upload_descriptor_to_hsdir at src/or/hs_service.c:1886. Stack trace: (on Tor 0.3.2.0-alpha-dev b4a14555597fb9b3)

8 years agoprop224 tests: Better HS time period tests.
George Kadianakis [Sat, 5 Aug 2017 20:43:05 +0000 (23:43 +0300)] 
prop224 tests: Better HS time period tests.

8 years agoprop224 tests: Better HS address tests.
George Kadianakis [Sat, 5 Aug 2017 20:25:44 +0000 (23:25 +0300)] 
prop224 tests: Better HS address tests.

8 years agoprop224 tests: Improve SRV protocol tests.
George Kadianakis [Sat, 5 Aug 2017 20:11:37 +0000 (23:11 +0300)] 
prop224 tests: Improve SRV protocol tests.

8 years agoDo more type checking when setting HS idents.
George Kadianakis [Fri, 4 Aug 2017 21:33:34 +0000 (00:33 +0300)] 
Do more type checking when setting HS idents.

I repurposed the old directory_request_set_hs_ident() into a new
directory_request_upload_set_hs_ident() which is only used for the
upload purpose and so it can assert on the dir_purpose.

When coding the client-side we can make a second function for fetch.

8 years agoFix broken intro point unittest.
George Kadianakis [Fri, 4 Aug 2017 20:46:20 +0000 (23:46 +0300)] 
Fix broken intro point unittest.

The structure was not zeroed out, and left some boolean fields
uninitialized.

8 years agoExtract intro point onion key even with multiple types.
George Kadianakis [Fri, 4 Aug 2017 20:35:04 +0000 (23:35 +0300)] 
Extract intro point onion key even with multiple types.

8 years agoprop224 tests: test_gen_establish_intro_cell() check cell contents.
George Kadianakis [Fri, 4 Aug 2017 19:53:53 +0000 (22:53 +0300)] 
prop224 tests: test_gen_establish_intro_cell() check cell contents.

8 years agoImprove code based on Nick review:
George Kadianakis [Fri, 4 Aug 2017 19:02:28 +0000 (22:02 +0300)] 
Improve code based on Nick review:

- Fix some more crazy ternary ops.
- Fix the order of disaster SRV computation.
- Whitespace fixes.
- Remove a redundant warn.
- Better docs.

8 years agoDon't double hash the ed25519 blind key parameter.
George Kadianakis [Fri, 4 Aug 2017 09:37:48 +0000 (12:37 +0300)] 
Don't double hash the ed25519 blind key parameter.

We used to do:
   h = H(BLIND_STRING | H(A | s | B | N )
when we should be doing:
   h = H(BLIND_STRING | A | s | B | N)

Change the logic so that hs_common.c does the hashing, and our ed25519
libraries just receive the hashed parameter ready-made. That's easier
than doing the hashing on the ed25519 libraries, since that means we
would have to pass them a variable-length param (depending on whether
's' is set or not).

Also fix the ed25519 test vectors since they were also double hashing.

8 years agoDon't set HSDir index if we don't have a live consensus.
George Kadianakis [Fri, 4 Aug 2017 09:21:14 +0000 (12:21 +0300)] 
Don't set HSDir index if we don't have a live consensus.

We also had to alter the SRV functions to take a consensus as optional
input, since we might be setting our HSDir index using a consensus that
is currently being processed and won't be returned by the
networkstatus_get_live_consensus() function.

This change has two results:

a) It makes sure we are using a fresh consensus with the right SRV value
   when we are calculating the HSDir hash ring.

b) It ensures that we will not use the sr_get_current/previous()
   functions when we don't have a consensus which would have falsely
   triggered the disaster SRV logic.

8 years agoCorrectly assign HSDir flags based on protocol list
George Kadianakis [Thu, 3 Aug 2017 13:08:17 +0000 (16:08 +0300)] 
Correctly assign HSDir flags based on protocol list

In Nick's words:

"We want to always return false if the platform is a Tor version, and it
is not as new as 0.3.0.8 -- but if the platform is not a Tor version, or
if the version is as new as 0.3.0.8, then we want to obey the protocol
list.

That way, other implementations of our protocol won't have to claim any
particular Tor version, and future versions of Tor will have the freedom
to drop this protocol in the distant future."

8 years agoFix small easy bugs all around
George Kadianakis [Thu, 3 Aug 2017 13:04:25 +0000 (16:04 +0300)] 
Fix small easy bugs all around

- Fix log message format string.
- Do extra circuit purpose check.
- wipe memory in a clear function
- Make sure we don't double add intro points in our list
- Make sure we don't double close intro circuits.
- s/tt_u64_op/tt_i64_op/

8 years agoConstify functions that can be constified.
George Kadianakis [Thu, 3 Aug 2017 13:03:30 +0000 (16:03 +0300)] 
Constify functions that can be constified.

8 years agoImprove documentation all around the codebase.
George Kadianakis [Thu, 3 Aug 2017 13:02:51 +0000 (16:02 +0300)] 
Improve documentation all around the codebase.

8 years agoMake ed25519 id keys optional for IPs and RPs.
George Kadianakis [Thu, 3 Aug 2017 13:00:18 +0000 (16:00 +0300)] 
Make ed25519 id keys optional for IPs and RPs.

8 years agoImprove setting hsdir index procedure.
George Kadianakis [Thu, 3 Aug 2017 12:54:42 +0000 (15:54 +0300)] 
Improve setting hsdir index procedure.

- Fix memleak.

8 years agoMake HidServRevCounter be a LINELIST as it should.
George Kadianakis [Thu, 3 Aug 2017 12:52:01 +0000 (15:52 +0300)] 
Make HidServRevCounter be a LINELIST as it should.

8 years agoRename some free() functions that are actually clear().
George Kadianakis [Thu, 3 Aug 2017 12:51:24 +0000 (15:51 +0300)] 
Rename some free() functions that are actually clear().

8 years agoValidate intro point limits to avoid asserts.
George Kadianakis [Thu, 3 Aug 2017 12:49:42 +0000 (15:49 +0300)] 
Validate intro point limits to avoid asserts.

8 years agoRelax assertions: turn them to BUGs and non-fatal asserts.
George Kadianakis [Thu, 3 Aug 2017 12:47:06 +0000 (15:47 +0300)] 
Relax assertions: turn them to BUGs and non-fatal asserts.

8 years agoprop224: Don't use nodes as HSDirs if they don't have an HSDir index.
George Kadianakis [Wed, 2 Aug 2017 13:50:15 +0000 (16:50 +0300)] 
prop224: Don't use nodes as HSDirs if they don't have an HSDir index.

8 years agomemwipe interesting unused memory
George Kadianakis [Thu, 3 Aug 2017 12:42:30 +0000 (15:42 +0300)] 
memwipe interesting unused memory

8 years agoFix 32-bit bug when writing address to descriptor.
George Kadianakis [Thu, 3 Aug 2017 10:24:50 +0000 (13:24 +0300)] 
Fix 32-bit bug when writing address to descriptor.

We used to sizeof() a pointer. Let's just use asprintf to avoid having
to be smart.

8 years agoFix ternary operator abuse.
George Kadianakis [Mon, 31 Jul 2017 10:27:16 +0000 (13:27 +0300)] 
Fix ternary operator abuse.

8 years agoUse htonll() when INT_8 is used.
George Kadianakis [Thu, 3 Aug 2017 09:01:52 +0000 (12:01 +0300)] 
Use htonll() when INT_8 is used.

Also prepend period_length to any period_num, as specified by the spec.

8 years agoprop224: Remove INTRODUCE2 legacy handling
David Goulet [Tue, 1 Aug 2017 17:30:04 +0000 (13:30 -0400)] 
prop224: Remove INTRODUCE2 legacy handling

Turns out that introduction points don't care about the INTRODUCE2 cell
format as long as the top field is LEGACY_KEY_ID as expected. So let's
use a single INTRODUCE format regardless of the introduction point being
legacy or not.

This also removes the polymorphic void* situation.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Unbreak test_upload_descriptors()
George Kadianakis [Mon, 24 Jul 2017 10:17:59 +0000 (13:17 +0300)] 
test: Unbreak test_upload_descriptors()

To upload the descriptor we needed a state file to write the rev counters in,
but that test did not have a state file initialized.

Also fix the typo in its func name.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Unit tests for the revision counter state file codethe
George Kadianakis [Mon, 24 Jul 2017 10:03:19 +0000 (13:03 +0300)] 
test: Unit tests for the revision counter state file codethe

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Use state file to save/load revision counters
George Kadianakis [Fri, 21 Jul 2017 12:53:17 +0000 (15:53 +0300)] 
prop224: Use state file to save/load revision counters

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Refactor the overlap function to not use absolute time.
George Kadianakis [Tue, 18 Jul 2017 13:06:12 +0000 (16:06 +0300)] 
prop224: Refactor the overlap function to not use absolute time.

We consider to be in overlap mode when we are in the period of time between a
fresh SRV and the beginning of the new time period (in the normal network this
is between 00:00 and 12:00 UTC). This commit edits that function to use the
above semantic logic instead of absolute times.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Make prop224 time periods smaller in testnets.
George Kadianakis [Tue, 18 Jul 2017 15:10:26 +0000 (18:10 +0300)] 
prop224: Make prop224 time periods smaller in testnets.

It used to be that time periods were 24 hours long even on chutney,
which made testing harder. With this commit, time periods have the same
length as a full SRV protocol run, which means that they will change
every 4 minutes in a 10-second voting interval chutney network!

8 years agoprop224: Refactor hs_get_time_period_num() to not use absolute time.
George Kadianakis [Mon, 24 Jul 2017 10:31:17 +0000 (13:31 +0300)] 
prop224: Refactor hs_get_time_period_num() to not use absolute time.

Instead use the SRV protocol duration to calculate the rotation offset
that was previously hardcoded to 12 hours.

8 years agoprop224: Compute start time of next time period.
George Kadianakis [Tue, 18 Jul 2017 13:44:03 +0000 (16:44 +0300)] 
prop224: Compute start time of next time period.

8 years agoSR: Calculate current SRV phase/run duration.
George Kadianakis [Mon, 24 Jul 2017 10:30:04 +0000 (13:30 +0300)] 
SR: Calculate current SRV phase/run duration.

This is also needed to make the HS desc overlap mode function
independent of absolute hours.

8 years agoSR: Compute the start time of the current protocol run.
George Kadianakis [Mon, 17 Jul 2017 11:45:14 +0000 (14:45 +0300)] 
SR: Compute the start time of the current protocol run.

This function will be used to make the HS desc overlap function be
independent of absolute times.

8 years agoprop224: HSDir v3 support is >= 0.3.0.8
David Goulet [Fri, 14 Jul 2017 20:37:13 +0000 (16:37 -0400)] 
prop224: HSDir v3 support is >= 0.3.0.8

Because of bug #22447, we have to select nodes that are at least this version.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Move get_intro_circuit() to hs_circuit.c
David Goulet [Wed, 19 Jul 2017 15:42:04 +0000 (11:42 -0400)] 
prop224: Move get_intro_circuit() to hs_circuit.c

Make this function public so we can use it both in hs_circuit.c and
hs_service.c to avoid code duplication.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Make circuit prediction aware of v3 services
David Goulet [Tue, 11 Jul 2017 15:18:23 +0000 (11:18 -0400)] 
prop224: Make circuit prediction aware of v3 services

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Add service rendezvous circuit relaunch
David Goulet [Tue, 30 May 2017 20:11:59 +0000 (16:11 -0400)] 
prop224: Add service rendezvous circuit relaunch

This introduces a callback to relaunch a service rendezvous circuit when a
previous one failed to build or expired.

It unifies the legacy function rend_service_relaunch_rendezvous() with one for
specific to prop224. There is now only one entry point for that which is
hs_circ_retry_service_rendezvous_point() supporting both legacy and prop224
circuits.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Different intro point timings with TestingNetwork
David Goulet [Fri, 26 May 2017 18:20:00 +0000 (14:20 -0400)] 
prop224: Different intro point timings with TestingNetwork

Change the timing for intro point's lifetime and maximum amount of circuit we
are allowed to launch in a TestingNetwork. This is particurlarly useful for
chutney testing to test intro point rotation.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Add a circuit has closed callback
David Goulet [Thu, 25 May 2017 14:28:00 +0000 (10:28 -0400)] 
prop224: Add a circuit has closed callback

When the circuit is about to be freed which has been marked close before, for
introduction circuit we now call this has_closed() callback so we can cleanup
any introduction point that have retried to many times or at least flag them
that their circuit is not established anymore.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agohs: Rename num_rend_services()
David Goulet [Mon, 10 Jul 2017 15:31:51 +0000 (11:31 -0400)] 
hs: Rename num_rend_services()

Renamed to rend_num_services() so it is consistent with the legacy naming.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Fix prop224 HS descriptor to use subcredential
George Kadianakis [Thu, 1 Jun 2017 12:11:03 +0000 (15:11 +0300)] 
test: Fix prop224 HS descriptor to use subcredential

We used to use NULL subcredential which is a terrible terrible idea.  Refactor
HS unittests to use subcredentials.

Also add some non-fatal asserts to make sure that we always use subcredentials
when decoding/encoding descs.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Add unit test coverage of hs_service.c
David Goulet [Fri, 5 May 2017 18:55:26 +0000 (14:55 -0400)] 
test: Add unit test coverage of hs_service.c

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Refactor HS tests to use the new ESTABLISH_INTRO cell code
David Goulet [Fri, 28 Apr 2017 17:41:34 +0000 (13:41 -0400)] 
test: Refactor HS tests to use the new ESTABLISH_INTRO cell code

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Add test_hs_common unit tests
David Goulet [Thu, 20 Apr 2017 15:20:02 +0000 (11:20 -0400)] 
test: Add test_hs_common unit tests

Move tests from test_hs_service.c to this file.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Add test_hs_ntor unit tests
David Goulet [Thu, 20 Apr 2017 14:04:28 +0000 (10:04 -0400)] 
test: Add test_hs_ntor unit tests

Move the ntor test from test_hs_service.c to this file.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agotest: Add test_hs_cell unit tests
David Goulet [Thu, 20 Apr 2017 13:58:21 +0000 (09:58 -0400)] 
test: Add test_hs_cell unit tests

Move ESTABLISH_INTRO tests from test_hs_service.c to this new file.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agoprop224: Link rendezvous circuit to edge connection
David Goulet [Wed, 10 May 2017 19:04:40 +0000 (15:04 -0400)] 
prop224: Link rendezvous circuit to edge connection

This commit refactors the handle_hs_exit_conn() function introduced at a prior
commit that connects the rendezvous circuit to the edge connection used to
connect to the service virtual port requested in a BEGIN cell.

The refactor adds the support for prop224 adding the
hs_service_set_conn_addr_port() function that has the same purpose has
rend_service_set_connection_addr_port() from the legacy code.

The rend_service_set_connection_addr_port() has also been a bit refactored so
the common code can be shared between the two HS subsystems (legacy and
prop224).

In terms of functionallity, nothing has changed, we still close the circuits
in case of failure for the same reasons as the legacy system currently does.

Signed-off-by: David Goulet <dgoulet@torproject.org>
8 years agohs: Refactor the service exit connection code
David Goulet [Wed, 10 May 2017 17:43:37 +0000 (13:43 -0400)] 
hs: Refactor the service exit connection code

This commit simply moves the code from the if condition of a rendezvous
circuit to a function to handle such a connection. No code was modified
_except_ the use or rh.stream_id changed to n_stream->stream_id so we don't
have to pass the cell header to the function.

This is groundwork for prop224 support which will break down the
handle_hs_exit_conn() depending on the version of hidden service the circuit
and edge connection is for.

Signed-off-by: David Goulet <dgoulet@torproject.org>