aboutsummaryrefslogtreecommitdiff
path: root/src/feature/dirclient/dirclient.c
AgeCommit message (Collapse)Author
2021-10-28Fix compilation on systems with older compilers.Alexander Færøy
This patch fixes a build error with GCC 7.x which doesn't seem to accept const int's as constants in macro initialization. See: tpo/core/tor#40410
2021-10-06Merge branch 'tor-gitlab/mr/392' into maint-0.4.5David Goulet
2021-10-06Merge branch 'tor-gitlab/mr/393' into maint-0.4.5David Goulet
2021-08-17dir: Do not flag non-running failing HSDirDavid Goulet
When a directory request fails, we flag the relay as non Running so we don't use it anymore. This can be problematic with onion services because there are cases where a tor instance could have a lot of services, ephemeral ones, and keeps failing to upload descriptors, let say due to a bad network, and thus flag a lot of nodes as non Running which then in turn can not be used for circuit building. This commit makes it that we never flag nodes as non Running on a onion service directory request (upload or fetch) failure as to keep the hashring intact and not affect other parts of tor. Fortunately, the onion service hashring is _not_ selected by looking at the Running flag but since we do a 3-hop circuit to the HSDir, other services on the same instance can influence each other by removing nodes from the consensus for path selection. This was made apparent with a small network that ran out of nodes to used due to rapid succession of onion services uploading and failing. See #40434 for details. Fixes #40434 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-05-27Upgrade and rate-limit compression failure message.Nick Mathewson
Without this message getting logged at 'WARN', it's hard to contextualize the messages we get about compression bombs, so this message should fix #40175. I'm rate-limiting this, however, since it _could_ get spammy if somebody on the network starts acting up. (Right now it should be very quiet; I've asked Sebastian to check it, and he says that he doesn't hit this message in practice.) Closes #40175.
2021-05-26Prefer mmap()ed consensus files over cached_dir_t entries.Nick Mathewson
Cached_dir_t is a somewhat "legacy" kind of storage when used for consensus documents, and it appears that there are cases when changing our settings causes us to stop updating those entries. This can cause trouble, as @arma found out in #40375, where he changed his settings around, and consensus diff application got messed up: consensus diffs were being _requested_ based on the latest consensus, but were being (incorrectly) applied to a consensus that was no longer the latest one. This patch is a minimal fix for backporting purposes: it has Tor do the same search when applying consensus diffs as we use to request them. This should be sufficient for correct behavior. There's a similar case in GETINFO handling; I've fixed that too. Fixes #40375; bugfix on 0.3.1.1-alpha.
2021-01-21log more during consensus voting processRoger Dingledine
Give more visibility to directory authority operators during the consensus voting process. Closes ticket 40245.
2020-10-20Merge branch 'mr_175_squashed'Nick Mathewson
2020-10-20Consider 301 as an error like 404Guinness
Tor does not follow redirects when bootstraping so we encountered an error. Fixes #40053
2020-10-19Simplify logic to use smartlist_add_asprintf()Nick Mathewson
2020-10-08dirclient: print bandwidth usage on one line (#40159)Alex Xu (Hello71)
2020-08-05Replace several C identifiers for ticket 18106.Nick Mathewson
We used to have a single boolean, "FascistFirewall". Ages ago, in tickets #17840 and #9067, we added an improved "ReachableAddresses" mechanism. It's time to rename related identifiers in the code for consistency. This closes #18106. This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ fascist_firewall_allows_address reachable_addr_allows \ fascist_firewall_use_ipv6 reachable_addr_use_ipv6 \ fascist_firewall_prefer_ipv6_impl reachable_addr_prefer_ipv6_impl \ fascist_firewall_prefer_ipv6_orport reachable_addr_prefer_ipv6_orport \ fascist_firewall_prefer_ipv6_dirport reachable_addr_prefer_ipv6_dirport \ fascist_firewall_allows_address_addr reachable_addr_allows_addr \ fascist_firewall_allows_address_ap reachable_addr_allows_ap \ fascist_firewall_allows_base reachable_addr_allows_base \ fascist_firewall_allows_ri_impl reachable_addr_allows_ri_impl \ fascist_firewall_allows_rs_impl reachable_addr_allows_rs_impl \ fascist_firewall_allows_rs reachable_addr_allows_rs \ fascist_firewall_allows_md_impl reachable_addr_allows_md_impl \ fascist_firewall_allows_node reachable_addr_allows_node \ fascist_firewall_allows_dir_server reachable_addr_allows_dir_server \ fascist_firewall_choose_address_impl reachable_addr_choose_impl \ fascist_firewall_choose_address reachable_addr_choose \ fascist_firewall_choose_address_base reachable_addr_choose_base \ fascist_firewall_choose_address_rs reachable_addr_choose_from_rs \ fascist_firewall_choose_address_ls reachable_addr_choose_from_ls \ fascist_firewall_choose_address_node reachable_addr_choose_from_node \ fascist_firewall_choose_address_dir_server reachable_addr_choose_from_dir_server
2020-07-22log: Don't use twice fmt_addr() in same logging statementDavid Goulet
Fixes #40059 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20relay: Handle dir address suggestion with new interfaceDavid Goulet
We now use relay_address_new_suggestion() when a suggested address is received from a directory. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-16Use connection_describe() for log messages.Nick Mathewson
2020-07-14addr: Use tor_addr_t instead of uint32_t for IPv4David Goulet
This changes a LOT of code but in the end, behavior is the same. Unfortunately, many functions had to be changed to accomodate but in majority of cases, to become simpler. Functions are also removed specifically those that were there to convert an IPv4 as a host format to a tor_addr_t. Those are not needed anymore. The IPv4 address field has been standardized to "ipv4_addr", the ORPort to "ipv4_orport" (currently IPv6 uses ipv6_orport) and DirPort to "ipv4_dirport". This is related to Sponsor 55 work that adds IPv6 support for relays and this work is needed in order to have a common interface between IPv4 and IPv6. Closes #40043. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-07Merge remote-tracking branch 'tor-github/pr/1880/head'Nick Mathewson
2020-05-06Merge branch 'maint-0.4.3'Nick Mathewson
Amazingly, this time we had no merge conflicts with "falls through" comments.
2020-05-06Use __attribute__((fallthrough)) rather than magic GCC comments.Nick Mathewson
GCC added an implicit-fallthrough warning a while back, where it would complain if you had a nontrivial "case:" block that didn't end with break, return, or something like that. Clang recently added the same thing. GCC, however, would let you annotate a fall-through as intended by any of various magic "/* fall through */" comments. Clang, however, only seems to like "__attribute__((fallthrough))". Fortunately, GCC accepts that too. A previous commit in this branch defined a FALLTHROUGH macro to do the right thing if GNUC is defined; here we replace all of our "fall through" comments with uses of that macro. This is an automated commit, made with the following perl one-liner: #!/usr/bin/perl -i -p s#/\* *falls? ?thr.*?\*/#FALLTHROUGH;#i; (In order to avoid conflicts, I'm applying this script separately to each maint branch. This is the 0.4.3 version.)
2020-05-05relay: Rename relay_resolve_addr.{c|h} fileDavid Goulet
New name is more accurate semantically. Closes #33789 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-05-05relay: New file relay_resolve_addr.{c|h}David Goulet
This commit moves router_pick_published_address() and the related helper functions into the new file. The log_addr_has_changed() function has been made public in router.h so we can use it in relay_resolve_addr.c. This is a refactoring as part of Sponsor 55. Only code movement at this commit. Part of #33789 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-03-19Actually log post-bootstrap directory dl totals.Nick Mathewson
Fixes bug 33651; bug not in any released Tor.
2020-03-05Merge branch 'clang_format_prep_3'Nick Mathewson
2020-02-25Merge remote-tracking branch 'tor-github/pr/1750/head'Nick Mathewson
2020-02-20Use PRIu64 and TOR_PRIuSZ, to fix 32-bit build error.Nick Mathewson
2020-02-20Make direclient_dump_total_dls() respect SafeLogging and pass tests.Nick Mathewson
Don't dump totals with anonymous purposes. Additionally, don't dump headers that have nothing underneath them.
2020-02-18Remember dirctory bw usage, and log it in the heartbeatNick Mathewson
Closes ticket 32720.
2020-02-18Don't accept posted votes after :52:30Roger Dingledine
If we receive via 'post' a vote from a dir auth after the fetch_missing_votes cutoff, that means we didn't get it by the time we begin the "fetching missing votes from everybody else" phase, which means it is very likely to cause a consensus split if we count it. Instead, we reject it. But we still allow votes that we fetch ourselves after that cutoff. This is a demo branch for making progress on #4631. I've been running it on moria1 and it catches and handles real buggy behavior from directory authorities, e.g. Jan 28 15:59:50.804 [warn] Rejecting vote from 199.58.81.140 received at 2020-01-28 20:59:50; our cutoff for received votes is 2020-01-28 20:52:30 Jan 28 15:59:50.805 [warn] Rejected vote from 199.58.81.140 ("Vote received too late, would be dangerous to count it"). Jan 29 01:52:52.667 [warn] Rejecting vote from 204.13.164.118 received at 2020-01-29 06:52:52; our cutoff for received votes is 2020-01-29 06:52:30 Jan 29 01:52:52.669 [warn] Rejected vote from 204.13.164.118 ("Vote received too late, would be dangerous to count it"). Jan 29 04:53:26.323 [warn] Rejecting vote from 204.13.164.118 received at 2020-01-29 09:53:26; our cutoff for received votes is 2020-01-29 09:52:30 Jan 29 04:53:26.326 [warn] Rejected vote from 204.13.164.118 ("Vote received too late, would be dangerous to count it").
2020-02-06Use smaller CPP error messagesNick Mathewson
Clang-format wants to split these messages across multiple lines, which confuses the heck out of coccinelle.
2020-01-16Rename dirclient_modes.h identifiers to start with dirclient_Nick Mathewson
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ directory_must_use_begindir dirclient_must_use_begindir \ directory_fetches_from_authorities dirclient_fetches_from_authorities \ directory_fetches_dir_info_early dirclient_fetches_dir_info_early \ directory_fetches_dir_info_later dirclient_fetches_dir_info_later \ directory_too_idle_to_fetch_descriptors dirclient_too_idle_to_fetch_descriptors
2020-01-16Move directory_must_use_begindir() to dirclient_modes.[ch]Nick Mathewson
2020-01-16Move dirclient-related functions out of dirserv, and reenable themNick Mathewson
I had incorrectly identified these functions as dircache-only, when in fact they apply to everyone who acts a directory client.
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2019-11-18Merge branch 'tor-github/pr/1423'George Kadianakis
2019-11-18hs-v3: Refactor descriptor dir fetch done codeDavid Goulet
This commit extract most of the code that dirclient.c had to handle the end of a descriptor directory requests (fetch). It is moved into hs_client.c in order to have one single point of entry and the rest is fully handled by the HS subsystem. As part of #30382, depending on how the descriptor ended up stored (decoded or not), different SOCKS error code can be returned. Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18hs-v3: Set extended error when missing/bad client authDavid Goulet
Part of #30382 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18hs-v3: Set extended error when descriptor is not foundDavid Goulet
Part of #30382 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18hs-v3: Return descriptor decoding status when storing as clientDavid Goulet
This will allow us to callback into the HS subsytem depending on the decoding status and return an extended SOCKS5 error code depending on the decoding issue. This is how we'll be able to tell the SocksPort connection if we are missing or have bad client authorization for a service. Part of #30382 Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-26doxygen: add @file declarations for src/feature/Nick Mathewson
If a file doesn't use the file command (either \file or @file), Doxygen won't try to process it.
2019-04-30Replace all remaining tor_mem_is_zero() with fast_mem_is_zero()Nick Mathewson
2019-03-25Split all controller events code into a new control_events.cNick Mathewson
Also, split the formatting code shared by control.c and control_events.c into controller_fmt.c.
2019-01-16Bump copyright date to 2019Nick Mathewson
2018-11-02Avoid mmap leak if we get a consensus diff we can't use.Nick Mathewson
Fixes CID 1440819; bug not in any released Tor.
2018-10-31Merge branch 'networkstatus_mmap' into networkstatus_mmap_mergeNick Mathewson
2018-09-27Move the predicted ports code out of rephist.cNick Mathewson
It differs from the rest of the rephist code in that it's actually necessary for Tor to operate, so it should probably go somewhere else. I'm not sure where yet, so I'll leave it in the same directory, but give it its own file.
2018-09-26Merge branch 'router_split'Nick Mathewson
2018-09-26Merge remote-tracking branch 'dgoulet/bug27550_035_01'Nick Mathewson
2018-09-25Revise things that had included router.h beforeNick Mathewson
Make them only include the headers that they needed, and sort their headers while we're at it.
2018-09-25Extract all the "am I a server" functions from router.cNick Mathewson
2018-09-25Rename dirauth/mode.h to dirauth/authmode.hNick Mathewson
This is preparation for having a routermode.h as well