diff options
author | David Goulet <dgoulet@torproject.org> | 2017-11-10 14:34:41 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-12-05 19:39:46 -0500 |
commit | b71a9b60cc0c29899637acc0610cb87c56869c1e (patch) | |
tree | ce1d22cf93c266f64585a7780b5dedf670e613fe /src/or/control.c | |
parent | 3b436d495fc6ad59ff5d9406d7ef17494286c299 (diff) | |
download | tor-b71a9b60cc0c29899637acc0610cb87c56869c1e.tar.gz tor-b71a9b60cc0c29899637acc0610cb87c56869c1e.zip |
hs-v3: Implement HS_DESC CREATED event
This makes the REPLICA= field optional for the control port event. A v2
service will always pass it and v3 is ignored.
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/control.c b/src/or/control.c index a1515da05a..15edc1f244 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -7252,21 +7252,29 @@ get_desc_id_from_query(const rend_data_t *rend_data, const char *hsdir_fp) * * <b>onion_address</b> is service address. * <b>desc_id</b> is the descriptor ID. - * <b>replica</b> is the the descriptor replica number. + * <b>replica</b> is the the descriptor replica number. If it is negative, it + * is ignored. */ void control_event_hs_descriptor_created(const char *onion_address, const char *desc_id, int replica) { + char *replica_field = NULL; + if (BUG(!onion_address || !desc_id)) { return; } + if (replica >= 0) { + tor_asprintf(&replica_field, " REPLICA=%d", replica); + } + send_control_event(EVENT_HS_DESC, - "650 HS_DESC CREATED %s UNKNOWN UNKNOWN %s " - "REPLICA=%d\r\n", - onion_address, desc_id, replica); + "650 HS_DESC CREATED %s UNKNOWN UNKNOWN %s%s\r\n", + onion_address, desc_id, + replica_field ? replica_field : ""); + tor_free(replica_field); } /** send HS_DESC upload event. |