diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-10-01 00:43:34 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-10-01 00:43:34 +0000 |
commit | df5c7534b1c127d799da43a96307c76282d5e348 (patch) | |
tree | daa30d2929077ff33740a78a655e28ce6b0bca9d /src/or/dirserv.c | |
parent | f694ab23f57fe73534e75b6ffae3de00491008ee (diff) | |
download | tor-df5c7534b1c127d799da43a96307c76282d5e348.tar tor-df5c7534b1c127d799da43a96307c76282d5e348.tar.gz |
Move dirserv/routers code out of main.c
svn:r527
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r-- | src/or/dirserv.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 73ff278e0..afe91a161 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -10,6 +10,8 @@ static int the_directory_is_dirty = 1; static char *the_directory = NULL; static int the_directory_len = -1; +static int list_running_servers(char **nicknames_out); + /************** Fingerprint handling code ************/ typedef struct fingerprint_entry_t { @@ -291,6 +293,46 @@ dirserv_init_from_directory_string(const char *dir) return 0; } +static int +list_running_servers(char **nicknames_out) +{ + char *nickname_lst[MAX_ROUTERS_IN_DIR]; + connection_t **connection_array; + int n_conns; + connection_t *conn; + char *cp; + int n = 0, i; + int length; + *nicknames_out = NULL; + nickname_lst[n++] = 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; + nickname_lst[n++] = conn->nickname; + } + length = n + 1; /* spaces + EOS + 1. */ + for (i = 0; i<n; ++i) { + length += strlen(nickname_lst[i]); + } + *nicknames_out = tor_malloc(length); + cp = *nicknames_out; + memset(cp,0,length); + for (i = 0; i<n; ++i) { + if (i) + strcat(cp, " "); + strcat(cp, nickname_lst[i]); + while (*cp) + ++cp; + } + return 0; +} + + int dirserv_dump_directory_to_string(char *s, int maxlen, crypto_pk_env_t *private_key) |