Loading src/or/command.c +1 −1 Changes for src/or/command.c: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ /* In-points to command.c: * * - command_process_cell(), called from * connection_or_process_cells_from_inbuf() in connection_or.c. * connection_or_process_cells_from_inbuf() in connection_or.c */ #include "or.h" Loading src/or/directory.c +75 −10 Changes for src/or/directory.c: 75 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,26 @@ * \brief Implement directory HTTP protocol. **/ /* In-points to directory.c: * * - directory_post_to_dirservers(), called from * router_upload_dir_desc_to_dirservers() in router.c * upload_service_descriptor() in rendservice.c * - directory_get_from_dirserver(), called from * rend_client_refetch_renddesc() in rendclient.c * run_scheduled_events() in main.c * do_hup() in main.c * - connection_dir_process_inbuf(), called from * connection_process_inbuf() in connection.c * - connection_dir_finished_flushing(), called from * connection_finished_flushing() in connection.c * - connection_dir_finished_connecting(), called from * connection_finished_connecting() in connection.c */ static void directory_initiate_command(routerinfo_t *router, uint8_t purpose, const char *payload, int payload_len); static void directory_send_command(connection_t *conn, int purpose, const char *payload, int payload_len); static int directory_handle_command(connection_t *conn); Loading @@ -27,6 +47,43 @@ char rend_fetch_url[] = "/rendezvous/"; /********* END VARIABLES ************/ /** Start a connection to every known directory server, using * connection purpose 'purpose' and uploading the payload 'payload' * (length 'payload_len'). The purpose should be one of * 'DIR_PURPOSE_UPLOAD_DIR' or 'DIR_PURPOSE_UPLOAD_RENDDESC'. */ void directory_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len) { int i; routerinfo_t *router; routerlist_t *rl; router_get_routerlist(&rl); if(!rl) return; for(i=0; i < smartlist_len(rl->routers); i++) { router = smartlist_get(rl->routers, i); if(router->dir_port > 0) directory_initiate_command(router, purpose, payload, payload_len); } } /** Start a connection to a random running directory server, using * connection purpose 'purpose' requesting 'payload' (length * 'payload_len'). The purpose should be one of * 'DIR_PURPOSE_FETCH_DIR' or 'DIR_PURPOSE_FETCH_RENDDESC'. */ void directory_get_from_dirserver(uint8_t purpose, const char *payload, int payload_len) { directory_initiate_command(router_pick_directory_server(), purpose, payload, payload_len); } /** Launch a new connection to the directory server <b>router</b> to upload or * download a service or rendezvous descriptor. <b>purpose</b> determines what * kind of directory connection we're launching, and must be one of Loading @@ -36,8 +93,10 @@ char rend_fetch_url[] = "/rendezvous/"; * of the HTTP post. When fetching a rendezvous descriptor, <b>payload</b> * and <b>payload_len</b> are the service ID we want to fetch. */ void directory_initiate_command(routerinfo_t *router, int purpose, const char *payload, int payload_len) { static void directory_initiate_command(routerinfo_t *router, uint8_t purpose, const char *payload, int payload_len) { connection_t *conn; switch (purpose) Loading Loading @@ -169,7 +228,9 @@ static void directory_send_command(connection_t *conn, int purpose, * null-terminate it (this modifies headers!) and return 0. * Otherwise, return -1. */ int parse_http_url(char *headers, char **url) { static int parse_http_url(char *headers, char **url) { char *s, *tmp; s = (char *)eat_whitespace_no_nl(headers); Loading @@ -193,7 +254,9 @@ int parse_http_url(char *headers, char **url) { * (else leave it alone), and return 0. * Otherwise, return -1. */ int parse_http_response(char *headers, int *code, char **message) { static int parse_http_response(char *headers, int *code, char **message) { int n1, n2; tor_assert(headers && code); Loading Loading @@ -368,9 +431,10 @@ static char answer503[] = "HTTP/1.0 503 Directory unavailable\r\n\r\n"; * service descriptor. On finding one, write a response into * conn-\>outbuf. If the request is unrecognized, send a 404. * Always return 0. */ static int directory_handle_command_get(connection_t *conn, char *headers, char *body, int body_len) { static int directory_handle_command_get(connection_t *conn, char *headers, char *body, int body_len) { size_t dlen; const char *cp; char *url; Loading Loading @@ -434,9 +498,10 @@ static int directory_handle_command_get(connection_t *conn, * service descriptor. On finding one, process it and write a * response into conn-\>outbuf. If the request is unrecognized, send a * 404. Always return 0. */ static int directory_handle_command_post(connection_t *conn, char *headers, char *body, int body_len) { static int directory_handle_command_post(connection_t *conn, char *headers, char *body, int body_len) { const char *cp; char *url; Loading src/or/main.c +2 −8 Changes for src/or/main.c: 2 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -330,10 +330,6 @@ void directory_has_arrived(void) { log_fn(LOG_INFO, "A directory has arrived."); /* just for testing */ // directory_initiate_command(router_pick_directory_server(), // DIR_PURPOSE_FETCH_RENDDESC, "foo", 3); has_fetched_directory=1; if(options.ORPort) { /* connect to them all */ Loading Loading @@ -445,8 +441,7 @@ static void run_scheduled_events(time_t now) { if(!options.DirPort) { /* NOTE directory servers do not currently fetch directories. * Hope this doesn't bite us later. */ directory_initiate_command(router_pick_directory_server(), DIR_PURPOSE_FETCH_DIR, NULL, 0); directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0); } else { /* We're a directory; dump any old descriptors. */ dirserv_remove_old_servers(); Loading Loading @@ -641,8 +636,7 @@ static int do_hup(void) { rend_services_introduce(); } else { /* fetch a new directory */ directory_initiate_command(router_pick_directory_server(), DIR_PURPOSE_FETCH_DIR, NULL, 0); directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0); } if(options.ORPort) { router_rebuild_descriptor(); Loading src/or/or.h +4 −5 Changes for src/or/or.h: 4 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -864,7 +864,6 @@ void assert_buf_ok(buf_t *buf); extern char *circuit_state_to_string[]; circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn); void circuit_close_all_marked(void); void circuit_free_cpath(crypt_path_t *cpath); int _circuit_mark_for_close(circuit_t *circ); #define circuit_mark_for_close(c) \ Loading Loading @@ -1069,8 +1068,10 @@ int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type, /********************************* directory.c ***************************/ void directory_initiate_command(routerinfo_t *router, int purpose, const char *payload, int payload_len); void directory_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len); void directory_get_from_dirserver(uint8_t purpose, const char *payload, int payload_len); int connection_dir_process_inbuf(connection_t *conn); int connection_dir_finished_flushing(connection_t *conn); int connection_dir_finished_connecting(connection_t *conn); Loading Loading @@ -1190,7 +1191,6 @@ void rend_client_desc_fetched(char *query, int success); char *rend_client_get_random_intro(char *query); int rend_parse_rendezvous_address(char *address); int rend_client_send_establish_rendezvous(circuit_t *circ); int rend_client_send_introduction(circuit_t *introcirc, circuit_t *rendcirc); /********************************* rendcommon.c ***************************/ Loading Loading @@ -1265,7 +1265,6 @@ void rotate_onion_key(void); void router_retry_connections(void); void router_upload_dir_desc_to_dirservers(void); void router_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len); int router_compare_to_my_exit_policy(connection_t *conn); routerinfo_t *router_get_my_routerinfo(void); const char *router_get_my_descriptor(void); Loading src/or/rendclient.c +1 −2 Changes for src/or/rendclient.c: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -228,8 +228,7 @@ rend_client_refetch_renddesc(const char *query) log_fn(LOG_INFO,"Would fetch a new renddesc here (for %s), but one is already in progress.", query); } else { /* not one already; initiate a dir rend desc lookup */ directory_initiate_command(router_pick_directory_server(), DIR_PURPOSE_FETCH_RENDDESC, directory_get_from_dirserver(DIR_PURPOSE_FETCH_RENDDESC, query, strlen(query)); } } Loading Loading
src/or/command.c +1 −1 Changes for src/or/command.c: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -10,7 +10,7 @@ /* In-points to command.c: * * - command_process_cell(), called from * connection_or_process_cells_from_inbuf() in connection_or.c. * connection_or_process_cells_from_inbuf() in connection_or.c */ #include "or.h" Loading
src/or/directory.c +75 −10 Changes for src/or/directory.c: 75 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,26 @@ * \brief Implement directory HTTP protocol. **/ /* In-points to directory.c: * * - directory_post_to_dirservers(), called from * router_upload_dir_desc_to_dirservers() in router.c * upload_service_descriptor() in rendservice.c * - directory_get_from_dirserver(), called from * rend_client_refetch_renddesc() in rendclient.c * run_scheduled_events() in main.c * do_hup() in main.c * - connection_dir_process_inbuf(), called from * connection_process_inbuf() in connection.c * - connection_dir_finished_flushing(), called from * connection_finished_flushing() in connection.c * - connection_dir_finished_connecting(), called from * connection_finished_connecting() in connection.c */ static void directory_initiate_command(routerinfo_t *router, uint8_t purpose, const char *payload, int payload_len); static void directory_send_command(connection_t *conn, int purpose, const char *payload, int payload_len); static int directory_handle_command(connection_t *conn); Loading @@ -27,6 +47,43 @@ char rend_fetch_url[] = "/rendezvous/"; /********* END VARIABLES ************/ /** Start a connection to every known directory server, using * connection purpose 'purpose' and uploading the payload 'payload' * (length 'payload_len'). The purpose should be one of * 'DIR_PURPOSE_UPLOAD_DIR' or 'DIR_PURPOSE_UPLOAD_RENDDESC'. */ void directory_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len) { int i; routerinfo_t *router; routerlist_t *rl; router_get_routerlist(&rl); if(!rl) return; for(i=0; i < smartlist_len(rl->routers); i++) { router = smartlist_get(rl->routers, i); if(router->dir_port > 0) directory_initiate_command(router, purpose, payload, payload_len); } } /** Start a connection to a random running directory server, using * connection purpose 'purpose' requesting 'payload' (length * 'payload_len'). The purpose should be one of * 'DIR_PURPOSE_FETCH_DIR' or 'DIR_PURPOSE_FETCH_RENDDESC'. */ void directory_get_from_dirserver(uint8_t purpose, const char *payload, int payload_len) { directory_initiate_command(router_pick_directory_server(), purpose, payload, payload_len); } /** Launch a new connection to the directory server <b>router</b> to upload or * download a service or rendezvous descriptor. <b>purpose</b> determines what * kind of directory connection we're launching, and must be one of Loading @@ -36,8 +93,10 @@ char rend_fetch_url[] = "/rendezvous/"; * of the HTTP post. When fetching a rendezvous descriptor, <b>payload</b> * and <b>payload_len</b> are the service ID we want to fetch. */ void directory_initiate_command(routerinfo_t *router, int purpose, const char *payload, int payload_len) { static void directory_initiate_command(routerinfo_t *router, uint8_t purpose, const char *payload, int payload_len) { connection_t *conn; switch (purpose) Loading Loading @@ -169,7 +228,9 @@ static void directory_send_command(connection_t *conn, int purpose, * null-terminate it (this modifies headers!) and return 0. * Otherwise, return -1. */ int parse_http_url(char *headers, char **url) { static int parse_http_url(char *headers, char **url) { char *s, *tmp; s = (char *)eat_whitespace_no_nl(headers); Loading @@ -193,7 +254,9 @@ int parse_http_url(char *headers, char **url) { * (else leave it alone), and return 0. * Otherwise, return -1. */ int parse_http_response(char *headers, int *code, char **message) { static int parse_http_response(char *headers, int *code, char **message) { int n1, n2; tor_assert(headers && code); Loading Loading @@ -368,9 +431,10 @@ static char answer503[] = "HTTP/1.0 503 Directory unavailable\r\n\r\n"; * service descriptor. On finding one, write a response into * conn-\>outbuf. If the request is unrecognized, send a 404. * Always return 0. */ static int directory_handle_command_get(connection_t *conn, char *headers, char *body, int body_len) { static int directory_handle_command_get(connection_t *conn, char *headers, char *body, int body_len) { size_t dlen; const char *cp; char *url; Loading Loading @@ -434,9 +498,10 @@ static int directory_handle_command_get(connection_t *conn, * service descriptor. On finding one, process it and write a * response into conn-\>outbuf. If the request is unrecognized, send a * 404. Always return 0. */ static int directory_handle_command_post(connection_t *conn, char *headers, char *body, int body_len) { static int directory_handle_command_post(connection_t *conn, char *headers, char *body, int body_len) { const char *cp; char *url; Loading
src/or/main.c +2 −8 Changes for src/or/main.c: 2 added lines, 8 removed lines. Original line number Diff line number Diff line Loading @@ -330,10 +330,6 @@ void directory_has_arrived(void) { log_fn(LOG_INFO, "A directory has arrived."); /* just for testing */ // directory_initiate_command(router_pick_directory_server(), // DIR_PURPOSE_FETCH_RENDDESC, "foo", 3); has_fetched_directory=1; if(options.ORPort) { /* connect to them all */ Loading Loading @@ -445,8 +441,7 @@ static void run_scheduled_events(time_t now) { if(!options.DirPort) { /* NOTE directory servers do not currently fetch directories. * Hope this doesn't bite us later. */ directory_initiate_command(router_pick_directory_server(), DIR_PURPOSE_FETCH_DIR, NULL, 0); directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0); } else { /* We're a directory; dump any old descriptors. */ dirserv_remove_old_servers(); Loading Loading @@ -641,8 +636,7 @@ static int do_hup(void) { rend_services_introduce(); } else { /* fetch a new directory */ directory_initiate_command(router_pick_directory_server(), DIR_PURPOSE_FETCH_DIR, NULL, 0); directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0); } if(options.ORPort) { router_rebuild_descriptor(); Loading
src/or/or.h +4 −5 Changes for src/or/or.h: 4 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -864,7 +864,6 @@ void assert_buf_ok(buf_t *buf); extern char *circuit_state_to_string[]; circuit_t *circuit_new(uint16_t p_circ_id, connection_t *p_conn); void circuit_close_all_marked(void); void circuit_free_cpath(crypt_path_t *cpath); int _circuit_mark_for_close(circuit_t *circ); #define circuit_mark_for_close(c) \ Loading Loading @@ -1069,8 +1068,10 @@ int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type, /********************************* directory.c ***************************/ void directory_initiate_command(routerinfo_t *router, int purpose, const char *payload, int payload_len); void directory_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len); void directory_get_from_dirserver(uint8_t purpose, const char *payload, int payload_len); int connection_dir_process_inbuf(connection_t *conn); int connection_dir_finished_flushing(connection_t *conn); int connection_dir_finished_connecting(connection_t *conn); Loading Loading @@ -1190,7 +1191,6 @@ void rend_client_desc_fetched(char *query, int success); char *rend_client_get_random_intro(char *query); int rend_parse_rendezvous_address(char *address); int rend_client_send_establish_rendezvous(circuit_t *circ); int rend_client_send_introduction(circuit_t *introcirc, circuit_t *rendcirc); /********************************* rendcommon.c ***************************/ Loading Loading @@ -1265,7 +1265,6 @@ void rotate_onion_key(void); void router_retry_connections(void); void router_upload_dir_desc_to_dirservers(void); void router_post_to_dirservers(uint8_t purpose, const char *payload, int payload_len); int router_compare_to_my_exit_policy(connection_t *conn); routerinfo_t *router_get_my_routerinfo(void); const char *router_get_my_descriptor(void); Loading
src/or/rendclient.c +1 −2 Changes for src/or/rendclient.c: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -228,8 +228,7 @@ rend_client_refetch_renddesc(const char *query) log_fn(LOG_INFO,"Would fetch a new renddesc here (for %s), but one is already in progress.", query); } else { /* not one already; initiate a dir rend desc lookup */ directory_initiate_command(router_pick_directory_server(), DIR_PURPOSE_FETCH_RENDDESC, directory_get_from_dirserver(DIR_PURPOSE_FETCH_RENDDESC, query, strlen(query)); } } Loading