Commit Graph

239 Commits

Author SHA1 Message Date
George Kadianakis
21b3303657 Rename REGISTER_SUCCESS_ALSO_DECRYPTED to REGISTER_SUCCESS_AND_DECRYPTED. 2019-11-18 19:21:45 +02:00
George Kadianakis
97fd75169d Various minor improvements after David's review.
- Fix a wrong log message
- Introduce a cap for the nickname size
- Change some 'if' statements to 'switch'.
2019-11-18 19:21:41 +02:00
George Kadianakis
ce422a9d4a hs-v3: Decrypt pending descriptors when we get new client auth creds. 2019-11-18 19:21:34 +02:00
George Kadianakis
db6a48b6bf control-port: Implement ONION_CLIENT_AUTH_VIEW. 2019-11-18 19:19:00 +02:00
George Kadianakis
8330b4dc2a control-port: Implement ONION_CLIENT_AUTH_REMOVE. 2019-11-18 19:18:49 +02:00
George Kadianakis
46f4415022 control-port: Tests for ONION_CLIENT_AUTH_ADD. 2019-11-18 19:18:45 +02:00
George Kadianakis
00fdaaee1e control-port: Implement ONION_CLIENT_AUTH_ADD. 2019-11-18 19:16:01 +02:00
George Kadianakis
d28b6792cb Merge branch 'tor-github/pr/1423' 2019-11-18 19:06:53 +02:00
David Goulet
3892ac7c71 test: Unit test for the hs cache decrypt on new auth
Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
68a004d147 hs-v3: Improve documentation of hs_cache_client_descriptor_t
Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
48a9f8a63f hs-v3: Function to re-parse unencrypted descriptor
We now keep descriptor that we can't decode due to missing client
authorization in the cache.

This new function is used when new client authorization are added and to tell
the client cache to retry decoding.

Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
fbc18c8989 hs-v3: Refactor descriptor dir fetch done code
This commit extract most of the code that dirclient.c had to handle the end of
a descriptor directory requests (fetch). It is moved into hs_client.c in order
to have one single point of entry and the rest is fully handled by the HS
subsystem.

As part of #30382, depending on how the descriptor ended up stored (decoded or
not), different SOCKS error code can be returned.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
542402cd60 hs-v3: Set extended error when missing/bad client auth
Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
fb1d212021 hs-v3: Set extended error when descriptor is not found
Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
7bba8bf72f hs-v3: Return descriptor decoding status when storing as client
This will allow us to callback into the HS subsytem depending on the decoding
status and return an extended SOCKS5 error code depending on the decoding
issue.

This is how we'll be able to tell the SocksPort connection if we are missing
or have bad client authorization for a service.

Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
David Goulet
96a53221b0 hs-v3: Keep descriptor in cache if client auth is missing or bad
We now keep the descriptor in the cache, obviously not decoded, if it can't be
decrypted for which we believe client authorization is missing or unusable
(bad).

This way, it can be used later once the client authorization are added or
updated.

Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-11-18 19:06:43 +02:00
Nick Mathewson
8b91680d5c Doxygen: rename all .dox files to end with .md
Using a standard ending here will let other tools that expect
markdown understand our output here.

This commit was automatically generated with:

   for fn in $(find src -name '*.dox'); do \
      git mv "$fn" "${fn%.dox}.md"; \
   done
2019-11-15 09:28:12 -05:00
Nick Mathewson
3a7369d0cf Doxygen: remove /** and **/ from all .dox files
This is an automatically generated commit, made with:

find src -name '*.dox' | \
   xargs  perl -i -ne 'print unless (m#^\s*/?\*\*/?\s*$#);'
2019-11-15 09:23:51 -05:00
Nick Mathewson
582cee723a Fix various doxygen comments in feature/hs. 2019-11-07 08:13:31 -05:00
Nick Mathewson
c6c02658cf hs_ident.c: make comments into doxygen. 2019-11-06 13:05:13 -05:00
Nick Mathewson
92b3f60ebc hs_ident.h: make comments into doxygen. 2019-11-06 13:03:40 -05:00
David Goulet
49cb7d6ec4 Merge branch 'tor-github/pr/1491' 2019-11-06 10:23:33 -05:00
Nick Mathewson
aac80a004f Doxygen: add several missing links. 2019-11-05 08:05:42 -05:00
Nick Mathewson
a33d1dce8a directory-level documentation for feature/* 2019-11-04 17:07:38 -05:00
Nick Mathewson
62a473debf Doxygen: Avoid ambiguity in @dir directives
This commit was automatically generated with:

find src -name '*.dox' |xargs perl -i -pe 's{\@dir ([^/])}{\@dir /$1};'
2019-11-04 10:23:36 -05:00
Nick Mathewson
7fc077ed25 Add stub directory-level documentation for most source directories
This includes app, core, feature, lib, and tools, but excludes
ext, test, and trunnel.

This was generated by the following shell script:

cd src
for dname in $(find lib core feature app tools -type d |grep -v \\.deps$); do
    keyword="$(echo "$dname" |sed -e "s/\//_/" )"
    target="${dname}/${keyword}.dox"
    echo "$target"
    cat <<EOF >"$target"
/**
@dir ${dname}
@brief ${dname}
**/
EOF

    git add "$target"
