Commit Graph

25452 Commits

Author SHA1 Message Date
Nick Mathewson
e2637214f2
split a wide line 2020-01-20 15:48:49 +10:00
Nick Mathewson
152cbf2a59
Rename routerstatus_has_changed to routerstatus_has_visibly_changed
This is an automated commit, generated by this command:

./scripts/maint/rename_c_identifier.py \
        routerstatus_has_changed routerstatus_has_visibly_changed

It was generated with --no-verify, since it introduces a wide line.
I'll fix it in a subsequent commit.
2020-01-20 15:48:45 +10:00
Nick Mathewson
c3633e6b29
Update routerstatus_has_changed tests.
Now they also check whether output of routerstatus_format_entry()
has changed.
2020-01-20 15:48:41 +10:00
Nick Mathewson
702a753cf3
Add unit test for routerstatus_has_changed() 2020-01-20 15:48:25 +10:00
teor
0b82b5ee42
Merge remote-tracking branch 'tor-github/pr/1671' 2020-01-20 15:40:42 +10:00
Nick Mathewson
5086b16055 Merge remote-tracking branch 'tor-github/pr/1529' 2020-01-17 08:49:56 -05:00
Nick Mathewson
c8b6392b4e Initialize publish/subscribe code when running as an NT service.
Fixes bug 32778; bugfix on 0.4.1.1-alpha.
2020-01-17 08:41:52 -05:00
Nick Mathewson
d7a22160f5 Revert "Restore feature where nt-services detect non-"run_tor" modes."
This reverts commit 5c240db0bf.
2020-01-17 08:39:49 -05:00
Nick Mathewson
7f03ba06d8 Merge branch 'ticket32806' 2020-01-17 08:37:33 -05:00
Nick Mathewson
6d2b9c9631 Remove some dead checks
The only code that could set these options to be negative was in the
unit tests.
2020-01-17 08:31:22 -05:00
Nick Mathewson
648e1afc33 fix a stray asterisk in a comment 2020-01-17 08:25:09 -05:00
Nick Mathewson
abd9ae48ac Merge branch 'ticket32487_squashed_and_merged' 2020-01-17 07:50:50 -05:00
Nick Mathewson
01fdc3240f Merge branch 'ticket32695_squashed' 2020-01-16 16:42:01 -05:00
Nick Mathewson
ceacda44f1 Remove functions that checked for pre-ipv6 consensus.
We no longer need or need to test:
  * node_awaiting_ipv6()
  * networkstatus_consensus_has_ipv6().
2020-01-16 16:41:53 -05:00
Nick Mathewson
8d94bcbf8c Remove routerstatus_format_entry() consensus_method argument as unused 2020-01-16 16:41:53 -05:00
Nick Mathewson
441a048a3a Remove support for now-obsolete consensus methods before 28.
Closes ticket 32695.
2020-01-16 16:41:53 -05:00
Nick Mathewson
60a0d7d1e8 expose routerstatus_has_changed to unit tests. 2020-01-16 12:14:12 -05:00
Victor Nepveu
594e5ce635 Refactor routerstatus_has_changed function
- Check all fields that might change in a routerstatus
- Document the refactoring

