summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
authorQingping Hou <dave2008713@gmail.com>2014-02-04 19:33:48 -0500
committerQingping Hou <dave2008713@gmail.com>2014-02-06 16:13:55 -0500
commitbf66ff915aa3b97922c3313542ed2f2f554d9c57 (patch)
treeaf3e53609c0e2954a394887f12d8d2241fc940ed /src/or/control.c
parent2d41cab1502666eaace21f10385964737d246388 (diff)
downloadtor-bf66ff915aa3b97922c3313542ed2f2f554d9c57.tar.gz
tor-bf66ff915aa3b97922c3313542ed2f2f554d9c57.zip
fix longname returned in HS_DESC control events
According to control spec, longname should not contain any spaces and is consists only of identy_digest + nickname added two functions: * node_get_verbose_nickname_by_id() * node_describe_longname_by_id()
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c55
1 files changed, 36 insertions, 19 deletions
diff --git a/src/or/control.c b/src/or/control.c
index d24b9e4bab..42db3613d4 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -4991,6 +4991,21 @@ rend_auth_type_to_string(rend_auth_type_t auth_type)
return str;
}
+/** Return a longname the node whose identity is <b>id_digest</b>. If
+ * node_get_by_id() returns NULL, base 16 encoding of <b>id_digest</b> is
+ * returned instead.
+ *
+ * This function is not thread-safe. Each call to this function invalidates
+ * previous values returned by this function.
+ */
+MOCK_IMPL(const char *,
+node_describe_longname_by_id,(const char *id_digest))
+{
+ static char longname[MAX_VERBOSE_NICKNAME_LEN+1];
+ node_get_verbose_nickname_by_id(id_digest, longname);
+ return longname;
+}
+
/** send HS_DESC requested event.
*
* <b>rend_query</b> is used to fetch requested onion address and auth type.
@@ -4999,20 +5014,21 @@ rend_auth_type_to_string(rend_auth_type_t auth_type)
*/
void
control_event_hs_descriptor_requested(const rend_data_t *rend_query,
- const char *hs_dir,
+ const char *id_digest,
const char *desc_id_base32)
{
- if (!hs_dir || !rend_query || !desc_id_base32) {
+ if (!id_digest || !rend_query || !desc_id_base32) {
log_warn(LD_BUG, "Called with rend_query==%p, "
- "hs_dir==%p, desc_id_base32==%p",
- rend_query, hs_dir, desc_id_base32);
+ "id_digest==%p, desc_id_base32==%p",
+ rend_query, id_digest, desc_id_base32);
return;
}
+
send_control_event(EVENT_HS_DESC, ALL_FORMATS,
"650 HS_DESC REQUESTED %s %s %s %s\r\n",
rend_query->onion_address,
rend_auth_type_to_string(rend_query->auth_type),
- hs_dir,
+ node_describe_longname_by_id(id_digest),
desc_id_base32);
}
@@ -5027,19 +5043,20 @@ control_event_hs_descriptor_requested(const rend_data_t *rend_query,
void
control_event_hs_descriptor_receive_end(const char *action,
const rend_data_t *rend_query,
- const char *hs_dir)
+ const char *id_digest)
{
- if (!action || !rend_query || !hs_dir) {
+ if (!action || !rend_query || !id_digest) {
log_warn(LD_BUG, "Called with action==%p, rend_query==%p, "
- "hs_dir==%p", action, rend_query, hs_dir);
+ "id_digest==%p", action, rend_query, id_digest);
return;
}
+
send_control_event(EVENT_HS_DESC, ALL_FORMATS,
"650 HS_DESC %s %s %s %s\r\n",
action,
rend_query->onion_address,
rend_auth_type_to_string(rend_query->auth_type),
- hs_dir);
+ node_describe_longname_by_id(id_digest));
}
/** send HS_DESC RECEIVED event
@@ -5048,14 +5065,14 @@ control_event_hs_descriptor_receive_end(const char *action,
*/
void
control_event_hs_descriptor_received(const rend_data_t *rend_query,
- const char *hs_dir)
+ const char *id_digest)
{
- if (!rend_query || !hs_dir) {
- log_warn(LD_BUG, "Called with rend_query==%p, hs_dir==%p",
- rend_query, hs_dir);
+ if (!rend_query || !id_digest) {
+ log_warn(LD_BUG, "Called with rend_query==%p, id_digest==%p",
+ rend_query, id_digest);
return;
}
- control_event_hs_descriptor_receive_end("RECEIVED", rend_query, hs_dir);
+ control_event_hs_descriptor_receive_end("RECEIVED", rend_query, id_digest);
}
/** send HS_DESC FAILED event
@@ -5064,14 +5081,14 @@ control_event_hs_descriptor_received(const rend_data_t *rend_query,
*/
void
control_event_hs_descriptor_failed(const rend_data_t *rend_query,
- const char *hs_dir)
+ const char *id_digest)
{
- if (!rend_query || !hs_dir) {
- log_warn(LD_BUG, "Called with rend_query==%p, hs_dir==%p",
- rend_query, hs_dir);
+ if (!rend_query || !id_digest) {
+ log_warn(LD_BUG, "Called with rend_query==%p, id_digest==%p",
+ rend_query, id_digest);
return;
}
- control_event_hs_descriptor_receive_end("FAILED", rend_query, hs_dir);
+ control_event_hs_descriptor_receive_end("FAILED", rend_query, id_digest);
}
/** Free any leftover allocated memory of the control.c subsystem. */