diff options
author | Qingping Hou <dave2008713@gmail.com> | 2014-02-04 19:33:48 -0500 |
---|---|---|
committer | Qingping Hou <dave2008713@gmail.com> | 2014-02-06 16:13:55 -0500 |
commit | bf66ff915aa3b97922c3313542ed2f2f554d9c57 (patch) | |
tree | af3e53609c0e2954a394887f12d8d2241fc940ed /src/or/nodelist.c | |
parent | 2d41cab1502666eaace21f10385964737d246388 (diff) | |
download | tor-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/nodelist.c')
-rw-r--r-- | src/or/nodelist.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/or/nodelist.c b/src/or/nodelist.c index d1a226e4ff..b1464422ad 100644 --- a/src/or/nodelist.c +++ b/src/or/nodelist.c @@ -646,7 +646,7 @@ node_get_purpose(const node_t *node) /** Compute the verbose ("extended") nickname of <b>node</b> and store it * into the MAX_VERBOSE_NICKNAME_LEN+1 character buffer at - * <b>verbose_nickname_out</b> */ + * <b>verbose_name_out</b> */ void node_get_verbose_nickname(const node_t *node, char *verbose_name_out) @@ -662,6 +662,25 @@ node_get_verbose_nickname(const node_t *node, strlcpy(verbose_name_out+1+HEX_DIGEST_LEN+1, nickname, MAX_NICKNAME_LEN+1); } +/** Compute the verbose ("extended") nickname of node with + * given <b>id_digest</b> and store it into the MAX_VERBOSE_NICKNAME_LEN+1 + * character buffer at <b>verbose_name_out</b> + * + * If node_get_by_id() returns NULL, base 16 encoding of + * <b>id_digest</b> is returned instead. */ +void +node_get_verbose_nickname_by_id(const char *id_digest, + char *verbose_name_out) +{ + const node_t *node = node_get_by_id(id_digest); + if (!node) { + verbose_name_out[0] = '$'; + base16_encode(verbose_name_out+1, HEX_DIGEST_LEN+1, id_digest, DIGEST_LEN); + } else { + node_get_verbose_nickname(node, verbose_name_out); + } +} + /** Return true iff it seems that <b>node</b> allows circuits to exit * through it directlry from the client. */ int |