From f5829aa723fddb9e48f07a8e9830924c1bd8f5fb Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Wed, 12 Nov 2003 19:34:34 +0000 Subject: lay groundwork for EntryNodes and ExitNodes svn:r805 --- src/or/onion.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src/or/onion.c') diff --git a/src/or/onion.c b/src/or/onion.c index be11d2d339..7c124a5600 100644 --- a/src/or/onion.c +++ b/src/or/onion.c @@ -157,6 +157,36 @@ int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *key return 0; } +char **parse_nickname_list(char *list, int *num) { + char **out; + char *start,*end; + int i; + + while(isspace(*list)) list++; + + i=0, start = list; + while(*start) { + while(*start && !isspace(*start)) start++; + i++; + while(isspace(*start)) start++; + } + + out = tor_malloc(i * sizeof(char *)); + + i=0, start=list; + while(*start) { + end=start; while(*end && !isspace(*end)) end++; + out[i] = tor_malloc(MAX_NICKNAME_LEN); + strncpy(out[i],start,end-start); + out[i][end-start] = 0; /* null terminate it */ + i++; + while(isspace(*end)) end++; + start = end; + } + *num = i; + return out; +} + /* uses a weighted coin with weight cw to choose a route length */ static int chooselen(double cw) { int len = 2; @@ -254,10 +284,11 @@ int onion_extend_cpath(crypt_path_t **head_ptr, int path_len, routerinfo_t **rou int rarray_len; int i; directory_t *dir; + char **nicknames; + int num_nicknames; assert(head_ptr); - if (router_out) - *router_out = NULL; + assert(router_out); router_get_directory(&dir); rarray = dir->routers; @@ -275,6 +306,10 @@ int onion_extend_cpath(crypt_path_t **head_ptr, int path_len, routerinfo_t **rou log_fn(LOG_DEBUG, "Path is %d long; we want %d", cur_len, path_len); again: + if(cur_len == 0) { /* picking entry node */ + + + } choice = crypto_pseudo_rand_int(rarray_len); log_fn(LOG_DEBUG,"Contemplating router %s for hop %d", rarray[choice]->nickname, cur_len); @@ -318,8 +353,7 @@ int onion_extend_cpath(crypt_path_t **head_ptr, int path_len, routerinfo_t **rou log_fn(LOG_DEBUG, "Extended circuit path with %s for hop %d", rarray[choice]->nickname, cur_len); - if (router_out) - *router_out = rarray[choice]; + *router_out = rarray[choice]; return 0; } -- cgit v1.2.3-54-g00ecf