Loading src/or/config.c +12 −7 Original line number Diff line number Diff line Loading @@ -298,6 +298,14 @@ const char default_dirservers_string[] = "-----END SIGNATURE-----\n" ; int config_assign_default_dirservers(void) { if(router_set_routerlist_from_string(default_dirservers_string) < 0) { log_fn(LOG_WARN,"Bug: the default dirservers internal string is corrupt."); return -1; } return 0; } /* Call this function when they're using the default torrc but * we can't find it. For now, just hard-code what comes in the * default torrc. Loading @@ -308,16 +316,13 @@ static int config_assign_default(or_options_t *options) { options->SocksPort = 9050; /* plus give them a dirservers file */ if(router_set_routerlist_from_string(default_dirservers_string) < 0) { log_fn(LOG_WARN,"Bug: the default dirservers internal string is corrupt."); if(config_assign_default_dirservers() < 0) return -1; } return 0; } /* prints the usage of tor. */ void print_usage(void) { static void print_usage(void) { printf("tor -f <torrc> [args]\n" "See man page for more options.\n\n" "-b <bandwidth>\t\tbytes/second rate limiting\n" Loading @@ -336,7 +341,7 @@ void print_usage(void) { ); } void free_options(or_options_t *options) { static void free_options(or_options_t *options) { tor_free(options->LogLevel); tor_free(options->LogFile); tor_free(options->DebugLogFile); Loading @@ -357,7 +362,7 @@ void free_options(or_options_t *options) { tor_free(options->Group); } void init_options(or_options_t *options) { static void init_options(or_options_t *options) { /* give reasonable values for each option. Defaults to zero. */ memset(options,0,sizeof(or_options_t)); options->LogLevel = tor_strdup("warn"); Loading src/or/or.h +1 −0 Original line number Diff line number Diff line Loading @@ -622,6 +622,7 @@ extern unsigned long stats_n_destroy_cells_processed; /********************************* config.c ***************************/ int config_assign_default_dirservers(void); int getconfig(int argc, char **argv, or_options_t *options); /********************************* connection.c ***************************/ Loading src/or/routerlist.c +24 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ typedef struct directory_token_t { /****************************************************************************/ /* static function prototypes */ static routerinfo_t * router_pick_directory_server_impl(void); static int router_get_list_from_string_impl(const char **s, routerlist_t **dest, int n_good_nicknames, Loading Loading @@ -93,8 +95,29 @@ router_release_token(directory_token_t *tok); /****************************************************************************/ /* pick a random running router with a positive dir_port */ /* try to find a running dirserver. if there are no dirservers * in our routerlist, reload the routerlist and try again. */ routerinfo_t *router_pick_directory_server(void) { routerinfo_t *choice; choice = router_pick_directory_server_impl(); if(!choice) { log_fn(LOG_WARN,"No dirservers known. Reloading and trying again."); if(options.RouterFile) { if(router_set_routerlist_from_file(options.RouterFile) < 0) return NULL; } else { if(config_assign_default_dirservers() < 0) return NULL; } /* give it another try */ choice = router_pick_directory_server_impl(); } return choice; } /* pick a random running router with a positive dir_port */ static routerinfo_t *router_pick_directory_server_impl(void) { int i; routerinfo_t *router, *dirserver=NULL; smartlist_t *sl; Loading Loading
src/or/config.c +12 −7 Original line number Diff line number Diff line Loading @@ -298,6 +298,14 @@ const char default_dirservers_string[] = "-----END SIGNATURE-----\n" ; int config_assign_default_dirservers(void) { if(router_set_routerlist_from_string(default_dirservers_string) < 0) { log_fn(LOG_WARN,"Bug: the default dirservers internal string is corrupt."); return -1; } return 0; } /* Call this function when they're using the default torrc but * we can't find it. For now, just hard-code what comes in the * default torrc. Loading @@ -308,16 +316,13 @@ static int config_assign_default(or_options_t *options) { options->SocksPort = 9050; /* plus give them a dirservers file */ if(router_set_routerlist_from_string(default_dirservers_string) < 0) { log_fn(LOG_WARN,"Bug: the default dirservers internal string is corrupt."); if(config_assign_default_dirservers() < 0) return -1; } return 0; } /* prints the usage of tor. */ void print_usage(void) { static void print_usage(void) { printf("tor -f <torrc> [args]\n" "See man page for more options.\n\n" "-b <bandwidth>\t\tbytes/second rate limiting\n" Loading @@ -336,7 +341,7 @@ void print_usage(void) { ); } void free_options(or_options_t *options) { static void free_options(or_options_t *options) { tor_free(options->LogLevel); tor_free(options->LogFile); tor_free(options->DebugLogFile); Loading @@ -357,7 +362,7 @@ void free_options(or_options_t *options) { tor_free(options->Group); } void init_options(or_options_t *options) { static void init_options(or_options_t *options) { /* give reasonable values for each option. Defaults to zero. */ memset(options,0,sizeof(or_options_t)); options->LogLevel = tor_strdup("warn"); Loading
src/or/or.h +1 −0 Original line number Diff line number Diff line Loading @@ -622,6 +622,7 @@ extern unsigned long stats_n_destroy_cells_processed; /********************************* config.c ***************************/ int config_assign_default_dirservers(void); int getconfig(int argc, char **argv, or_options_t *options); /********************************* connection.c ***************************/ Loading
src/or/routerlist.c +24 −1 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ typedef struct directory_token_t { /****************************************************************************/ /* static function prototypes */ static routerinfo_t * router_pick_directory_server_impl(void); static int router_get_list_from_string_impl(const char **s, routerlist_t **dest, int n_good_nicknames, Loading Loading @@ -93,8 +95,29 @@ router_release_token(directory_token_t *tok); /****************************************************************************/ /* pick a random running router with a positive dir_port */ /* try to find a running dirserver. if there are no dirservers * in our routerlist, reload the routerlist and try again. */ routerinfo_t *router_pick_directory_server(void) { routerinfo_t *choice; choice = router_pick_directory_server_impl(); if(!choice) { log_fn(LOG_WARN,"No dirservers known. Reloading and trying again."); if(options.RouterFile) { if(router_set_routerlist_from_file(options.RouterFile) < 0) return NULL; } else { if(config_assign_default_dirservers() < 0) return NULL; } /* give it another try */ choice = router_pick_directory_server_impl(); } return choice; } /* pick a random running router with a positive dir_port */ static routerinfo_t *router_pick_directory_server_impl(void) { int i; routerinfo_t *router, *dirserver=NULL; smartlist_t *sl; Loading