[or-cvs] running-routers now lists down routers too (with a ! before...
Roger Dingledine
arma at seul.org
Thu Jul 1 11:32:28 UTC 2004
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
dirserv.c or.h router.c
Log Message:
running-routers now lists down routers too (with a ! before their name)
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- dirserv.c 30 Jun 2004 21:48:02 -0000 1.57
+++ dirserv.c 1 Jul 2004 11:32:25 -0000 1.58
@@ -442,36 +442,47 @@
char *cp;
int i;
int length;
- smartlist_t *nicknames;
+ smartlist_t *nicknames_up, *nicknames_down;
*nicknames_out = NULL;
- nicknames = smartlist_create();
- smartlist_add(nicknames, options.Nickname);
+ nicknames_up = smartlist_create();
+ nicknames_down = smartlist_create();
+ smartlist_add(nicknames_up, options.Nickname);
get_connection_array(&connection_array, &n_conns);
for (i = 0; i<n_conns; ++i) {
conn = connection_array[i];
- if (conn->type != CONN_TYPE_OR || conn->state != OR_CONN_STATE_OPEN)
- continue; /* only list successfully handshaked OR's. */
- if(!conn->nickname) /* it's an OP, don't list it */
- continue;
- /* XXX008 need to change this to list "!nickname" for down routers */
+ if (conn->type != CONN_TYPE_OR || !conn->nickname)
+ continue; /* only list ORs. */
if (!router_nickname_is_approved(conn->nickname))
continue; /* If we removed them from the approved list, don't list it.*/
- smartlist_add(nicknames, conn->nickname);
+ if(conn->state == OR_CONN_STATE_OPEN)
+ smartlist_add(nicknames_up, conn->nickname);
+ else
+ smartlist_add(nicknames_down, conn->nickname);
}
- length = smartlist_len(nicknames) + 1; /* spaces + EOS + 1. */
- SMARTLIST_FOREACH(nicknames, char *, c, length += strlen(c));
+ length = smartlist_len(nicknames_up) +
+ 2*smartlist_len(nicknames_down) + 1;
+ /* spaces + EOS + !'s + 1. */
+ SMARTLIST_FOREACH(nicknames_up, char *, c, length += strlen(c));
+ SMARTLIST_FOREACH(nicknames_down, char *, c, length += strlen(c));
*nicknames_out = tor_malloc_zero(length);
cp = *nicknames_out;
- for (i = 0; i<smartlist_len(nicknames); ++i) {
+ for (i = 0; i<smartlist_len(nicknames_up); ++i) {
if (i)
strcat(cp, " ");
- strcat(cp, (char*)smartlist_get(nicknames,i)); /* can't overflow */
+ strcat(cp, (char*)smartlist_get(nicknames_up,i)); /* can't overflow */
while (*cp)
++cp;
}
- smartlist_free(nicknames);
+ for (i = 0; i<smartlist_len(nicknames_down); ++i) {
+ strcat(cp, " !");
+ strcat(cp, (char*)smartlist_get(nicknames_down,i)); /* can't overflow */
+ while (*cp)
+ ++cp;
+ }
+ smartlist_free(nicknames_up);
+ smartlist_free(nicknames_down);
return 0;
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.372
retrieving revision 1.373
diff -u -d -r1.372 -r1.373
--- or.h 1 Jul 2004 01:16:58 -0000 1.372
+++ or.h 1 Jul 2004 11:32:25 -0000 1.373
@@ -570,7 +570,7 @@
crypto_pk_env_t *onion_pkey; /**< Public RSA key for onions. */
crypto_pk_env_t *identity_pkey; /**< Public RSA key for signing. */
- char identity_digest[DIGEST_LEN]; /** Digest of identity key */
+ char identity_digest[DIGEST_LEN]; /**< Digest of identity key */
char *platform; /**< What software/operating system is this OR using? */
Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- router.c 1 Jul 2004 01:16:59 -0000 1.54
+++ router.c 1 Jul 2004 11:32:26 -0000 1.55
@@ -285,7 +285,7 @@
if(!cp) {
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
} else {
- if(options.AuthoritativeDir)
+ if(options.AuthoritativeDir) {
if(dirserv_load_from_directory_string(cp) < 0){
log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
tor_free(cp);
More information about the tor-commits
mailing list