Signed-off-by: Victor Nepveu <victor.nepveu@imt-atlantique.net>
2020-01-16 10:39:15 -05:00
Nick Mathewson
17c63ff9f6 Merge remote-tracking branch 'tor-github/pr/1663' 2020-01-16 10:24:39 -05:00
Nick Mathewson
3c89622e39 Merge branch 'ticket32487_squashed' into ticket32487_squashed_and_merged
Resolved conflicts in src/core/include.am
2020-01-16 07:57:37 -05:00
Nick Mathewson
efb301c86c Document why dircache is not included in --list-modules 2020-01-16 07:48:17 -05:00
Nick Mathewson
a623a49777 Add have_module_dircache(). 2020-01-16 07:48:17 -05:00
Nick Mathewson
5cff1ce84b Turn several functions from stubs into macros
This may help the compiler eliminate deadcode.
2020-01-16 07:48:17 -05:00
Nick Mathewson
6ba4b5e5da Rename dirclient_modes.h identifiers to start with dirclient_
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-16 07:48:17 -05:00
Nick Mathewson
8d1f31190e Move directory_must_use_begindir() to dirclient_modes.[ch] 2020-01-16 07:48:17 -05:00
Nick Mathewson
773bcf5629 Move dirclient-related functions out of dirserv, and reenable them
I had incorrectly identified these functions as dircache-only, when
in fact they apply to everyone who acts a directory client.
2020-01-16 07:48:17 -05:00
Nick Mathewson
8a0c739467 Disable feature/dircache files when dircache module is disabled.
To make Tor still work, we define a minimal dircache_stub.c file
that defines the entry points to the module that can actually be
seen by the compiler when we're building with dircache and relay
disabled.
2020-01-16 07:48:17 -05:00
Nick Mathewson
6e12a8f047 Use dir_conn_clear_spool() in connection.c.
This is cleaner than iterating over the spool.
2020-01-16 07:48:17 -05:00
Nick Mathewson
fe8156dbc2 Move dirserv_get_routerdescs() to control_getinfo.c
This function had some XXX comments indicating (correctly) that it
was not actually used by the dirserver code, and that only the
controller still used it.
2020-01-16 07:48:17 -05:00
Nick Mathewson
4cf15ee015 Move dir_split_resource_into_spoolable() to dircache module.
Only directory caches actually need to spool things.
2020-01-16 07:48:17 -05:00
teor
fb541ffca3
Merge branch 'maint-0.4.0' into maint-0.4.1 2020-01-16 10:00:40 +10:00
teor
026f068bb3
Merge branch 'maint-0.3.5' into maint-0.4.0 2020-01-16 10:00:32 +10:00
teor
19954cffd7
Merge remote-tracking branch 'tor-github/pr/1513' into maint-0.3.5 2020-01-16 09:57:27 +10:00
Alexander Færøy
ca9a5390ff Don't escape the bridge distribution value.
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-15 23:41:58 +00:00
teor
f3cbc26bdd
add_c_file: Fix "control line not preceded by a blank line"
Fix dirauth and relay module include.am add_c_file.py
"control line not preceded by a blank line" errors.

Also remove a duplicate ADD_C_FILE: SOURCES in the relay module.

Obviously correct fixes to already-reviewed code.
2020-01-16 09:38:26 +10:00
Alexander Færøy
399ec3130b Remove "hyphae" as a known value for BridgeDistribution.
This patch removes hyphae as a known value for the BridgeDistribution
option in torrc.
2020-01-15 23:20:27 +00:00
Nick Mathewson
5e70c27e85 Merge remote-tracking branch 'tor-github/pr/1657' 2020-01-15 13:10:14 -05:00
Alexander Færøy
1c8bafcdf9 Lowercase BridgeDistribution value before adding it to the descriptor.
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-15 17:22:47 +00:00
Alexander Færøy
026f0c7184 Make BridgeDistribution setting validator case-insensitive.
This patch makes sure that we accept values such as "nOne", "None", and
"AnY" as valid values for BridgeDistribution. We later ensure to
lower-case the values before they are forwarded to the BridgeDB.

See: https://bugs.torproject.org/32753
2020-01-15 17:21:10 +00:00
Alexander Færøy
3f20a69afb Always escape BridgeDistribution value from torrc in descriptors.
When the BridgeDistribution value was added in commit
ebab521525 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-15 17:18:30 +00:00
Nick Mathewson
77246dc0d8 Tell static analyzer that having ntservice functions not exist is ok
When we made these functions exist unconditionally (as macros on
non-windows platforms), we started to get a dead-code warning on
Coverity.  We now use a macro to tell coverity not to worry about
this particular dead-code instance.
2020-01-15 10:30:03 -05:00
Nick Mathewson
5e27caa60c compat_compiler: add a macro to prevent coverity deadcode warnings.
The POSSIBLE(e) macro evaluates to the value of (e), but does so in
a way that a static analyzer will not conclude that (e) is
impossible.  We can use this when we expect our regular compilers to
eliminate deadcode, but we don't want coverity to complain about it.

Part of a fix for 32960.
2020-01-15 10:21:18 -05:00
teor
5fa7c1b13f
Merge remote-tracking branch 'tor-github/pr/1661' 2020-01-16 00:46:31 +10:00
Nick Mathewson
08bbb6b8d9 Merge branch 'ticket32892_043_01_squashed' 2020-01-14 13:31:20 -05:00
David Goulet
59dac38ebe chan: Remove dead var cell handler from channel_t
The variable lenght cells are handled directly by
channel_tls_handle_var_cell() from an OR connection reading its inbuf. The
channel var cell handler (agnostic) was never used.

