[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Clean up the "add myself as a trusted dirserver" code.
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv16367/src/or
Modified Files:
router.c routerlist.c
Log Message:
Clean up the "add myself as a trusted dirserver" code.
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.195
retrieving revision 1.196
diff -u -d -r1.195 -r1.196
--- router.c 26 Aug 2005 18:44:26 -0000 1.195
+++ router.c 26 Aug 2005 19:31:51 -0000 1.196
@@ -368,7 +368,7 @@
/* 6b. [authdirserver only] add own key to approved directories. */
crypto_pk_get_digest(get_identity_key(), digest);
if (!router_digest_is_trusted_dir(digest)) {
- add_trusted_dir_server(options->Address, (uint16_t)options->DirPort, digest);
+ add_trusted_dir_server(NULL, (uint16_t)options->DirPort, digest);
}
/* 7. [authdirserver only] load old directory, if it's there */
tor_snprintf(keydir,sizeof(keydir),"%s/cached-directory", datadir);
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.253
retrieving revision 1.254
diff -u -d -r1.253 -r1.254
--- routerlist.c 26 Aug 2005 19:25:36 -0000 1.253
+++ routerlist.c 26 Aug 2005 19:31:51 -0000 1.254
@@ -1452,17 +1452,19 @@
}
/** Add to the list of authorized directory servers one at
- * <b>address</b>:<b>port</b>, with identity key <b>digest</b>. */
+ * <b>address</b>:<b>port</b>, with identity key <b>digest</b>. If
+ * <b>address</b> is NULL, add ourself. */
void
add_trusted_dir_server(const char *address, uint16_t port, const char *digest)
{
trusted_dir_server_t *ent;
uint32_t a;
+ char *hostname = NULL;
if (!trusted_dir_servers)
trusted_dir_servers = smartlist_create();
- if (!address) { /* need to guess */
- if (resolve_my_address(get_options(), &a, NULL) < 0) {
+ if (!address) { /* The address is us; we should guess. */
+ if (resolve_my_address(get_options(), &a, &hostname) < 0) {
log_fn(LOG_WARN, "Couldn't find a suitable address. Returning.");
return;
}
@@ -1472,15 +1474,12 @@
address);
return;
}
+ hostname = tor_strdup(address);
a = ntohl(a);
}
ent = tor_malloc(sizeof(trusted_dir_server_t));
- if (address) {
- ent->address = tor_strdup(address);
- } else {
- ent->address = tor_dup_addr(a);
- }
+ ent->address = hostname;
ent->addr = a;
ent->dir_port = port;
ent->is_running = 1;