aboutsummaryrefslogtreecommitdiff
path: root/src/test/test_config.c
AgeCommit message (Collapse)Author
2020-08-12Merge remote-tracking branch 'tor-gitlab/mr/62'Nick Mathewson
2020-07-30Write unittest for #40065.George Kadianakis
Make the unit test pass by including an explicit IPv6 port and an implicit IPv4 port. See comments for more details.
2020-07-24relay: Turn find address "method_used" into enumDavid Goulet
Enum allows us to easily compare what is being returned but also better semantic to the code. Related #33247 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-21relay: Automatically Enable an IPv6 ORPortDavid Goulet
This commit makes it that if the ORPort is set with a single port, it will bind to both global listen IPv4 and IPv6 addresses. To pin an "ORPort <PORT>" to be IPv4 or IPv6, the IPv4Only/IPv6Only flags are honored thus this will _only_ bind on IPv6 for that port value: ORPort 9050 IPv6Only Results in: [::]:9050 ORPort 9051 IPv4Only Results in: [0.0.0.0]:9051 Attempting to configure an explicit IPv4 address with IPv6Only flag is an error and vice versa. Closes #33246 Signed-off-by: David Goulet <dgoulet@torproject.org>
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: Add AddressDisableIPv6 torrc optionDavid Goulet
This option controls if a tor relay will attempt address auto discovery and thus ultimately publish an IPv6 ORPort in the descriptor. Behavior is from proposal 312 section 3.2.6. Closes #33245 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-20test: Move unit tests to new find address interfaceDavid Goulet
Remove use of router_pick_published_address() and use relay_find_addr_to_publish instead. Related to #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-20addr: Continue discovery if Address exits but not for wanted familyDavid Goulet
Commit b14b1f2b1d9 was a mistake. In case an Address statement is missing for the wanted family but another one exists for another family, simply continue the address discovery. It is not a mistake to be missing an Address statement for a family because the address could simply be discovered by the next methods. Not all address family requires a specific Address statement. However, we do bail if we couldn't find any valid address for the requested family _and_ a resolve failed meaning we had a hostname but couldn't resolve it. In that case, we can't know if that hostname would have been for v4 or v6 thus we can't continue the address discovery properly. Couple unit tests case were removed to match this reality. Related #40025 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-15Fix small memory leak in config include testsDaniel Pinto
Tests that used options_init_from_string were not freeing calling config_free_all().
2020-07-15Add support for patterns on %include #25140Daniel Pinto
Also adds generic tor_glob function to expand globs.
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-09Merge branch 'maint-0.4.4'Nick Mathewson
2020-07-07Revert "config: Make clients tell dual-stack exits they prefer IPv6"David Goulet
This reverts commit bf2a399fc0d90df76e091fa3259f7c1b8fb87781. Don't set by default the prefer IPv6 feature on client ports because it breaks the torsocks use case. The SOCKS resolve command is lacking a mechanism to ask for a specific address family (v4 or v6) thus prioritizing IPv6 when an IPv4 address is asked on the resolve SOCKS interface resulting in a failure. Tor Browser explicitly set PreferIPv6 so this should not affect the majority of our users. Closes #33796 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-07addr: Attempt to learn our address with ORPortDavid Goulet
If no Address statement are found in the configuration file, attempt to learn our address by looking at the ORPort address if any. Specifying an address is optional so if we can't find one, it is fine, we move on to the next discovery mechanism. Note that specifying a hostname on the ORPort is not yet supported at this commit. Closes #33236 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-06Fix coccinelle complaint in test_config.cNick Mathewson
2020-07-06addr: Fix possible memleak in find_my_address()David Goulet
Unit tests also suffered from a memleak. Closes #40024 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-02addr: Prioritize interface lookup over local hostnameDavid Goulet
The find_my_address() function now prioritize the local interface over the local hostname when guessing the IP address. See proposal 312, section 3.2.1, general case: https://gitweb.torproject.org/torspec.git/tree/proposals/312-relay-auto-ipv6-addr.txt#n359 The entire unit tests had to be refactored to make this possible. Instead of hot patching it, it has been rewritten to cover all possible cases and the test interface has been changed to accomodate both IPv4 and IPv6 in order for them to be tested identically. Closes #33238 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30test: Mixed unit tests for find_my_address()David Goulet
This unit tests validates the use of IPv4 _and_ IPv6 together as in multiple option Address lines both addresses and hostnames. Closes #33235 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30test: Unit tests for find_my_address() IPv6David Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30test: Rename function to be IPv4 specificDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24test: Modernize find_my_address() unit testDavid Goulet
Signed-off-by: David Goulet <dgoulet@torproject.org>
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-24addr: Make resolve_my_address_v4() use find_my_address()David Goulet
In order to transition smoothly, maek resolve_my_address_v4() call the new fancy find_my_address() with AF_INET. Next commits should remove the use of resolve_my_address_v4() accross the code to use find_my_address(). This commit is so the unit tests would be more easily fixed and port to the new find_my_address() internals. Part of #33233. Signed-off-by: David Goulet <dgoulet@torproject.org>
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-23config: Change Address to be a LINELISTDavid Goulet
With prop312, we want to support IPv4 and IPv6 thus multiple Address statement (up to 2) will be accepted. For this, "Address" option becomes a LINELIST so we can properly process the IPv4 or/and IPv6. Part of #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
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-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-21Add tests for get_first_advertised_{addr,port}_by_type_af()Nick Mathewson
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-20Merge branch 'tor-github/pr/1675'David Goulet
2020-01-20Merge branch 'tor-github/pr/1668'David Goulet
2020-01-20config: Make clients tell dual-stack exits they prefer IPv6teor
Make Tor clients tell dual-stack exits that they prefer IPv6 connections. This change is equivalent to setting the PreferIPv6 flag on SOCKSPorts (and most other listener ports). Tor Browser has been setting this flag for some time, and we want to remove a client distinguisher at exits. Also update the man page, putting all the IP flags in their non-default forms. Closes ticket 32637.
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 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-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-09Merge branch 'pre_formatter_cleanups_squashed'Nick Mathewson
2020-01-09Remove extra ; from tt_assert() macro definition.Nick Mathewson
We were actually omitting the semicolon in a few places, leading to confusing indentation and some cocci failures.
2020-01-08It's 2020. Update the copyright dates with "make update-copyright"Nick Mathewson
2020-01-06Merge branch 'haxxpop/tcp_proxy_squashed' into tcp_proxy_squshed_and_mergedNick Mathewson
2019-12-08add KV_RAW to kvline.cTaylor Yu
Add the KV_RAW flag to kvline_encode(). This allows generation of output that is compatible with some quirks of the control protocol. Part of #30984.
2019-12-08clean up kvline_can_encode_lines()Taylor Yu
Add a check for '=' characters in needs_escape(). This simplifies the logic in kvline_can_encode_lines(). Part of #30984.
2019-11-06Merge branch 'maint-0.4.0' into maint-0.4.1teor