done
2019-11-04 07:40:14 -05:00
David Goulet
e85f86bb7b dos: Add HS DoS INTRO2 rejected stats in heartbeat
The DoS heartbeat now contains the number of rejected INTRODUCE2 cell that the
relay has seen.

Closes #31371

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-31 13:57:14 -04:00
David Goulet
ff8823d03c dos: Account rejection in hs_dos_can_send_intro2
This required a small refactoring so we could count properly the INTRO2
sending disallow.

Part of #31371

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-31 13:50:36 -04:00
George Kadianakis
4413b98190 Merge branch 'tor-github/pr/1456' 2019-10-29 21:29:13 +08:00
Nick Mathewson
68f8086041 doxygen: add @file declarations for src/feature/
If a file doesn't use the file command (either \file or @file),
Doxygen won't try to process it.
2019-10-26 12:05:28 -04:00
teor
c00602cc34
Merge branch 'maint-0.4.2' 2019-10-25 09:42:14 +10:00
teor
acd27f4b41
Merge remote-tracking branch 'tor-github/pr/1464' into maint-0.4.2 2019-10-25 09:41:48 +10:00
David Goulet
ed57a04a65 hs-v3: Remove a BUG() caused by an acceptable race
hs_client_purge_state() and hs_cache_clean_as_client() can remove a descriptor
from the client cache with a NEWNYM or simply when the descriptor expires.

Which means that for an INTRO circuit being established during that time, once
it opens, we lookup the descriptor to get the IP object but hey surprised, no
more descriptor.

The approach here is minimalist that is accept the race and close the circuit
since we can not continue. Before that, the circuit would stay opened and the
client wait the SockTimeout.

Fixers #28970.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-24 08:50:01 -04:00
David Goulet
b6c24eb484 hs-v3: Remove the circuit_established intro flag
Only use the HS circuit map to know if an introduction circuit is established
or not. No need for a flag to keep state of something we already have in the
circuit map. Furthermore, the circuit map gets cleaned up properly so it will
always have the "latest truth".

This commit also removes a unit test that was testing specifically that flag
but now we rely solely on the HS circuit map which is also tested few lines
below the removed test.

Fixes #32094

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-23 11:51:23 -04:00
Nick Mathewson
931a5db2a7 Re-run make autostyle. 2019-10-22 09:40:31 -04:00
Nick Mathewson
b2d487ae22 Merge branch 'ticket31705_v2' into ticket31705_v2_merged
Conflicts:
	src/feature/dirparse/authcert_parse.c
	src/feature/dirparse/ns_parse.c
	src/feature/hs/hs_service.c
	src/lib/conf/conftesting.h
	src/lib/log/log.h
	src/lib/thread/threads.h
	src/test/test_options.c

These conflicts were mostly related to autostyle improvements, with
one or two due to doxygen fixes.
2019-10-22 09:39:06 -04:00
Nick Mathewson
d9bad0203b Disable a couple of iterator macros when COCCI is defined. 2019-10-22 09:32:13 -04:00
teor
d616214e47
Merge branch 'maint-0.4.2' 2019-10-18 12:05:20 +10:00
David Goulet
52bf54ecd4 hs-v3: Add a series of decoding error code
This commit introduces the hs_desc_decode_status_t enum which aims at having
more fine grained error code when decoding a descriptor.

This will be useful in later commits when we support keeping a descriptor that
can't be decrypted due to missing or bad client authorization creds.

No behavior change.

Part of #30382.

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-17 11:31:03 -04:00
David Goulet
8e0d9189c5 hs-v3: Helper function to find all entry connections
No code behavior change. This removes duplicate code that was finding all
entry connections for a specific onion service identity key.

The find_entry_conns() helper function is introduced for that.

Part of #30382

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-17 11:31:03 -04:00
Nick Mathewson
5c09230b45 hs_cache.c: fix HTML tags in doxygen comments. 2019-10-17 08:27:17 -04:00
Nick Mathewson
3430b487d6 hs_cell.[ch]: repair doxygen. 2019-10-16 12:08:38 -04:00
Nick Mathewson
17b88241db hs_cache.[ch]: repair doxygen comments. 2019-10-16 11:57:44 -04:00
Nick Mathewson
1b66668e26 hs_client.[ch]: fix doxygen comments by using /**. 2019-10-16 11:51:47 -04:00
Nick Mathewson
123fe6bdc5 hs_common.[ch]: repair doxygen comments by replacing /* with /** 2019-10-16 11:39:10 -04:00
Nick Mathewson
2127d797e9 hs_descriptor.[ch]: repair doxygen comments.
These are yet more that were not made with "/**"
2019-10-16 11:33:03 -04:00
Nick Mathewson
ca26ea03fc hs_service.c: repair doxygen comments 2019-10-16 11:26:20 -04:00
Nick Mathewson
0e9e5c37b7 hs_service.h: repair doxygen comments. 2019-10-16 11:18:43 -04:00
David Goulet
09e6c0f7c7 hs-v3: Fix possible memory leak in error code path
Found by coverity CID 1454769.

There were a second possible leak that is also fixed in this commit.

Fixes #32063

Signed-off-by: David Goulet <dgoulet@torproject.org>
2019-10-15 08:54:11 -04:00
Nick Mathewson
2e5724d153 Merge branch 'ticket31682_042_01_squashed' 2019-10-11 10:21:58 -04:00