aboutsummaryrefslogtreecommitdiff
path: root/src/app
AgeCommit message (Collapse)Author
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-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-07-01Merge remote-tracking branch 'dgoulet/ticket33235_045_01'Nick Mathewson
2020-06-30resolve_addr.c: remove a needless quote markNick Mathewson
2020-06-30addr: Document better is_local_addr_to_resolve_addr()David Goulet
This function is about learning if a given address is local to us as in the resolved address as a relay. Closes #40009 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30addr: Don't guess our address if no Address lines are validDavid Goulet
If at least one Address line is given but invalid, we should not attempt to guess our address. This commit sends back the "bail" signal so find_my_address() can return an error if the requested family doesn't exists but still an Address line is found which is likely another family. Fixed in #33235 Related to #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30addr: Continue trying all Address options on resolve failureDavid Goulet
When going over all Address lines from the configuration, continue to attempt resolving other lines if one fails. Before that, we would bail right away and never noticed the other Address lines. Fixed in #33235 Related to #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-30addr: Only attempt Address resolution on non parsable linesDavid Goulet
In get_address_from_config(), we would attempt to resolve an Address line that is not from the requested family but that line could be a valid address from another family (v4 vs v6). This makes it that we don't attempt to resolve a valid address from another family. Found with unit test config/find_my_address_mixed. Fixed in #33235 Related to #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-26Move remaining CodeStructure.md contents into doxygen.Nick Mathewson
2020-06-26Merge branch 'assume_reachable_revamp'Nick Mathewson
2020-06-25addr: Look at /48 for IPv6 in is_local_addr()David Goulet
Closes #33618 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-25Merge branch 'tor-github/pr/1951'David Goulet
2020-06-25Merge branch 'tor-github/pr/1917'David Goulet
2020-06-25Add an fingerprint-ed25519 file to the data directoryNeel Chauhan
2020-06-25Remove now-unused OPTIONS_DUMP_DEFAULTS.Nick Mathewson
2020-06-25Deprecate the "--dump-config non-builtin" optionNick Mathewson
When it works, "non-builtin" doesn't do anything different from "short". (When it doesn't work, it gives an assertion failure.) Closes ticket #33398.
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-24addr: Rename resolved_addr_is_local()David Goulet
Better function name. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24addr: Refactor find_my_address() to simplify itDavid Goulet
Instead of a complex if/else block, use a table of functions that have the same interface and each of them attempt to find the address one after the other. Pointed out by nickm's during review. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24addr: Set out parameters to NULL in resolve_addr.cDavid Goulet
By doing this, a memory leak was found with "hostname_used" that could have been overwritten by another function. This commit changes that by making it a NULL string instead. Found by nickm's review. Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24addr: Safeguard last resolved address index accessDavid Goulet
The last resolved address cache uses an index that is mapped to an address family (AF_INET and AF_INET6). This commit adds a conversion function from af to index and change the code to use that all the time only. In the process, this commit fixes a bug that the last resolved address accessors were using the af value insted of the index. Spotted by nickm during review 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: Refactor is_local_addr() to support IPv6David Goulet
Series of changes: 1. Rename function to reflect the namespace of the file. 2. Use the new last resolved cache instead of the unused last_resolved_addr_v4 (which is also removed in this commit). 3. Make the entire code base use the new resolved_addr_is_local() function. You will notice that this function uses /24 to differentiate subnets where the rest of tor uses /16 (including documentation of EnforceDistinctSubnets). Ticket #40009 has been opened for that. But that the moment, the function keeps looking at /24. Part of #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-24addr: Refactor last resolved address cache accessorsDavid Goulet
Series of things done in this commit: 1. Rename the functions to better reflect the namespace of the file. 2. Make both reset and get function to operate on the last_resolved_addrs cache that is per family. 3. Make the get function to take a tor_addr_t. 4. Change all callsite to use the new convention. Part of #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-24addr: New find_my_address() to support multiple address familiesDavid Goulet
resolve_my_address() was beyond repair in terms of refactoring. Way too complex and doing too many things. This commit implements find_my_address() which in theory does the same as resolve_my_address() but in a more clean, concise and modern way using the tor_addr_t interface and for multiple address family. The caller needs to pass the address family (IPv4 or IPv6) which this interface supports. For both, a last resolved cache is used as well. Implements #33233 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-06-23addr: Rename last_resolved_addr to be v4 specificDavid Goulet
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-06-15Remove AssumeReachable from TestingTorNetwork.Nick Mathewson
Closes ticket 34446.
2020-06-05Merge remote-tracking branch 'tor-github/pr/1902/head'Nick Mathewson
2020-06-01config: Add IPv4 Address config debug loggingc
Per ticket #32888 this should address logging "the Address torrc option", "and whether it is an IP address, or a DNS name"; or the detected "local hostname", "and whether it is an IP address, or a DNS name". Some of these details already seem to be logged, so just add what's missing.
2020-05-27Merge branch 'tor-github/pr/1898'George Kadianakis
2020-05-27Add HS v3 status to the SIGUSR1 dumpstats()Neel Chauhan
2020-05-21Merge remote-tracking branch 'tor-github/pr/1899/head'Nick Mathewson
2020-05-21Merge branch 'tor-github/pr/1850'George Kadianakis
2020-05-21Check for NULL from tor_dup_ip()rl1987
2020-05-20Add support for console control signals in WindowsDamon Harris
2020-05-16Fix spacing in if statement in port_parse_config()Neel Chauhan
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-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-04-09Merge remote-tracking branch 'tor-github/pr/1801/head'Nick Mathewson
2020-04-09client: Revert setting PreferIPv6 on by defaultDavid Goulet
This change broke torsocks that by default is expecting an IPv4 for hostname resolution because it can't ask tor for a specific IP version with the SOCKS5 extension. PreferIPv6 made it that sometimes the IPv6 could be returned to torsocks that was expecting an IPv4. Torsocks is probably a very unique case because the runtime flow is that it hijacks DNS resolution (ex: getaddrinfo()), gets an IP and then sends it back for the connect() to happen. The libc has DNS resolution functions that allows the caller to request a specific INET family but torsocks can't tell tor to resolve the hostname only to an IPv4 or IPv6 and thus by default fallsback to IPv4. Reverting this change into 0.4.3.x series but we'll keep it in the 0.4.4.x series in the hope that we add this SOCKS5 extension to tor for DNS resolution and then change torsocks to use that. Fixes #33804 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-04-01Updated the TestingTorNetwork man page optionsSteven Engler
Updated 'doc/tor.1.txt' to match 'src/app/config/testnet.inc'.
2020-04-01Move LOG_PROTOCOL_WARN to app/config.hteor
LOG_PROTOCOL_WARN was in core/or.h, but the function it depends on is in app/config.h. Put them in the same header, to reduce dependencies. Part of 33633.
2020-03-26Add --dbg-dump-subsystem-list command to list the subsystems.Nick Mathewson
I'm prefixing this with --dbg-* because it is not meant to be used externally.
2020-03-26Implement a function to list the subsystems to stdout.Nick Mathewson