summaryrefslogtreecommitdiff
path: root/src/or/hs_service.h
AgeCommit message (Collapse)Author
2018-07-05Move literally everything out of src/orNick Mathewson
This commit won't build yet -- it just puts everything in a slightly more logical place. The reasoning here is that "src/core" will hold the stuff that every (or nearly every) tor instance will need in order to do onion routing. Other features (including some necessary ones) will live in "src/feature". The "src/app" directory will hold the stuff needed to have Tor be an application you can actually run. This commit DOES NOT refactor the former contents of src/or into a logical set of acyclic libraries, or change any code at all. That will have to come in the future. We will continue to move things around and split them in the future, but I hope this lays a reasonable groundwork for doing so.
2018-06-21Rectify include paths (automated)Nick Mathewson
2018-06-20Run rectify_include_paths.pyNick Mathewson
2018-06-20Update copyrights to 2018.Nick Mathewson
2018-05-03hs-v3: Remove extra white-space and clarify commentDavid Goulet
From Neel's latest patch on optimizing the hs_circ_service_get_intro_circ() digest calculation, remove an extra white-space and clarify a comment of the legacy key digest to inform when to use it. Signed-off-by: David Goulet <dgoulet@torproject.org>
2018-05-02Optimize legacy intro point digest calculation.Neel Chauhan
2018-04-27hs: Rescan the main loop event list if the service map changesDavid Goulet
Because ADD_ONION/DEL_ONION can modify the global service map (both for v2 and v3), we need to rescan the event list so we either enable or disable the HS service main loop event. Fixees #25939 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-12-08Merge branch 'macro_free_v2_squashed'Nick Mathewson
2017-12-08Replace all FREE_AND_NULL* uses to take a type and a free function.Nick Mathewson
This commit was made mechanically by this perl script: \#!/usr/bin/perl -w -i -p next if /^#define FREE_AND_NULL/; s/\bFREE_AND_NULL\((\w+),/FREE_AND_NULL\(${1}_t, ${1}_free_,/; s/\bFREE_AND_NULL_UNMATCHED\(/FREE_AND_NULL\(/;
2017-12-08Switch to a safer FREE_AND_NULL implementationNick Mathewson
This one only evaluates the input once, so it cannot mess up even if there are side effects.
2017-12-08Change the free macro convention in the rest of src/or/*.hNick Mathewson
2017-12-05hs-v3: Add a public function to upload a descriptor to an HSDirDavid Goulet
This is groundwork for the HSPOST control port command that needs a way in the HS subsystem to upload a service descriptor to a specific HSDir. To do so, we add a public function that takes a series of parameters including a fully encoded descriptor and initiate a directory request to a specific routerstatut_t object. It is for now not used but should be, in future commit, by the HSPOST command. This commit has no behavior change, only refactoring. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-12-05hs-v3: Add ephemeral service supportDavid Goulet
The functions are now used by the ADD_ONION/DEL_ONION control port command as well. This commits makes them fully functionnal with hidden service v3. Part of #20699 Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-11-20hs-v3: Add a lookup service current descriptor functionDavid Goulet
This will be used by the control port command "GETINFO hs/service/desc/id/<ADDR>" which returns the encoded current descriptor for the given onion address. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-09-15Run our #else/#endif annotator on our source code.Nick Mathewson
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-04Merge remote-tracking branch 'asn/bug23346'Nick Mathewson
2017-09-04hs: Remove dead code and uneeded featureDavid Goulet
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>
2017-08-30prop224: Simplify HSDir set change algo.George Kadianakis
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"
2017-08-25prop224: Move service_desc_hsdirs_changed() and make it static.George Kadianakis
That function could be static but needed to be moved to the top.
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-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-08prop224 tests: Better HS address tests.George Kadianakis
2017-08-08Constify functions that can be constified.George Kadianakis
2017-08-08Improve documentation all around the codebase.George Kadianakis
2017-08-08Relax assertions: turn them to BUGs and non-fatal asserts.George Kadianakis
2017-08-08test: Unit tests for the revision counter state file codetheGeorge Kadianakis
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Make circuit prediction aware of v3 servicesDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Add a circuit has closed callbackDavid Goulet
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>
2017-08-08test: Add unit test coverage of hs_service.cDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08test: Refactor HS tests to use the new ESTABLISH_INTRO cell codeDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Link rendezvous circuit to edge connectionDavid Goulet
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>
2017-08-08prop224: Sandbox support for serviceDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Implement a service intro point failure cacheDavid Goulet
Imagine a Tor network where you have only 8 nodes available due to some reasons. And your hidden service wants 8 introduction points. Everything is fine but then a node goes down bringing the network to 7. The service will retry 3 times that node and then give up but keep it in a failure cache for 5 minutes (INTRO_CIRC_RETRY_PERIOD) so it doesn't retry it non stop and exhaust the maximum number of circuit retry. In the real public network today, this is unlikely to happen unless the ExcludeNodes list is extremely restrictive. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Upload service descriptorsDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Add service replay cacheDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Handle service INTRODUCE2 cellDavid Goulet
At this commit, launching rendezvous circuit is not implemented, only a placeholder. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Handle service INTRO_ESTABLISHED cellDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Circuit has opened and ESTABLISH_INTRO cellDavid Goulet
Add the entry point from the circuit subsystem of "circuit has opened" which is for all type of hidden service circuits. For the introduction point, this commit actually adds the support for handling those circuits when opened and sending ESTABLISH_INTRO on a circuit. Rendevzou point circuit aren't supported yet at this commit. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Service v3 descriptor creation and logicDavid Goulet
This commit adds the functionality for a service to build its descriptor. Also, a global call to build all descriptors for all services is added to the service scheduled events. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-08-08prop224: Scheduled events for serviceDavid Goulet
Add the main loop entry point to the HS service subsystem. It is run every second and make sure that all services are in their quiescent state after that which means valid descriptors, all needed circuits opened and latest descriptors have been uploaded. For now, only v2 is supported and placeholders for v3 actions for that main loop callback. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-25prop224: Add onion key to service descriptor intro pointDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Move service version into config objectDavid Goulet
It makes more sense to have the version in the configuration object of the service because it is afterall a torrc option (HiddenServiceVersion). Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13test: Add v3 service load keys and accessorsDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13test: Add v3 service config and registration testDavid Goulet
This tests our hs_config.c API to properly load v3 services and register them to the global map. It does NOT test the service object validity, that will be the hs service unit test later on. At this commit, we have 100% code coverage of hs_config.c. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Load and/or generate v3 service keysDavid Goulet
Try to load or/and generate service keys for v3. This write both the public and private key file to disk along with the hostname file containing the onion address. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Configure v3 service from optionsDavid Goulet
This commit adds the support in the HS subsystem for loading a service from a set of or_options_t and put them in a staging list. To achieve this, service accessors have been created and a global hash map containing service object indexed by master public key. However, this is not used for now. It's ground work for registration process. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Add a init/free_all function for the whole subsystemDavid Goulet
Introduces hs_init() located in hs_common.c which initialize the entire HS v3 subsystem. This is done _prior_ to the options being loaded because we need to allocate global data structure before we load the configuration. The hs_free_all() is added to release everything from tor_free_all(). Note that both functions do NOT handle v2 service subsystem but does handle the common interface that both v2 and v3 needs such as the cache and circuitmap. Signed-off-by: David Goulet <dgoulet@torproject.org>
2017-07-13prop224: Add hs_config.{c|h} with a refactoringDavid Goulet
Add the hs_config.{c|h} files contains everything that the HS subsystem needs to load and configure services. Ultimately, it should also contain client functions such as client authorization. This comes with a big refactoring of rend_config_services() which has now changed to only configure a single service and it is stripped down of the common directives which are now part of the generic handler. This is ground work for prop224 of course but only touches version 2 services and add XXX note for version 3. Signed-off-by: David Goulet <dgoulet@torproject.org>