summaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-10-03 18:58:40 +0000
committerNick Mathewson <nickm@torproject.org>2006-10-03 18:58:40 +0000
commit6e0b90a90276e90b8a0d7b5c683f4dc5d29fd33f (patch)
treecbbb20e7a573c31fde6b3251b14f0c2b2481c660 /src/or/router.c
parent246fecb585cef56af5a0c4bf08365d2d040c3c73 (diff)
downloadtor-6e0b90a90276e90b8a0d7b5c683f4dc5d29fd33f.tar.gz
tor-6e0b90a90276e90b8a0d7b5c683f4dc5d29fd33f.zip
r8838@totoro: nickm | 2006-10-02 15:24:39 -0400
Partial implementation of revised nickname syntax for controllers. Implement ability to look up routers by "verbose" nicknames; add a per-v1-control-connection flag to turn the feature on in events. Needs testing, spec, ability to actually turn on the flag, double-checking that we wont overflow any nickname buffers, and changelog. svn:r8582
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/or/router.c b/src/or/router.c
index b139440f53..47897669da 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1306,8 +1306,28 @@ is_legal_hexdigest(const char *s)
tor_assert(s);
if (s[0] == '$') s++;
len = strlen(s);
- return (len == HEX_DIGEST_LEN &&
- strspn(s,HEX_CHARACTERS)==len);
+ if (len > HEX_DIGEST_LEN) {
+ if (s[HEX_DIGEST_LEN] == '=' ||
+ s[HEX_DIGEST_LEN] == '~') {
+ if (!is_legal_nickname(s+HEX_DIGEST_LEN+1))
+ return 0;
+ } else {
+ return 0;
+ }
+ }
+ return (len >= HEX_DIGEST_LEN &&
+ strspn(s,HEX_CHARACTERS)==HEX_DIGEST_LEN);
+}
+
+/** DOCDOC buf must have MAX_VERBOSE_NICKNAME_LEN+1 bytes. */
+void
+router_get_verbose_nickname(char *buf, routerinfo_t *router)
+{
+ buf[0] = '$';
+ base16_encode(buf+1, HEX_DIGEST_LEN+1, router->cache_info.identity_digest,
+ DIGEST_LEN);
+ buf[1+HEX_DIGEST_LEN] = router->is_named ? '=' : '~';
+ strlcpy(buf+1+HEX_DIGEST_LEN+1, router->nickname, MAX_NICKNAME_LEN+1);
}
/** Forget that we have issued any router-related warnings, so that we'll