aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_hs_common.c
AgeCommit message (Collapse)Author
2018-06-29Merge branch 'maint-0.3.3' into maint-0.3.4Nick Mathewson
2018-06-29Merge branch 'maint-0.3.2' into maint-0.3.3Nick Mathewson
2018-06-23Fix memory leak in helper_add_hsdir_to_networkstatus().Alexander Færøy
This patch fixes a memory leak in helper_add_hsdir_to_networkstatus() where the rs object might not get properly freed. See: Coverity CID 1437427.
2018-05-03Merge remote-tracking branch 'isis/bug24660_r1'Nick Mathewson
2018-05-02Make hs_get_responsible_hsdirs() deterministic.Nick Mathewson
This test was using the current time to pick the time period number, and a randomly generated hs key. Therefore, it sometimes picked an index that would wrap around the example dht, and sometimes would not. The fix here is just to fix the time period and the public key. Fixes bug 25997; bugfix on 0.3.2.1-alpha.
2018-05-01vote: Move dirvote_recalculate_timing() to voting_schedule.cDavid Goulet
By doing so, it is renamed to voting_schedule_recalculate_timing(). This required a lot of changes to include voting_schedule.h everywhere that this function was used. This effectively now makes voting_schedule.{c|h} not include dirauth/dirvote.h for that symbol and thus no dependency on the dirauth module anymore. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-27mod: Move dirauth specific files to its own moduleDavid Goulet
This is a pretty big commit but it only moves these files to src/or/dirauth: dircollate.c dirvote.c shared_random.c shared_random_state.c dircollate.h dirvote.h shared_random.h shared_random_state.h Then many files are modified to change the include line for those header files that have moved into a new directory. Without using --disable-module-dirauth, everything builds fine. When using the flag to disable the module, tor doesn't build due to linking errors. This will be addressed in the next commit(s). No code behavior change. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-04-22Rename node_has_descriptor() to node_has_any_descriptor()Nick Mathewson
Changing the name of this function should help keep us from misusing it when node_has_preferred_descriptor() would be more appropriate.
2018-04-06crypto: Refactor (P)RNG functionality into new crypto_rand module.Isis Lovecruft
* ADD new /src/common/crypto_rand.[ch] module. * ADD new /src/common/crypto_util.[ch] module (contains the memwipe() function, since all crypto_* modules need this). * FIXES part of #24658: https://bugs.torproject.org/24658
2018-01-24Extract protover summary flags into a new structureNick Mathewson
This will let us use them on routerinfo_t as well as on routerstatus_t, and save some time on relays. No behavioral changes here.
2018-01-03Fix some shadowed-global warnings.Nick Mathewson
These are all about local variables shadowing global functions. That isn't normally a problem, but at least one compiler we care about seems to treat this as a case of -Wshadow violation, so let's fix it. Fixes bug 24634; bugfix on 0.3.2.1-alpha.
2017-12-20Update the unit tests to reflect the change of 24425Nick Mathewson
2017-10-31test: Fix voting schedule for hs_common.cDavid Goulet
Part of #23623 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-15Merge branch 'scan-build-032'Nick Mathewson
2017-09-15test: Make check-spaces happyDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-15test: Unit test for the hs indexesDavid Goulet
Using a test vector in python, test both hs_build_hsdir_index() and hs_build_hs_index(). This commit also adds the hs_build_address.py to EXTRA_DIST which was missing. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-15prop224 test: Enrich the client_service_hsdir_set_sync() test.George Kadianakis
Do two major improvements: a) Make the client pick 6 HSDirs instead of just 1 and make sure they all match the service's HSDirs. b) Test two additional missing scenarios borrowed from the test_reachability() test.
2017-09-14prop224 client-side: Start validating onion address pubkeys.George Kadianakis
Fix the test_build_address() test and its test vectors python script. They were both using a bogus pubkey for building an HS address which does not validate anymore. Also fix a few more unittests that were using bogus onion addresses and were failing the validation. I replaced the bogus address with the one generated from the test vector script.
2017-09-12Clear up dead-assignment warnings from scan-buildNick Mathewson
2017-09-11test: Fix memleaksDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-08test: Test that client picks the right HSDir for service.George Kadianakis
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.
2017-09-08prop224: hs_time_between_tp_and_srv() -> hs_in_period_between_tp_and_srv()George Kadianakis
Conflicts: src/or/nodelist.c
2017-09-08test: Add an HS v3 reachability unit testDavid Goulet
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>
2017-09-08prop224: Make client and service pick same HSDirDavid Goulet
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>
2017-09-08prop224: Expand the overlap period concept to be a full SRV protocol runDavid Goulet
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: +------------------------------------------------------------------+ | | | 00:00 12:00 00:00 12:00 00:00 12:00 | | SRV#1 TP#1 SRV#2 TP#2 SRV#3 TP#3 | | | | $==========|-----------$===========|-----------$===========| | | ^ ^ | | C S | +------------------------------------------------------------------+ 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.
2017-09-08prop224: Use fetch and store HSDir indexes.David Goulet
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>
2017-08-30prop224: Clear list of prev hsdirs before we upload all descs.George Kadianakis
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!
2017-08-30prop224 test: Improve desc_reupload_logic() test with more nodes.George Kadianakis
2017-08-30prop224 test: Simplify interface for adding nodes to hash ring.George Kadianakis
We want to have tests with big hash rings so let's make it an one-liner to add nodes.
2017-08-28prop224: Add test that exposes the #23343 bug.George Kadianakis
2017-08-25prop224: Refactor descriptor reupload logic.George Kadianakis
We refactor the descriptor reupload logic to be similar to the v2 logic where we update a global 'consider_republishing_rend_descriptors' flag and then we use that to check for hash ring changes during the global hidden service callbacks. This fixes bugs where we would inspect the hash ring immediately as we receive new dirinfo (e.g. consensus) but before running the hidden service housekeeping events. That was leaving us in an inconsistent state wrt hsdir indices and causing bugs all around.
2017-08-24Fix operator usage in src/test/*.cAlexander Færøy
This patch fixes the operator usage in src/test/*.c to use the symbolic operators instead of the normal C comparison operators. This patch was generated using: ./scripts/coccinelle/test-operator-cleanup src/test/*.[ch]
2017-08-24prop224: Refactor rendclient.c to use the new hsdir_req code.George Kadianakis
- 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>
2017-08-19prop224: Refactor parse_extended_hostname() to parse v3 addrs.George Kadianakis
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>
2017-08-19prop224: Improve descriptor reupload logic.George Kadianakis
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.
2017-08-19test: Improve get_responsible_hsdirs test.George Kadianakis
2017-08-11test: Fix memory leak in test_hs_common.cDavid Goulet
Partially fixes #23223 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-11test: Fix hs common test for WindowsDavid Goulet
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>
2017-08-09fix another 32-bit warningNick Mathewson
2017-08-08Start caching disaster SRV values.George Kadianakis
Also add some unittests.
2017-08-08Fix the build_hs_index() function.George Kadianakis
Also add a unittest for hs_get_responsible_hsdirs() which was used to find and fix the bug.
2017-08-08prop224 tests: Better HS time period tests.George Kadianakis
2017-08-08prop224 tests: Better HS address tests.George Kadianakis
2017-08-08Improve documentation all around the codebase.George Kadianakis
2017-08-08prop224: Refactor the overlap function to not use absolute time.George Kadianakis
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>
2017-08-08prop224: Compute start time of next time period.George Kadianakis
2017-08-08test: Add test_hs_common unit testsDavid Goulet
Move tests from test_hs_service.c to this file. Signed-off-by: David Goulet <dgoulet@torproject.org>