aboutsummaryrefslogtreecommitdiff
path: root/src/feature/relay/router.c
AgeCommit message (Collapse)Author
2020-07-21Combine router_get_advertised_or_port{,by_af_}() functionsNick Mathewson
2020-07-21Rename get_primary_dir_port()Nick Mathewson
Also, remove get_primary_or_port() -- nothing used it.
2020-07-21Rename get_first_advertised_{addr,port}_by_type_af().Nick Mathewson
Rationale: these don't actually give the first advertised address/port, but instead give us the first such port that we are _configured_ to advertise. Putting them in a portconf_ namespace therefore makes sense. Similarly, there are no other functions that get the first configured advertised addr/port, so the "by_type_af()" part is needless. This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ get_first_advertised_addr_by_type_af portconf_get_first_advertised_addr \ get_first_advertised_port_by_type_af portconf_get_first_advertised_port
2020-07-21relay: Don't publish IPv6 if found ORPort is 0David Goulet
The ORPort can be IPv4Only which means that even if we can auto discover an IPv6 address, we should not publish it because it would have an ORPort of 0. Fixes #40054 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20relay: Use flags in relay_find_addr_to_publish()David Goulet
Instead of a boolean saying "cache_only" add the concept of flags so we add semantic through out the code and allow ourselves to have more options in the future. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20addr: Use false/true with relay_find_addr_to_publish()David Goulet
Previous development introduced the error of using 0/1 for a boolean parameter. Fix that everywhere Related #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20relay: Don't lookup our address before rebuilding our descriptorDavid Goulet
Tor periodic events have moved to a role base model where relays have specific events. One of those is to rebuild the descriptor and that is ran every minute. This removes the call to router_rebuild_descriptor() from router_get_my_routerinfo_with_err() because that is the only code path that can call for a rebuild every second. Instead, when we mark the descriptor as dirty, immediately reschedule the descriptor check periodic event so it can be rebuilt that way instead of randomly when router_get_my_routerinfo_with_err() is called. Related to #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20relay: Publish IPv4/IPv6 from resolved address cacheDavid Goulet
When a relay builds a new descriptor, use the new relay_find_addr_to_publish() interface to find the address to publish per family. This commit also make the check for address consistency to also work for a configured IPv6 for which before it was IPv4 only. Related to #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
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-07-10Rename public bandwidth-history identifiers to start with "bwhist".Nick Mathewson
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ rep_hist_note_bytes_read bwhist_note_bytes_read \ rep_hist_note_bytes_written bwhist_note_bytes_written \ rep_hist_note_dir_bytes_read bwhist_note_dir_bytes_read \ rep_hist_note_dir_bytes_written bwhist_note_dir_bytes_written \ rep_hist_get_bandwidth_lines bwhist_get_bandwidth_lines \ rep_hist_update_state bwhist_update_state \ rep_hist_load_state bwhist_load_state \ rep_hist_bandwidth_assess bwhist_bandwidth_assess
2020-07-10Split bandwidth history functions into a separate C file.Nick Mathewson
These are logically independent from the rest of rephist, and make more sense in isolation. The next patch will rename them too.
2020-07-02router: Authorities add their own IPv6 to trusted dir serversteor
Authorities currently add themselves to the trusted dir servers list, but if they have an IPv6 ORPort, they leave it out. This commit makes authorities add their own IPv6 ORPort to the trusted dir servers list. Closes ticket 32822.
2020-06-26Merge branch 'assume_reachable_revamp'Nick Mathewson
2020-06-25Merge branch 'tor-github/pr/1917'David Goulet
2020-06-25Add an fingerprint-ed25519 file to the data directoryNeel Chauhan
2020-06-24Add an AssumeReachableIPv6 autobool option.Nick Mathewson
This option tells Tor that our IPv6 orport is reachable, and doesn't need to be checked. Closes the rest of 33224.
2020-06-24Add two new networkstatus parameters to emulate AssumeReachable.Nick Mathewson
These parameters do not suppress checks, but they tell relays that it's okay to publish even when those checks fail. I have chosen lowercase hyphenated names, since these seem to be more common in networkstatus params. Closes #33224 and part of #34064.
2020-06-24Rename router_should_skip_orport_reachability_check.Nick Mathewson
This was supposed to happen in #40012, but the command line was wrong. This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ router_should_skip_orport_reachability_check router_all_orports_seem_reachable
2020-06-24Merge branch 'tor-github/pr/1945'David Goulet
2020-06-24addr: Remove resolve_my_address_v4()David Goulet
Replace it by find_my_address() everywhere. This changes many parts of the code that uses it to use a tor_addr_t instead of a plain uint32_t for IPv4. Many changes to the unit test to also use the new interface. Part #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24Replace router_should_skip_*() identifiers.Nick Mathewson
These identifiers are confusing and unreadable. I think these replacements should be better. Closes ticket #40012. This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ router_should_skip_orport_reachability_check_family router_orport_seems_reachable \ router_should_skip_dirport_reachability_check router_dirport_seems_reachable \ router_should_skip_dirport_reachability_check router_all_orports_seem_reachable
2020-06-23addr: Rename resolve_my_address to be v4 specificDavid Goulet
Part of #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-09Merge remote-tracking branch 'tor-github/pr/1888/head'Nick Mathewson
2020-05-21Check for NULL from tor_dup_ip()rl1987
2020-05-11protover: Add node functions for IPv6 extend supportteor
Part of 33226.
2020-05-07Replace several C identifiers.teor
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ router_skip_orport_reachability_check router_should_skip_orport_reachability_check \ router_skip_dirport_reachability_check router_should_skip_dirport_reachability_check \ router_connect_assume_or_reachable client_or_conn_should_skip_reachable_address_check \ router_connect_assume_dir_reachable client_dir_conn_should_skip_reachable_address_check It was generated with --no-verify, so it probably breaks some commit hooks. The commiter should be sure to fix them up in a subsequent commit.
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-05config: New file resolve_addr.{c|h}David Goulet
Move a series of function from config.c into that new file which is related to address resolving. Part of #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-04-30relay: Clarify reachability status check functionsteor
This is an automated commit, generated by this command: ./scripts/maint/rename_c_identifier.py \ check_whether_orport_reachable router_skip_orport_reachability_check \ check_whether_dirport_reachable router_skip_dirport_reachability_check It was generated with --no-verify, so it probably breaks some commit hooks. The commiter should be sure to fix them up in a subsequent commit. Part of 33222.
2020-04-30relay: Refactor can extend over IPv6 checksteor
Split "can extend over IPv6" and "has advertised IPv6 ORPort" into separate functions. They currently have the same result, but this may change in 33818 with ExtendAllowIPv6Addresses. Part of 33817.
2020-04-29relay: Add IP version tests for circuit extendsteor
Add IPv4-only and IPv6-only tests for circuit_open_connection_for_extend(). Part of 33817.
2020-04-29relay: Choose between IPv4 and IPv6 extends at randomteor
When an EXTEND2 cell has an IPv4 and an IPv6 address, choose one of them uniformly at random. Part of 33817.
2020-04-12Fix typo in router_build_fresh_unsigned_routerinfo() commentNeel Chauhan
2020-03-27spell consensus more right in commentsRoger Dingledine
2020-03-21Merge branch 'bug32588_042' into bug32588_043teor
Merge static function declaration deletions from bug32588_042 and maint-0.4.3 in app/config/config.c.
2020-03-21Merge branch 'bug32588_041' into bug32588_042teor
2020-03-21Merge branch 'bug32588_035' into bug32588_041teor
Merge tests from maint-0.4.1 with new tests from bug32588_035 in test_router.c.
2020-03-21router: Refactor IPv6 ORPort function logicteor
Return early when there is no suitable IPv6 ORPort. Show the address and port on error, using a convenience function. Code simplification and refactoring. Cleanup after 32588.
2020-03-21router: Stop advertising incorrect auto IPv6 ORPortsteor
When IPv6 ORPorts are set to "auto", tor relays and bridges would advertise an incorrect port in their descriptor. This may be a low-severity memory safety issue, because the published port number may be derived from uninitialised or out-of-bounds memory reads. Fixes bug 32588; bugfix on 0.2.3.9-alpha.
2020-02-12Merge branch 'maint-0.4.1' into maint-0.4.2teor
2020-02-12Merge branch 'maint-0.3.5' into maint-0.4.1teor
2020-02-12Lowercase the BridgeDistribution value from torrc in descriptors.Alexander Færøy
This patch ensures that we always lowercase the BridgeDistribution from torrc in descriptors before submitting it. See: https://bugs.torproject.org/32753
2020-01-15Don't escape the bridge distribution value.Alexander Færøy
We already check if there are invalid values in check_bridge_distribution_setting() and reject the value if that is the case. We can therefore only have strings of [A-Z] | [a-z] | [0-9] | '-' | '_' here which is according to the directory specification. See: https://bugs.torproject.org/32753
2020-01-15Lowercase BridgeDistribution value before adding it to the descriptor.Alexander Færøy
This patch makes sure we lowercase the value of BridgeDistribution before we add it to the descriptor as `bridge-distribution-request`. See: https://bugs.torproject.org/32753
2020-01-15Always escape BridgeDistribution value from torrc in descriptors.Alexander Færøy
When the BridgeDistribution value was added in commit ebab5215252f9fa810ae091c335c5ae6e619faaf the check for whether the value contains '\n' or '\r' was added as a requirement for whether or not the value should be escaped. This patch removes this check and makes sure we call `escaped()` on the value every time before we add it to a descriptor. See: https://bugs.torproject.org/32753
2020-01-09Merge branch 'ticket22029_attempt_squashed'Nick Mathewson
2020-01-09Allow ed25519 keys to be banned in approved-routersNeel Chauhan
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2020-01-08router: Improve port search function commentsteor