diff options
author | Roger Dingledine <arma@torproject.org> | 2003-11-12 19:34:34 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-11-12 19:34:34 +0000 |
commit | f5829aa723fddb9e48f07a8e9830924c1bd8f5fb (patch) | |
tree | f0bbbf7cbf9f9346440f233c772fc0d6ced366d5 /src/or/onion.c | |
parent | 9358381d83d0d27db58c94cf01ab45c16292d378 (diff) | |
download | tor-f5829aa723fddb9e48f07a8e9830924c1bd8f5fb.tar.gz tor-f5829aa723fddb9e48f07a8e9830924c1bd8f5fb.zip |
lay groundwork for EntryNodes and ExitNodes
svn:r805
Diffstat (limited to 'src/or/onion.c')
-rw-r--r-- | src/or/onion.c | 42 |
1 files changed, 38 insertions, 4 deletions
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; } |