Closes #32892

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-01-14 13:31:08 -05:00
Nick Mathewson
165a92e33f Replace an assertion with a check-and-log
We hit this assertion with bug 32868, but I'm stymied figuring out
how we wound up with a routerstatus like this.  This patch is a
diagnostic to attempt to figure out what is going on, and to avoid a
crash in the meantime.
2020-01-14 13:16:39 -05:00
Nick Mathewson
c948db4252 Merge remote-tracking branch 'tor-github/pr/1636' 2020-01-14 12:46:14 -05:00
Nick Mathewson
c2dc94d8eb Merge branch 'ticket32883' 2020-01-14 12:42:41 -05:00
Nick Mathewson
dec11793ba Merge branch 'ticket32825_squashed' 2020-01-14 12:42:19 -05:00
Nick Mathewson
ac7d6f3c05 Rename UTIL_TEST_NO_WIN to reflect intent
Now that these tests are skipped on windows _and_ android, we should
name the macro that skips them after the functionality that the
tests depend on.

Closes last part of 32825.
2020-01-14 12:42:13 -05:00
Nick Mathewson
75741c6b3a Merge remote-tracking branch 'tor-github/pr/1659' 2020-01-14 12:40:07 -05:00
Neel Chauhan
8d288eb3a7 Deprecate the ClientAutoIPv6ORPort option 2020-01-13 14:55:16 -08:00
Nick Mathewson
73ac1add3f Split core/include.am into per-subdirectory include.am files
Closes ticket 32137.
2020-01-13 09:34:17 -05:00
David Goulet
bbe90e3ec1 hs-v2: Always check rend_cache validity before using it
When looking up an entry in the rend_cache, stop asserting that it exists but
rather confirm it exists and if not, return that no entry was found.

The reason for that is because the hs_circ_cleanup_on_free() function (which
can end up looking at the rend_cache) can be called from the
circuit_free_all() function that is called _after_ the rend cache is cleaned
up in tor_free_all().

We could fix the free all ordering but then it will just hide a future bug.
Instead, handle a missing rend_cache as a valid use case as in while we are in
the cleanup process.

As Tor becomes more modular, it is getting more and more difficult to ensure
subsystem callstack ordering thus this fix aims at making the HSv2 subsystem
more robust at being called while tor is pretty much in any kind of state.

Fixes #32847.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-01-13 09:25:26 -05:00
Nick Mathewson
5888db4967 Merge branch 'disable_ns_macro' 2020-01-09 16:02:41 -05:00
Nick Mathewson
93894fb770 Merge branch 'ticket22029_attempt_squashed' 2020-01-09 15:27:32 -05:00
Neel Chauhan
9129de7017 Add dirserv_load_fingerprint_file() test 2020-01-09 15:27:26 -05:00
Neel Chauhan
d0068be0dd Allow ed25519 keys to be banned in approved-routers 2020-01-09 15:27:26 -05:00
Nick Mathewson
e28e41dd78 Fix wide lines from NS() removal fallout. 2020-01-09 11:43:49 -05:00
Nick Mathewson
42c6fc851e Remove NS*() macros from test.h.
We never used them very much, and although they had potential to
clarify some of our tests, they also made some of the logic harder
for people to follow.  Clang-format can't make head or tail of them,
so the time has come to say goodbye to them.
2020-01-09 11:09:31 -05:00
Nick Mathewson
23c77f79fd Remove all usage of the NS*() macros in test*.c
This is an automatically generated commit, made with the following
kludgey perl script. It results in a number of wide lines, which
I'll clean up in a subsequent commit.

#/usr/bin/perl -w -i
$mod = "NS_MODULE";
$submod = "NS_SUBMODULE";
$last_was_empty = 0;

