Commit Graph

26692 Commits

Author SHA1 Message Date
Nick Mathewson
d9221968ce Include a more modest openssl header in crypto_openssl_mgt.h
The "engines.h" header has lots of stuff; the "opensslv.h" header
has the version number, which is all we actually need here.

We need to do this because we're about to change this header to
conditionally define OPENSSL_SUPPRESS_DEPRECATED, and it would be
too late to do so if we'd already included "engines.h".
2020-10-28 10:11:42 -04:00
Nick Mathewson
511822529a Revise fix for bug 32178 (spaces at end of log msg).
The loop in the earlier patch would invoke undefined behavior in two
ways: First, it would check whether it was looking at a space before
it checked whether the pointer was in-range.  Second, it would let a
pointer reach a position _before_ the start of a string, which is
not allowed.

I've removed the assertion about empty messages: empty messages can
be their own warning IMO.

I've also added tests for this formatting code, to make sure it
actually works.
2020-10-28 09:41:51 -04:00
Amadeusz Pawlik
ec7a6757ec Removes trailing spaces in control event log 2020-10-28 09:08:53 -04:00
David Goulet
2edda444da test: Missing tor_free() in metrics unit tests
Found by coverity:

  *** CID 1468664:  Resource leaks  (RESOURCE_LEAK)
  /src/test/test_metrics.c: 83 in test_config()
  77       tt_int_op(ret, OP_EQ, false);
  78
  79      done:
  80       SMARTLIST_FOREACH(ports, port_cfg_t *, c, port_cfg_free(c));
  81       smartlist_free(ports);
  82       or_options_free(options);
  >>>     CID 1468664:  Resource leaks  (RESOURCE_LEAK)
  >>>     Variable "err_msg" going out of scope leaks the storage it points to.
  83     }
  84
  85     static char _c_buf[256];
  86     #define CONTAINS(conn, msg) \
  87       do { \
  88         tt_int_op(buf_datalen(conn->outbuf), OP_EQ, (strlen(msg))); \

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-28 08:52:02 -04:00
Neel Chauhan
0c79cddc6b Avoid asserts with flag 2020-10-27 14:47:42 -07:00
David Goulet
362229f184 lib/metrics: Fix wrong macro expansion
The "METRICS_PREFIX" was not expanded but rather used as a litteral. Fix that
by just removing the define and using "tor_" directly.

Reviewed-by: Alexander Færøy <ahf@torproject.org>
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 13:00:20 -04:00
David Goulet
5de6673972 metrics: Add tor_ namespace to all metrics
Closes #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
238340ce54 test: Add test for onion service metrics module
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
f65c0820af test: Metrics tests for lib/ and feature/
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
4c19eed35c tests: Fix unit tests after adding new HS metrics module
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
1c06c9f1c0 doc: Initial documentation of the lib/metrics
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
97731196c4 hs: Collect introduction circuit metrics
Tracks the total number of established introduction circuit.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
c081bee38a hs: Collect rendezvous circuit metrics
The total number of rendezvous circuit created and the number of established
ones which is a gauge that decreases to keep an updated counter.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
2fe0322fe4 hs: Collect service traffic metrics
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
695957511b hs: Always note the virtual port in the ident
Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
50f44afeb4 hs: New metrics module
At this commit, a new service registers to the module and a store is created.
It also remove itself from the metrics module if it goes away.

In order to hook into the metrics subsystem, this commit attaches the HS
subsystem into the subsystem global list so its get_metrics() call can be
accessible.

HS initialization is still _not_ done through the subsys module as it is
likely require much more testing.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
4f5cea1f59 conn: New Metrics listener port
If MetricsPort is defined, listen on it and handle the incoming request.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
a882d1bf0a metrics: New feature module to track tor metrics
Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
ec731290a5 lib: New metrics library
Used to provide an interface to create metrics store and update the entries.

Related to #40063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-27 10:43:42 -04:00
David Goulet
26cfac1880 Merge branch 'tor-gitlab/mr/176' into maint-0.4.4 2020-10-27 10:18:16 -04:00
David Goulet
6338fc2afa Merge branch 'tor-gitlab/mr/173' 2020-10-27 09:43:04 -04:00
David Goulet
683c794273 Merge branch 'tor-gitlab/mr/176' 2020-10-27 09:36:16 -04:00
Nick Mathewson
c90535c539 Merge branch 'maint-0.4.4' 2020-10-26 16:39:31 -04:00
George Kadianakis
07f2a06c61 Merge remote-tracking branch 'tor-gitlab/mr/169' into master 2020-10-26 17:04:58 +02:00
Nick Mathewson
f43fe890dd Merge remote-tracking branch 'tor-gitlab/mr/127' 2020-10-23 11:47:40 -04:00
Nick Mathewson
fd58e74ddc Update required/recommended protocol lists more systematically
First I began with a set of candidates:

  The client's _required_ list starts with all the protocols
  supported by every release in 0.2.9-stable through current
  master.

  The client's _required_ list starts with all the protocols
  supported by every release in 0.3.5-stable through current
  master.

  Everybody's _recommended_ list starts with all the protocols
  supported by every release in 0.3.5-stable through current master.

Then I removed the protocol versions that we do not actually want to
require or recommend:

  DirCache=1 (deprecated)
  HSDir=1, HSIntro=1-3, HSRend=1 (deprecated)
  (All HS* protocol requirements for clients)
  Link=1-3 (deprecated)
  LinkAuth=1 (obsolete)
  Relay=1 (obsolete)
2020-10-23 11:23:08 -04:00
Nick Mathewson
2908086694 Merge branch 'combined_libs' 2020-10-23 10:33:07 -04:00
Roger Dingledine
00118355f5 Turn ConsensusParams into a Linelist
Make it possible to specify multiple ConsensusParams torrc
lines.

Now directory authority operators can for example put the
main ConsensusParams config in one torrc file and then add to it
from a different torrc file.

Closes ticket 40164.
2020-10-22 03:26:03 -04:00
David Goulet
0d420918e7 main: Off by one when dumping subsystem list
Fixes #40163

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-21 13:48:37 -04:00
Daniel Pinto
bb9707420e Allow mutiple lines on configuration for ROUTERSET entries. #28361
Affected entries are: EntryNodes, ExcludeNodes, ExcludeExitNodes,
ExitNodes, MiddleNodes, HSLayer2Nodes and HSLayer3Nodes.
2020-10-21 01:53:50 +01:00
Guinness
0668437b58
Set is_padding_timer_scheduled to 0
When calling `circpad_send_padding_cell_for_callback()`, the flag
`is_padding_timer_scheduled` was not resetted to 0 which caused an issue
in the circpad simulator.
This commit fixes this problem.

Fixes #32671.
2020-10-20 21:04:33 +02:00
Nick Mathewson
579f200efc Merge branch 'mr_175_squashed' 2020-10-20 09:03:26 -04:00
Guinness
5248d08ede Consider 301 as an error like 404
Tor does not follow redirects when bootstraping so we encountered an
error.

Fixes #40053
2020-10-20 08:57:42 -04:00
George Kadianakis
19302a1dfd Merge remote-tracking branch 'tor-gitlab/mr/148' into master 2020-10-20 13:26:19 +03:00
Nick Mathewson
cb4cedae68 Explain why we use "mark_as_used_for_origin_circuit" where we do
Also, explain why it's relevant for bootstrapping.

This is a comments-only patch.
2020-10-19 11:45:24 -04:00
Nick Mathewson
f7adf3653f Simplify logic to use smartlist_add_asprintf() 2020-10-19 11:24:32 -04:00
Nick Mathewson
151d446aa1 Merge remote-tracking branch 'tor-gitlab/mr/167' 2020-10-19 11:15:20 -04:00
Nick Mathewson
d872c69255 Update required/recommended protocol versions.
Cons=1 is the old format of consensuses, without ed25519 keys. It
  is no longer required or recommended.

  Cons=2 is the new format of consensuses, with ed25519 keys. It
  is now required.

  (Similarly for Desc=1,2 and Microdesc=1,2)

No supported client or relay versions should be affected by this
change, since these versions are supported by clients and relays
running 0.2.9 and later.  It will only take effect once enough
authorities vote for it.

Closes ticket 40162.
2020-10-18 16:23:53 -04:00
Nick Mathewson
4298d87756 Split required/recommended protocol lists into multiple lines
This should make diffs easier to read.
2020-10-18 16:18:42 -04:00
Nick Mathewson
62667b49e9 Regenerate extample_extrainfo.inc and adjust tests. 2020-10-16 16:07:46 -04:00
Nick Mathewson
5032b8f178 Regenerate complete failing_routerdescs.inc and adjust tests accordingly. 2020-10-16 16:07:46 -04:00
Nick Mathewson
0031d2b0ad Update makedesc.py script so that it works with python3. 2020-10-16 16:07:46 -04:00
Nick Mathewson
98c4e218b8 Update slow_ed25519.py to work with python 3. 2020-10-16 16:07:46 -04:00
Nick Mathewson
5e2294c6fe Fix formats_rsa_ed25519 tests.
The "protos" field is mandatory, and so are Ed25519 signatures.

Also, remove formats_rsa (the version without Ed25519), since
RSA-only relays are no longer supported.
2020-10-16 16:07:46 -04:00
Nick Mathewson
84c13a35db Add pr= lines to test_dir_clip_unmeasured*. 2020-10-16 16:07:46 -04:00
Nick Mathewson
bae5ba8073 Fix a couple of routerstatus-based tests. 2020-10-16 16:07:46 -04:00
Nick Mathewson
61a5a303f9 Replace the contents of test_descriptors.inc with a new set.
Had to replace these since we're updating the list of required fields.

These are taken from a chutney instance.  Shockingly, this is enough
to make the test_dir_handle_get.c tests pass again.
2020-10-16 16:07:46 -04:00
Nick Mathewson
769882ea7c test_dir_handle_get: add ntor-onion-key to microdescriptor example
Shockingly, this test didn't break after this change!
2020-10-16 16:07:46 -04:00
Nick Mathewson
acf4225441 Fix up vote tests in test_dir_handle_get.
These tests used a hardcoded vote with a hardcoded digest.  That
vote didn't have any pr lines, and so it is now invalid. I've
adjusted the testing code so that it mocks the signature-checking,
so that we can more easily change the contents of the vote.
2020-10-16 16:07:46 -04:00
Nick Mathewson
36ea25c236 Fix the tests in test_microdesc.c
This was fairly simple: just had to replace the examples with ones
that had ntor keys.  There were a couple of example chutney
routerinfos that I had to replace too.

I also removed tests for producing microdescs via consensus methods
that we don't support any longer.
2020-10-16 16:07:46 -04:00
Nick Mathewson
bb275e3712 Fix router/dump_router_to_string_no_bridge_distribution_method
The descriptor it generated needed to include ed25519 keys; needed
to have a correct TAP crosscert.
2020-10-16 16:07:46 -04:00
Nick Mathewson
6d419a3da3 test_dir_common: make sure we include pr lines. Fixes 7 tests. 2020-10-16 07:40:54 -04:00
Nick Mathewson
e934d713b3 Mark as required fields from prop315.
This change breaks some unit tests; it's time to fix those in
subsequent commits.
2020-10-15 18:02:16 -04:00
Nick Mathewson
47d6eef190 Also, include ed25519 identities in connection_describe().
Related to #22668.
2020-10-15 10:53:45 -04:00
Nick Mathewson
5718f38c85 Add ed25519 identities to relay descriptions.
(Or at least, to all those relay descriptions that derive from
format_node_description()).

Closes #22668.
2020-10-15 10:29:01 -04:00
Nick Mathewson
93e7661fef Add a function to get an ed25519 ID from a routerinfo. 2020-10-15 10:20:42 -04:00
Nick Mathewson
33fb51a111 Protover: simplify implementation structure to use 64-bit property
Now that prop318 is in, we can simplify our representation for
protocol range sets to just be a bitmask.
2020-10-14 13:09:29 -04:00
Nick Mathewson
4a80dde43c Merge branch 'prop318_limit_protover_035' into prop318_limit_protover_045 2020-10-14 11:31:58 -04:00
Nick Mathewson
dd63b97288 Implement proposal 318: Limit protovers to 0..63
In brief: we go through a lot of gymnastics to handle huge protover
numbers, but after years of development we're not even close to 10
for any of our current versions.  We also have a convenient
workaround available in case we ever run out of protocols: if (for
example) we someday need Link=64, we can just add Link2=0 or
something.

This patch is a minimal patch to change tor's behavior; it doesn't
take advantage of the new restrictions.

Implements #40133 and proposal 318.
2020-10-14 11:28:37 -04:00
David Goulet
bb249a221f Merge branch 'tor-gitlab/mr/170' 2020-10-14 09:46:44 -04:00
Nick Mathewson
42a5e652cb Make OptimisticData always-on.
We've been using it for years, and it seems to work just fine.  This
patch removes the option and its network parameter.

Part of #40139
2020-10-13 14:38:32 -04:00
Nick Mathewson
ac311a38ec Make "usecreatefast" always-off.
Part of #40139, where I'm removing network parameters that we
shouldn't be looking at any longer.
2020-10-13 14:00:34 -04:00
Alexander Færøy
78aa037c41 Merge remote-tracking branch 'tor-gitlab/mr/161' 2020-10-13 13:50:14 +00:00
Neel Chauhan
05242f5555 Pass the SOCKS request address in relay begin cells 2020-10-12 20:46:42 -07:00
Alex Xu (Hello71)
29065db381 dirclient: print bandwidth usage on one line (#40159) 2020-10-08 09:48:38 -04:00
Nick Mathewson
c4812698c3 Remove long-obsolete members from the state file.
Tor has a feature to preserve unrecognized state file entries in
order to maintain forward compatibility.  But this feature, along
with some unused code that we never actually removed, led to us
keeping items that were of no use to the user, other than at worst
to preserve ancient information about them.

This commit adds a feature to remove obsolete entries when we load
the file.

Closes ticket 40137.
2020-10-07 20:46:37 +03:00
Nick Mathewson
2ceea13140 Merge remote-tracking branch 'tor-gitlab/mr/164' 2020-10-07 09:42:37 -04:00
Nick Mathewson
741edf1b45 Merge remote-tracking branch 'tor-github/pr/1827/head' into maint-0.3.5 2020-10-07 09:29:07 -04:00
Nick Mathewson
40f0db75bd Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:38:30 -04:00
David Goulet
b404f085ad hs-v2: Add deprecation warning for service
If at least one service is configured as a version 2, a log warning is emitted
once and only once.

Closes #40003

Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-10-07 08:38:23 -04:00
Nick Mathewson
0e2e517019 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-10-07 08:35:18 -04:00
Neel Chauhan
884cad3edf Make HSFETCH take the decoded length into account, not the base32 one 2020-10-07 08:35:12 -04:00
Nick Mathewson
3e9fa5a029 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:29:31 -04:00
Nick Mathewson
5f5587ee50 Merge remote-tracking branch 'tor-gitlab/mr/77' into maint-0.3.5 2020-10-07 08:29:23 -04:00
Nick Mathewson
701a1936fa Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:26:04 -04:00
Nick Mathewson
ad7ffa5240 Merge remote-tracking branch 'tor-gitlab/mr/79' into maint-0.3.5 2020-10-07 08:25:55 -04:00
Nick Mathewson
98e14720b5 Merge remote-tracking branch 'tor-github/pr/1661/head' into maint-0.3.5 2020-10-07 08:14:46 -04:00
Nick Mathewson
9587512578 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:10:08 -04:00
Nick Mathewson
968b6c30c1 Merge remote-tracking branch 'tor-gitlab/mr/43' into maint-0.3.5 2020-10-07 08:09:59 -04:00
Nick Mathewson
8505dd5e37 Merge branch 'maint-0.4.3' into maint-0.4.4 2020-10-07 08:08:02 -04:00
Nick Mathewson
9029444482 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:08:01 -04:00
Nick Mathewson
e0e0ef713e Merge remote-tracking branch 'tor-gitlab/mr/137' into maint-0.3.5 2020-10-07 08:07:53 -04:00
Nick Mathewson
8a561fc5bf Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:05:40 -04:00
Nick Mathewson
84a5bd48e2 Merge remote-tracking branch 'tor-gitlab/mr/103' into maint-0.3.5 2020-10-07 08:05:31 -04:00
Nick Mathewson
b5a88e8d47 Merge branch 'maint-0.3.5' into maint-0.4.3 2020-10-07 08:01:37 -04:00
Nick Mathewson
ed6a328297 Merge branch 'mr_124_squashed' into maint-0.3.5 2020-10-07 08:00:59 -04:00
Nick Mathewson
c5ba8b6221 Parallelize src/test/test into chunks.
First, we introduce a flag to teach src/test/test to split its work
into chunks.  Then we replace our invocation of src/test/test in our
"make check" target with a set of 8 scripts that invoke the first
8th of the tests, the second 8th, and so on.

This change makes our "make -kj4 check" target in our hardened
gitlab build more than twice as fast, since src/test/test was taking
the longest to finish.

Closes 40098.
2020-10-07 08:00:49 -04:00
George Kadianakis
438aba6c0b Merge branch 'maint-0.4.4' into master 2020-10-07 13:42:57 +03:00
George Kadianakis
a914ac5d7c Merge remote-tracking branch 'tor-gitlab/mr/154' into maint-0.4.4 2020-10-07 13:32:17 +03:00
George Kadianakis
84e825598a Merge branch 'maint-0.4.4' into master 2020-10-07 13:29:16 +03:00
George Kadianakis
149b7a2418 Merge remote-tracking branch 'tor-gitlab/mr/163' into maint-0.4.4 2020-10-07 13:29:00 +03:00
Alexander Færøy
5f61e19d8a Expose TOR_PT_OUTBOUND_BIND_ADDRESS_{V4,V6} to Pluggable Transports.
This patch adds support for exposing the environment variables
`TOR_PT_OUTBOUND_BIND_ADDRESS_V4` and `TOR_PT_OUTBOUND_BIND_ADDRESS_V6` to
Pluggable Transport proccesses. These two values will contain the IPv4
and IPv6 address that the user have specified in torrc that they wish
the PT to use for all outgoing IP packets.

It is important to note here that it is up to the indvidual Pluggable
Transport if they are willing to honor these values or ignore them
completely.

One can test this feature using the following dummy PT written in POSIX
shell script:

    #!/bin/sh

    echo "LOG SEVERITY=warning MESSAGE=\"Value for IPv4: ${TOR_PT_OUTBOUND_BIND_ADDRESS_V4}\""
    echo "LOG SEVERITY=warning MESSAGE=\"Value for IPv6: ${TOR_PT_OUTBOUND_BIND_ADDRESS_V6}\""

    while true ; do
        sleep 1
    done

with the following entries in your torrc:

    OutboundBindAddressPT 203.0.113.4
    OutboundBindAddress 203.0.113.5
    OutboundBindAddressPT 2001:db8::4
    OutboundBindAddress 2001:db8::5

See: https://bugs.torproject.org/5304
2020-10-06 09:30:11 -04:00
Alexander Færøy
69c1a4ebc3 Move parse logic for outbound addresses to before we handle PT's.
This patch moves the logic for handling outbound addresses in torrc to
before we handle pluggable transports. Since we need access to the
values in OutboundBindAddress and friends for #5304 we have to parse
these values before we spawn any PT's.

This commit is code movement only.

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Alexander Færøy
ad08743299 Rename OUTBOUND_ADDR_EXIT_AND_OR to OUTBOUND_ADDR_ANY.
This patch renames the enumeration value in `outbound_addr_t` from
`OUTBOUND_ADDR_EXIT_AND_OR` to `OUTBOUND_ADDR_ANY` since with the
arrival of `OUTBOUND_ADDR_PT` it no longer makes sense to call the
fallback value for "Exit and OR". Instead we rename it to "any".

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Alexander Færøy
db0aaf428e Add OutboundBindAddressPT to torrc.
This patch adds a new option to torrc: `OutboundBindAddressPT`. This
option works in the same way as `OutboundBindAddressOR` and
`OutboundBindAddressExit` in that it allows the user to specify which
outbound IP address the user wants the PT to make its connections from.

There is one difference though in that OutboundBindAddressPT will only
be a suggestion for the PT to use since Tor cannot enforce whether or
not the PT actually uses this option for anything.

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Alexander Færøy
25bffccd71 Document enumeration values for outbound_addr_t.
This patch adds doxygen documentation strings for each of the values in
`outbound_addr_t`.

See: https://bugs.torproject.org/5304
2020-10-06 09:30:10 -04:00
Daniel Pinto
304ae473ca Fix %include bug with pattern with */ on glibc < 2.19 #40141
Fix bug where %including a pattern ending in */ would include
files and folders (instead of folders only) in versions of
glibc < 2.19.
2020-10-03 04:10:52 +01:00
Roger Dingledine
4f114f59e6 fix typos
no actual changes
2020-10-01 19:32:32 -04:00
Nick Mathewson
f5ddc45647 Merge branch 'bug40133_035' into bug40133_043 2020-09-28 10:37:14 -04:00
Nick Mathewson
79d7773968 Merge branch 'maint-0.3.5' into bug40133_035 2020-09-28 10:35:12 -04:00