summaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-11-08 16:51:30 -0500
committerNick Mathewson <nickm@torproject.org>2011-11-30 11:55:44 -0500
commit11d5a9f63d85adda25d1227befcebf249107a1bd (patch)
tree65d5ef90fbfe27b421be49053574ddb5e26ee51e /src/or/router.c
parent5f0a8dcd2cfcbafc3deb3a6717808b607a459dac (diff)
downloadtor-11d5a9f63d85adda25d1227befcebf249107a1bd.tar.gz
tor-11d5a9f63d85adda25d1227befcebf249107a1bd.zip
Initial support for simplest use of prop186 or-address lines
This lets a routerinfo_t have a single IPv6 or-address, and adds support for formatting and parsing those lines.
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/or/router.c b/src/or/router.c
index 82e05dbec9..2e9b256cc2 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1903,6 +1903,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
int result=0;
addr_policy_t *tmpe;
char *family_line;
+ char *extra_or_address = NULL;
const or_options_t *options = get_options();
/* Make sure the identity key matches the one in the routerinfo. */
@@ -1955,9 +1956,22 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
router->cache_info.extra_info_digest, DIGEST_LEN);
}
+ if (router->ipv6_orport &&
+ tor_addr_family(&router->ipv6_addr) == AF_INET6) {
+ char addr[TOR_ADDR_BUF_LEN];
+ const char *a;
+ a = tor_addr_to_str(addr, &router->ipv6_addr, sizeof(addr), 1);
+ if (a) {
+ tor_asprintf(&extra_or_address,
+ "or-address %s:%d\n", a, router->ipv6_orport);
+ log_notice(LD_OR, "My line is <%s>", extra_or_address);
+ }
+ }
+
/* Generate the easy portion of the router descriptor. */
result = tor_snprintf(s, maxlen,
"router %s %s %d 0 %d\n"
+ "%s"
"platform %s\n"
"opt protocols Link 1 2 Circuit 1\n"
"published %s\n"
@@ -1972,6 +1986,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
router->address,
router->or_port,
decide_to_advertise_dirport(options, router->dir_port),
+ extra_or_address ? extra_or_address : "",
router->platform,
published,
fingerprint,
@@ -1992,6 +2007,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
tor_free(family_line);
tor_free(onion_pkey);
tor_free(identity_pkey);
+ tor_free(extra_or_address);
if (result < 0) {
log_warn(LD_BUG,"descriptor snprintf #1 ran out of room!");