summaryrefslogtreecommitdiff
path: root/src/or/router.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-15 01:58:11 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-15 01:58:11 +0000
commit7fa5d224d4469de9ff69f41a245ada9b329a2840 (patch)
tree65464005a80a12dd2e103bac4534ea23d212afdd /src/or/router.c
parente448879e3cd1a664c76f4c586cc4fe6f893b1187 (diff)
downloadtor-7fa5d224d4469de9ff69f41a245ada9b329a2840.tar.gz
tor-7fa5d224d4469de9ff69f41a245ada9b329a2840.zip
Implement "families" of coadministered nodes; prevent them all from appearing on the same circuit.
svn:r2523
Diffstat (limited to 'src/or/router.c')
-rw-r--r--src/or/router.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/or/router.c b/src/or/router.c
index df0f428977..ab606ee69b 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -552,6 +552,13 @@ int router_rebuild_descriptor(void) {
ri->is_trusted_dir = authdir_mode();
if(desc_routerinfo) /* inherit values */
ri->is_verified = desc_routerinfo->is_verified;
+ if (options.MyFamily) {
+ ri->declared_family = smartlist_create();
+ smartlist_split_string(ri->declared_family, options.MyFamily, ",",
+ SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+ } else {
+ ri->declared_family = NULL;
+ }
if (desc_routerinfo)
routerinfo_free(desc_routerinfo);
@@ -600,6 +607,7 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
int result=0;
struct exit_policy_t *tmpe;
char *bandwidth_usage;
+ char *family_line;
#ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING
char *s_tmp, *s_dup;
const char *cp;
@@ -639,6 +647,16 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
/* How busy have we been? */
bandwidth_usage = rep_hist_get_bandwidth_lines();
+ if (router->declared_family && smartlist_len(router->declared_family)) {
+ char *s = smartlist_join_strings(router->declared_family, " ", 0);
+ size_t n = strlen(s) + strlen("opt family ") + 2; /* 1 for \n, 1 for \0. */
+ family_line = tor_malloc(n);
+ snprintf(family_line, n, "opt family %s\n", s);
+ tor_free(s);
+ } else {
+ family_line = tor_strdup("");
+ }
+
/* Generate the easy portion of the router descriptor. */
result = snprintf(s, maxlen,
"router %s %s %d %d %d\n"
@@ -648,7 +666,7 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
"opt uptime %ld\n"
"bandwidth %d %d %d\n"
"onion-key\n%s"
- "signing-key\n%s%s",
+ "signing-key\n%s%s%s",
router->nickname,
router->address,
router->or_port,
@@ -665,7 +683,7 @@ int router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
(int) router->bandwidthburst,
(int) router->bandwidthcapacity,
onion_pkey, identity_pkey,
- bandwidth_usage);
+ family_line, bandwidth_usage);
tor_free(onion_pkey);
tor_free(identity_pkey);