summaryrefslogtreecommitdiff
path: root/src/feature/dirclient
AgeCommit message (Collapse)Author
2022-10-25use consensus ip:port for dir auths if differentRoger Dingledine
Directory authorities and relays now interact properly with directory authorities if they change addresses. In the past, they would continue to upload votes, signatures, descriptors, etc to the hard-coded address in the configuration. Now, if the directory authority is listed in the consensus at a different address, they will direct queries to this new address. Specifically, these three activities have changed: * Posting a vote, a signature, or a relay descriptor to all the dir auths. * Dir auths fetching missing votes or signatures from all the dir auths. * Dir auths fetching new descriptors from a specific dir auth when they just learned about them from that dir auth's vote. We already do this desired behavior (prefer the address in the consensus, but fall back to the hard-coded dirservers info if needed) when fetching missing certs. There is a fifth case, in router_pick_trusteddirserver(), where clients and relays are trying to reach a random dir auth to fetch something. I left that case alone for now because the interaction with fallbackdirs is complicated. Implements ticket 40705.
2022-10-25clean up comment a bitRoger Dingledine
2021-10-24fetch missing bridge descriptors without delayRoger Dingledine
Without this change, if we have a working bridge, and we add a new bridge, we will schedule the fetch attempt for that new bridge descriptor for three hours(!) in the future. This change is especially needed because of bug #40396, where if you have one working bridge and one bridge whose descriptor you haven't fetched yet, your Tor will stall until you have successfully fetched that new descriptor -- in this case for hours. In the old design, we would put off all further bridge descriptor fetches once we had any working bridge descriptor. In this new design, we make the decision per bridge based on whether we successfully got *its* descriptor. To make this work, we need to also call learned_bridge_descriptor() every time we get a bridge descriptor, not just when it's a novel descriptor. Fixes bug 40396. Also happens to fix bug 40495 (redundant descriptor fetches for every bridge) since now we delay fetches once we succeed. A side effect of this change is that if we have any configured bridges that *aren't* working, we will keep trying to fetch their descriptors on the modern directory retry schedule -- every couple of seconds for the first half minute, then backing off after that -- which is a lot faster than before.
2021-08-18Merge remote-tracking branch 'tor-gitlab/mr/420'Nick Mathewson
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-06-18Merge branch 'maint-0.4.6'David Goulet
2021-06-18Fix 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-06-01Merge branch 'maint-0.4.6'David Goulet
2021-06-01Merge branch 'tor-gitlab/mr/393' into maint-0.4.6David Goulet
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-27Merge branch 'maint-0.4.6'David Goulet
2021-05-27Merge branch 'tor-gitlab/mr/392' into maint-0.4.6David Goulet
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-04-23Merge branch 'tor-gitlab/mr/327'David Goulet
Conflicts: src/test/test.c Minor comment issue.
2021-03-12Update copyrights to 2021, using "make update-copyright"Nick Mathewson
2021-02-24Merge branch 'maint-0.4.5'David Goulet
2021-02-24Choose the correct dirport when contacting an authority.Nick Mathewson
This is part of an implementation for proposal 330. This implementation doesn't handle authdirs' IPv6 dirports (yet).
2021-02-24Add support for knowing multiple HTTP DirPorts for an authority.Nick Mathewson
(These aren't yet set or used.)
2021-02-23relay: Avoid a directory early fetchDavid Goulet
The directory_fetches_from_authorities() is used to know if a client or relay should fetch data from an authority early in the boot process. We had a condition in that function that made a relay trigger that fetch if it didn't know its address (so we can learn it). However, when this is called, the address discovery has not been done yet so it would always return true for a relay. Furthermore, it would always trigger a log notice that the IPv4 couldn't be found which was inevitable because the address discovery process has not been done yet (done when building our first descriptor). It is also important to point out that starting in 0.4.5.1-alpha, asking an authority for an address is done during address discovery time using a one-hop circuit thus independent from the relay deciding to fetch or not documents from an authority. Small fix also is to reverse the "IPv(4|6)Only" flag in the notice so that if we can't find IPv6 it would output to use IPv4Only. Fixes #40300 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-22relay: Remove dirport reachability self testDavid Goulet
Regular relays are about to get their DirPort removed so that reachability test is not useful anymore Authorities will still use the DirPort but because network reentry towards their DirPort is now denied network wide, this test is not useful anymore and so it should simply be considered reachable at all time. Part of #40282 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-19hs-v2: Removal of service and relay supportDavid Goulet
This is unfortunately massive but both functionalities were extremely intertwined and it would have required us to actually change the HSv2 code in order to be able to split this into multiple commits. After this commit, there are still artefacts of v2 in the code but there is no more support for service, intro point and HSDir. The v2 support for rendezvous circuit is still available since that code is the same for the v3 and we will leave it in so if a client is able to rendezvous on v2 then it can still transfer traffic. Once the entire network has moved away from v2, we can remove v2 rendezvous point support. Related to #40266 Signed-off-by: David Goulet <dgoulet@torproject.org>
2021-02-19hs-v2: Remove client supportDavid Goulet
Related to #40266 Signed-off-by: David Goulet <dgoulet@torproject.org>
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-20relay: Deciding to fetch from authority, use new find address APIDavid Goulet
Use the new relay_has_address_set() interface when deciding if we need to fetch directory information from an authority as a relay. If no IPv4 address is found, we'll proceed with a fetch so we can learn our address in the HTTP header or NETINFO cell that a trusted authority will send us back. Related to #40025 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-16Merge branch 'ticket32487_squashed' into ticket32487_squashed_and_mergedNick Mathewson
Resolved conflicts in src/core/include.am
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.