while (<>) {

    s/\bASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/$1_$2/;

    if (/# *define +NS_MODULE +(\w+)/) {
        $mod = $1;
        next;
    } elsif (/# *define +NS_SUBMODULE +(\w+)/) {
        $submod = $1;
        next;
    }

    next if (/#undef NS_(SUB)?MODULE/);

    s/NS\(\s*test_main\s*\)/test_${mod}_${submod}/;
    s/NS\(\s*(\w+)\s*\)/${mod}_${submod}_$1/g;
    s/NS_FULL\(\\s*(\w+)\s*,\s*(\w+),\s*(\w+)\s*\)/$1_$2_$3/;
    s/^(\s*)NS_MOCK\(\s*(\w+)\s*\)/$1MOCK($2,\n$1     ${mod}_${submod}_$2)/;
    s/NS_UNMOCK\(\s*(\w+)\s*\)/UNMOCK($1)/;
    s/TEST_CASE\(\s*(\w+)\s*\)/{ "$1", test_${mod}_$1, TT_FORK, NULL, NULL }/;
    s/TEST_CASE_ASPECT\(\s*(\w+)\s*,\s*(\w+)\s*\)/{ "$1_$2", test_${mod}_$1_$2, TT_FORK, NULL, NULL }/;
    s/NS_DECL\(\s*([^,]+)\s*,\s*([^,]+)\s*,\s*(\(.*)\);/static $1 ${mod}_${submod}_$2$3;\nATTR_UNUSED static int ${mod}_${submod}_$2_called = 0;/;
    s/\bCALLED\(\s*(\w+)\s*\)/${mod}_${submod}_$1_called/;

    if (/^$/) {
        print if (! $last_was_empty);
        $last_was_empty = 1;
    } else {
        $last_was_empty = 0;
        print;
    }

    if (eof) {
        $mod = "NS_MODULE";
        $submod = "NS_SUBMODULE";
        $last_was_empty = 0;
    }
}

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
#	modified:   src/test/test_accounting.c
#	modified:   src/test/test_compat_libevent.c
#	modified:   src/test/test_dir.c
#	modified:   src/test/test_dir_handle_get.c
#	modified:   src/test/test_dns.c
#	modified:   src/test/test_options.c
#	modified:   src/test/test_procmon.c
#	modified:   src/test/test_rendcache.c
#	modified:   src/test/test_router.c
#	modified:   src/test/test_routerset.c
#	modified:   src/test/test_status.c
#	modified:   src/test/test_tortls.c
#	modified:   src/test/test_tortls_openssl.c
#	modified:   src/test/test_util_format.c
#	modified:   src/test/test_util_process.c
#
# Untracked files:
#	experiments/
#	locate_options.sh
#	un_ns.pl
#

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Thu Jan 9 10:26:10 2020 -0500
#
# On branch disable_ns_macro
# Changes to be committed:
#	modified:   src/test/test_accounting.c
#	modified:   src/test/test_compat_libevent.c
#	modified:   src/test/test_dir.c
#	modified:   src/test/test_dir_handle_get.c
#	modified:   src/test/test_dns.c
#	modified:   src/test/test_options.c
#	modified:   src/test/test_procmon.c
#	modified:   src/test/test_rendcache.c
#	modified:   src/test/test_router.c
#	modified:   src/test/test_routerset.c
#	modified:   src/test/test_status.c
#	modified:   src/test/test_tortls.c
#	modified:   src/test/test_tortls_openssl.c
#	modified:   src/test/test_util_format.c
#	modified:   src/test/test_util_process.c
#
# Untracked files:
#	experiments/
#	locate_options.sh
#	un_ns.pl
#
2020-01-09 11:09:22 -05:00
Nick Mathewson
c9855f23c1 Replace various NS_MODULE/SUBMODULE vals with shorter names.
This will help avoid wide lines in our output.
2020-01-09 11:08:18 -05:00
Nick Mathewson
e2fcfc6e52 Put all NS_DECL invocations on single lines.
This is going to make my script happier; these lines will soon
disappear.
2020-01-09 10:06:35 -05:00
Nick Mathewson
1ffba2f121 Always define NS_MODULE and NS_SUBMODULE when NS is used.
When these macros aren't defined, the expansions of the NS macros
can get particularly ugly.
2020-01-09 09:56:41 -05:00
Nick Mathewson
e45810113b Merge branch 'pre_formatter_cleanups_squashed' 2020-01-09 07:32:39 -05:00
Nick Mathewson
3ad518cd97 process.h: include stdbool.h
We use bool, so we should include stdbool.
2020-01-09 07:30:35 -05:00
Nick Mathewson
ca9d605fa7 conscache.h: declare config_line_t structure.
This frees us from a dependency on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
09f03e6e3f Turn authdir_mode_v3() into a non-inline function
This change means that authmode.h no longer needs to see
or_options_t, and frees us from an ordering dependency.
2020-01-09 07:30:35 -05:00
Nick Mathewson
2f7a2c42d2 Include ht.h in all headers that use HT_ENTRY()
Without this change, compilation success depends on include order in
several tricky ways.
2020-01-09 07:30:35 -05:00
Nick Mathewson
afa36682f9 consdiffmgr.h: use struct declarations for several types
This prevents a dependency on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
06d977b569 hs_circuitmap.h: use a struct declaration
This fixes a case where our compilation would depend on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
887bf05c24 routerparse.h: include parsecommon.h when exposing token table.
Without this include, our compilation depends more on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
774d1092fd process.h: add a struct declaration for buf_t.
This lets us avoid a dependency on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
dd5dda78f6 timers.h: add declaration for timeval.
This frees us from some dependencies on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
25354171b5 lib/conf: include torint.h in files that use it.
This frees us from some dependencies on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
8d4b4aa932 control_hs.h: use a couple of struct delcarations
Doing this frees us from some assumptions about include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
8b7eeea39d connection.h: new includes and struct declarations
Using these frees us from several dependencies on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
c4ac5adc4a siphash.h: include stdint.
Doing this gives us a valid uint64_t type, freeing us from
dependencies on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
6a6486a7bf hs_circuit: use struct declaration.
This frees us from a dependency on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
d7b8377c28 or_options_st.h: Add an include and a struct declaration.
This frees us from some dependencies on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
8bb686d8a0 Include x509.h in tortls_internal.h.
This gives us the definition of tor_x509_cert_impl_t, and makes us
less dependent on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
b1dceeca5a Include sys/types.h in fdio.h, for "off_t".
Otherwise our compilation depends on include order.
2020-01-09 07:30:35 -05:00
Nick Mathewson
7b0d8834f2 Use raw_assert in ht.h
Also, include torerr.h from ht.h if we are using raw_assert.

Otherwise, our includes need to be ordered so that ht.h comes after
util_log.h.
2020-01-09 07:30:35 -05:00
Nick Mathewson
73b83b8f1a Remove extra ; from tt_assert() macro definition.
We were actually omitting the semicolon in a few places, leading to
confusing indentation and some cocci failures.
2020-01-09 07:30:35 -05:00
Nick Mathewson
3ce2304c6d Use new ENABLE/DISABLE_GCC_WARNING
This is an automated commit, generated by:

perl -i -pe 'next if /define/; s/((?:ENABLE|DISABLE)_GCC_WARNING)\(([A-Za-z0-9_\-]+)\)/$1(\"-W$2\")/' src/*/*/*.[ch] src/*/*.[ch]
2020-01-09 07:30:35 -05:00
Nick Mathewson
792e5b2403 Replace DISABLE/ENABLE_GCC_WARNING with something that will confuse clang-format less 2020-01-09 07:30:35 -05:00
Nick Mathewson
a48cb9fa43 core/include.am: spelling fix 2020-01-08 20:50:02 -05:00
Nick Mathewson
4f02812242 It's 2020. Update the copyright dates with "make update-copyright" 2020-01-08 18:39:17 -05:00
Nick Mathewson
2d27a3ecc0 Run "make autostyle"; add an endif comment 2020-01-08 18:38:24 -05:00
teor
a58cffe195
router: Improve port search function comments 2020-01-08 17:47:08 +10:00
Roger Dingledine
81fd8aad24 speaking of utf-8, remove strange char from comment 2020-01-07 18:25:17 -05:00
Nick Mathewson
e231cd5b61 Merge branch 'ticket32845_squashed' 2020-01-07 10:16:15 -05:00
teor
0e3fd4df99 string: Check UTF-8 string pointer and length
If they are inconsistent, output a raw bug log.

Part of 32845.
2020-01-07 10:16:08 -05:00
Nick Mathewson
17a1ae025a Merge remote-tracking branch 'tor-github/pr/1640' 2020-01-07 08:59:31 -05:00
Nick Mathewson
c48068ece3 test_helpers: add a missing free for CID 1457527. 2020-01-07 08:22:02 -05:00
Nick Mathewson
f2aeaaf71d Add new state to connection_proxy_state_to_string()
Also, add a CTASSERT() to make sure that we don't let this array get
out-of-sync again.

Found by coverity; this is CID 1457528.
2020-01-07 08:09:27 -05:00
teor
d62dbb6762 string: Add extra UTF-8 test cases
These test cases are validated differently by some
programming languages, because those languages have
incorrect UTF-8 implementations.

We want to make sure that tor validates them correctly.

Closes ticket 32845.
2020-01-07 17:05:48 +10:00
Neel Chauhan
ee015d36f8 Space the a-d unsigned ints in tor_inet_aton() 2020-01-06 20:20:38 -08:00
Nick Mathewson
1b63eea66c Merge branch 'haxxpop/tcp_proxy_squashed' into tcp_proxy_squshed_and_merged 2020-01-06 13:41:20 -05:00
Suphanat Chunhapanya
4264717ca3 test: HTTP CONNECT protocol 2020-01-06 13:39:10 -05:00