[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] lay groundwork for EntryNodes and ExitNodes
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
circuit.c config.c onion.c or.h routers.c test.c
Log Message:
lay groundwork for EntryNodes and ExitNodes
Index: circuit.c
===================================================================
RCS file: /home/or/cvsroot/src/or/circuit.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- circuit.c 12 Nov 2003 03:48:33 -0000 1.89
+++ circuit.c 12 Nov 2003 19:34:34 -0000 1.90
@@ -766,7 +766,7 @@
* circuit that one is ready. */
connection_ap_attach_pending();
return 0;
- } else if (r<0 || !router) {
+ } else if (r<0) {
log_fn(LOG_WARN,"Unable to extend circuit path.");
return -1;
}
Index: config.c
===================================================================
RCS file: /home/or/cvsroot/src/or/config.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- config.c 10 Nov 2003 08:06:53 -0000 1.65
+++ config.c 12 Nov 2003 19:34:34 -0000 1.66
@@ -161,6 +161,8 @@
config_compare(list, "DirBindAddress", CONFIG_TYPE_STRING, &options->DirBindAddress) ||
config_compare(list, "DirFetchPostPeriod",CONFIG_TYPE_INT, &options->DirFetchPostPeriod) ||
+ config_compare(list, "ExitNodes", CONFIG_TYPE_STRING, &options->ExitNodes) ||
+ config_compare(list, "EntryNodes", CONFIG_TYPE_STRING, &options->EntryNodes) ||
config_compare(list, "ExitPolicy", CONFIG_TYPE_STRING, &options->ExitPolicy) ||
config_compare(list, "Group", CONFIG_TYPE_STRING, &options->Group) ||
@@ -210,17 +212,18 @@
void print_usage(void) {
printf("tor -f <torrc> [args]\n"
"-d <file>\t\tDebug file\n"
- "-e <policy>\t\tExit policy\n"
- "-l <level>\t\tLog level\n"
"-m <max>\t\tMax number of connections\n"
+ "-l <level>\t\tLog level\n"
+ "-t <bandwidth>\t\tTotal bandwidth\n"
+ "-r <file>\t\tList of known routers\n");
+ printf("\nClient options:\n"
+ "-e \"nick1 nick2 ...\"\t\tExit nodes\n"
"-s <IP>\t\t\tPort to bind to for Socks\n"
);
- /* split things up to be ANSI compliant */
- printf("-n <nick>\t\tNickname of router\n"
+ printf("\nServer options:\n"
+ "-n <nick>\t\tNickname of router\n"
"-o <port>\t\tOR port to bind to\n"
"-p <file>\t\tPID file\n"
- "-r <file>\t\tRouter config file\n"
- "-t <bandwidth>\t\tTotal bandwidth\n"
);
}
@@ -233,6 +236,8 @@
tor_free(options->Nickname);
tor_free(options->Address);
tor_free(options->PidFile);
+ tor_free(options->ExitNodes);
+ tor_free(options->EntryNodes);
tor_free(options->ExitPolicy);
tor_free(options->SocksBindAddress);
tor_free(options->ORBindAddress);
@@ -245,6 +250,8 @@
/* give reasonable values for each option. Defaults to zero. */
memset(options,0,sizeof(or_options_t));
options->LogLevel = tor_strdup("info");
+ options->ExitNodes = tor_strdup("");
+ options->EntryNodes = tor_strdup("");
options->ExitPolicy = tor_strdup("reject 127.0.0.1:*");
options->SocksBindAddress = tor_strdup("127.0.0.1");
options->ORBindAddress = tor_strdup("0.0.0.0");
Index: onion.c
===================================================================
RCS file: /home/or/cvsroot/src/or/onion.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -d -r1.80 -r1.81
--- onion.c 12 Nov 2003 04:12:35 -0000 1.80
+++ onion.c 12 Nov 2003 19:34:34 -0000 1.81
@@ -157,6 +157,36 @@
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 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 @@
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 @@
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;
}
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.181
retrieving revision 1.182
diff -u -d -r1.181 -r1.182
--- or.h 12 Nov 2003 02:58:45 -0000 1.181
+++ or.h 12 Nov 2003 19:34:34 -0000 1.182
@@ -432,6 +432,8 @@
char *Nickname;
char *Address;
char *PidFile;
+ char *ExitNodes;
+ char *EntryNodes;
char *ExitPolicy;
char *SocksBindAddress;
char *ORBindAddress;
@@ -692,6 +694,8 @@
void onion_pending_remove(circuit_t *circ);
int onionskin_answer(circuit_t *circ, unsigned char *payload, unsigned char *keys);
+
+char **parse_nickname_list(char *start, int *num);
int onion_extend_cpath(crypt_path_t **head_ptr, int path_len, routerinfo_t **router_out);
Index: routers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routers.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- routers.c 11 Nov 2003 17:21:35 -0000 1.87
+++ routers.c 12 Nov 2003 19:34:34 -0000 1.88
@@ -29,9 +29,6 @@
/* static function prototypes */
void routerlist_free(routerinfo_t *list);
-static char *eat_whitespace(char *s);
-static char *eat_whitespace_no_nl(char *s);
-static char *find_whitespace(char *s);
static int router_add_exit_policy_from_string(routerinfo_t *router, char *s);
static int router_add_exit_policy(routerinfo_t *router,
directory_token_t *tok);
@@ -427,40 +424,6 @@
#else
#define router_get_next_token _router_get_next_token
#endif
-
-
-/* return the first char of s that is not whitespace and not a comment */
-static char *eat_whitespace(char *s) {
- assert(s);
-
- while(isspace(*s) || *s == '#') {
- while(isspace(*s))
- s++;
- if(*s == '#') { /* read to a \n or \0 */
- while(*s && *s != '\n')
- s++;
- if(!*s)
- return s;
- }
- }
- return s;
-}
-
-static char *eat_whitespace_no_nl(char *s) {
- while(*s == ' ' || *s == '\t')
- ++s;
- return s;
-}
-
-/* return the first char of s that is whitespace or '#' or '\0 */
-static char *find_whitespace(char *s) {
- assert(s);
-
- while(*s && !isspace(*s) && *s != '#')
- s++;
-
- return s;
-}
int router_get_list_from_string(char *s)
{
Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- test.c 10 Nov 2003 08:06:55 -0000 1.47
+++ test.c 12 Nov 2003 19:34:34 -0000 1.48
@@ -464,6 +464,21 @@
test_eq((time_t) 1076393695UL, tor_timegm(&a_time));
}
+void test_onion() {
+ char **names;
+ int i,num;
+
+ names = parse_nickname_list(" foo bar baz quux ", &num);
+ test_eq(num,4);
+ test_streq(names[0],"foo");
+ test_streq(names[1],"bar");
+ test_streq(names[2],"baz");
+ test_streq(names[3],"quux");
+ for(i=0;i<num;i++)
+ tor_free(names[i]);
+ tor_free(names);
+}
+
void
test_onion_handshake() {
/* client-side */
@@ -693,6 +708,7 @@
puts("\n========================= Util ============================");
test_util();
puts("\n========================= Onion Skins =====================");
+ test_onion();
test_onion_handshake();
puts("\n========================= Directory Formats ===============");
test_dir_format();