|
Tor 0.5.0.0-alpha-dev
|
Header file for directory.c. More...
Go to the source code of this file.
Header file for directory.c.
Definition in file directory.h.
| #define DIR_CONN_STATE_CLIENT_FINISHED 4 |
State for connection to directory server: happy and finished.
Definition at line 26 of file directory.h.
| #define DIR_CONN_STATE_CLIENT_READING 3 |
State for connection to directory server: reading HTTP response.
Definition at line 24 of file directory.h.
| #define DIR_CONN_STATE_CLIENT_SENDING 2 |
State for connection to directory server: sending HTTP request.
Definition at line 22 of file directory.h.
| #define DIR_CONN_STATE_CONNECTING 1 |
State for connection to directory server: waiting for connect().
Definition at line 20 of file directory.h.
| #define DIR_CONN_STATE_MAX_ 6 |
Definition at line 31 of file directory.h.
| #define DIR_CONN_STATE_MIN_ 1 |
Definition at line 18 of file directory.h.
| #define DIR_CONN_STATE_SERVER_COMMAND_WAIT 5 |
State for connection at directory server: waiting for HTTP request.
Definition at line 28 of file directory.h.
| #define DIR_CONN_STATE_SERVER_WRITING 6 |
State for connection at directory server: sending HTTP response.
Definition at line 30 of file directory.h.
| #define DIR_PURPOSE_FETCH_CERTIFICATE 15 |
A connection to a directory server: download one or more directory authority certificates.
Definition at line 57 of file directory.h.
| #define DIR_PURPOSE_FETCH_CONSENSUS 14 |
A connection to a directory server: download a v3 networkstatus consensus.
Definition at line 54 of file directory.h.
| #define DIR_PURPOSE_FETCH_DETACHED_SIGNATURES 13 |
A connection to a directory server: download a v3 detached signatures object for a consensus.
Definition at line 51 of file directory.h.
| #define DIR_PURPOSE_FETCH_EXTRAINFO 7 |
A connection to a directory server: download one or more extra-info documents.
Definition at line 39 of file directory.h.
| #define DIR_PURPOSE_FETCH_HSDESC 21 |
A connection to a hidden service directory: fetch a v3 descriptor.
Definition at line 69 of file directory.h.
| #define DIR_PURPOSE_FETCH_MICRODESC 19 |
Value 17 and 18 were onion service v2 purposes. A connection to a directory server: download a microdescriptor.
Definition at line 65 of file directory.h.
| #define DIR_PURPOSE_FETCH_SERVERDESC 6 |
A connection to a directory server: download one or more server descriptors.
Definition at line 36 of file directory.h.
| #define DIR_PURPOSE_FETCH_STATUS_VOTE 12 |
A connection to a directory server: download one or more v3 networkstatus votes.
Definition at line 48 of file directory.h.
| #define DIR_PURPOSE_HAS_FETCHED_HSDESC 22 |
A connection to a directory server: set after a hidden service descriptor is downloaded.
Definition at line 72 of file directory.h.
| #define DIR_PURPOSE_IS_HS | ( | p | ) |
True iff p is a purpose corresponding to onion service that is either uploading or fetching actions.
Definition at line 85 of file directory.h.
| #define DIR_PURPOSE_IS_UPLOAD | ( | p | ) |
True iff p is a purpose corresponding to uploading data to a directory server.
Definition at line 77 of file directory.h.
| #define DIR_PURPOSE_MAX_ 22 |
Definition at line 73 of file directory.h.
| #define DIR_PURPOSE_MIN_ 6 |
Definition at line 33 of file directory.h.
| #define DIR_PURPOSE_SERVER 16 |
Purpose for connection at a directory server.
Definition at line 60 of file directory.h.
| #define DIR_PURPOSE_UPLOAD_DIR 8 |
A connection to a directory server: upload a server descriptor.
Definition at line 41 of file directory.h.
| #define DIR_PURPOSE_UPLOAD_HSDESC 20 |
A connection to a hidden service directory: upload a v3 descriptor.
Definition at line 67 of file directory.h.
| #define DIR_PURPOSE_UPLOAD_SIGNATURES 11 |
A connection to a directory server: upload a v3 consensus signature
Definition at line 45 of file directory.h.
| #define DIR_PURPOSE_UPLOAD_VOTE 10 |
A connection to a directory server: upload a v3 networkstatus vote.
Definition at line 43 of file directory.h.
| #define DSR_BASE64 (1<<1) |
Definition at line 106 of file directory.h.
| #define DSR_DIGEST256 (1<<2) |
Definition at line 107 of file directory.h.
| #define DSR_HEX (1<<0) |
Definition at line 105 of file directory.h.
| #define DSR_SORT_UNIQ (1<<3) |
Definition at line 108 of file directory.h.
| #define X_ADDRESS_HEADER "X-Your-Address-Is: " |
Definition at line 122 of file directory.h.
| #define X_OR_DIFF_FROM_CONSENSUS_HEADER "X-Or-Diff-From-Consensus: " |
Definition at line 123 of file directory.h.
| char * authdir_type_to_string | ( | dirinfo_type_t | auth | ) |
Return a newly allocated string describing auth. Only describes authority features.
Definition at line 161 of file directory.c.
Referenced by directory_post_to_dirservers().
| void connection_dir_about_to_close | ( | dir_connection_t * | dir_conn | ) |
Called when we're about to finally unlink and free a directory connection: perform necessary accounting and cleanup
Definition at line 518 of file directory.c.
Referenced by connection_about_to_close_connection().
| int connection_dir_finished_connecting | ( | dir_connection_t * | conn | ) |
Connected handler for directory connections: begin sending data to the server, and return 0. Only used when connections don't immediately connect.
Definition at line 593 of file directory.c.
Referenced by connection_finished_connecting().
| int connection_dir_finished_flushing | ( | dir_connection_t * | conn | ) |
Write handler for directory connections; called when all data has been flushed. Close the connection or wait for a response as appropriate.
Definition at line 547 of file directory.c.
Referenced by connection_finished_flushing().
| bool connection_dir_is_anonymous | ( | const dir_connection_t * | dir_conn | ) |
Return true iff the given directory connection dir_conn is anonymous, that is, it is on a circuit via a public relay and not directly from a client or bridge.
For client circuits via relays: true for 2-hop+ paths. For client circuits via bridges: true for 3-hop+ paths.
This first test if the connection is encrypted since it is a strong requirement for anonymity.
Definition at line 201 of file directory.c.
Referenced by directory_handle_command_post(), and handle_get_hs_descriptor_v3().
| int connection_dir_is_encrypted | ( | const dir_connection_t * | conn | ) |
Return true iff anything we say on conn is being encrypted before we send it to the client/server.
Definition at line 181 of file directory.c.
Referenced by connection_dir_is_anonymous(), handle_get_descriptor(), handle_get_networkstatus_bridges(), spooled_resource_estimate_size(), and spooled_resource_flush_some().
| int connection_dir_process_inbuf | ( | dir_connection_t * | conn | ) |
Read handler for directory connections. (That's connections to directory servers and connections at directory servers.)
Definition at line 476 of file directory.c.
Referenced by connection_process_inbuf().
| int connection_dir_reached_eof | ( | dir_connection_t * | conn | ) |
Called when a directory connection reaches EOF.
Definition at line 2839 of file dirclient.c.
Referenced by connection_reached_eof(), and run_connection_housekeeping().
| bool connection_dir_used_obsolete_sendme | ( | const dir_connection_t * | conn | ) |
Did conn ever send us a version 0 sendme cell and we allowed it? Used to decide whether to count consensus fetches from it in our geoip stats.
Note that this function might have false negatives in some cases, i.e. it could tell us that the conn never sent a v0 sendme when actually it did but its linked edge connection or OR connection got broken before we called this function. For our geoip stats these false negatives would mean overcounting users by including some of the v0-using clients.
We think these false positives should be unlikely or maybe even impossible when called from connection_dirserv_flushed_some(), but be careful calling it from elsewhere.
Definition at line 283 of file directory.c.
Referenced by connection_dirserv_flushed_some().
| const dir_connection_t * CONST_TO_DIR_CONN | ( | const connection_t * | c | ) |
Cast a const connection_t * to a const dir_connection_t *.
Exit with an assertion failure if the input is not a dir_connection_t.
Definition at line 102 of file directory.c.
| int dir_split_resource_into_fingerprint_pairs | ( | const char * | res, |
| smartlist_t * | pairs_out | ||
| ) |
Divide a string res of the form FP1-FP2+FP3-FP4...[.z], where each FP is a hex-encoded fingerprint, into a sequence of distinct sorted fp_pair_t. Skip malformed pairs. On success, return 0 and add those fp_pair_t into pairs_out. On failure, return -1.
Definition at line 625 of file directory.c.
Referenced by connection_dir_download_cert_failed(), handle_get_keys(), and list_pending_fpsk_downloads().
| int dir_split_resource_into_fingerprints | ( | const char * | resource, |
| smartlist_t * | fp_out, | ||
| int * | compressed_out, | ||
| int | flags | ||
| ) |
Given a directory resource request, containing zero or more strings separated by plus signs, followed optionally by ".z", store the strings, in order, into fp_out. If compressed_out is non-NULL, set it to 1 if the resource ends in ".z", else set it to 0.
If (flags & DSR_HEX), then delete all elements that aren't hex digests, and decode the rest. If (flags & DSR_BASE64), then use "-" rather than "+" as a separator, delete all the elements that aren't base64-encoded digests, and decode the rest. If (flags & DSR_DIGEST256), these digests should be 256 bits long; else they should be 160.
If (flags & DSR_SORT_UNIQ), then sort the list and remove all duplicates.
Definition at line 684 of file directory.c.
Referenced by client_likes_consensus(), connection_dir_bridge_routerdesc_failed(), connection_dir_download_cert_failed(), controller_get_routerdescs(), dir_split_resource_into_spoolable(), handle_get_keys(), handle_response_fetch_desc(), handle_response_fetch_microdesc(), and list_pending_downloads().
| char * http_get_header | ( | const char * | headers, |
| const char * | which | ||
| ) |
Return a copy of the first HTTP header in headers whose key is which. The key should be given with a terminating colon and space; this function copies everything after, up to but not including the following \r\n.
Definition at line 358 of file directory.c.
Referenced by connection_ap_process_http_connect(), connection_dir_client_reached_eof(), directory_handle_command_get(), directory_handle_command_post(), handle_get_networkstatus_bridges(), handle_response_upload_dir(), http_set_address_origin(), and parse_or_diff_from_header().
| int parse_http_command | ( | const char * | headers, |
| char ** | command_out, | ||
| char ** | url_out | ||
| ) |
Parse an HTTP request line at the start of a headers string. On failure, return -1. On success, set *command_out to a copy of the HTTP command ("get", "post", etc), set *url_out to a copy of the URL, and return 0.
Definition at line 304 of file directory.c.
Referenced by connection_ap_process_http_connect(), metrics_connection_process_inbuf(), and parse_http_url().
| int parse_http_response | ( | const char * | headers, |
| int * | code, | ||
| time_t * | date, | ||
| compress_method_t * | compression, | ||
| char ** | reason | ||
| ) |
Parse an HTTP response string headers of the form
* "HTTP/1.\%d \%d\%s\r\n...". *
If it's well-formed, assign the status code to *code and return 0. Otherwise, return -1.
On success: If date is provided, set *date to the Date header in the http headers, or 0 if no such header is found. If compression is provided, set *compression to the compression method given in the Content-Encoding header, or 0 if no such header is found, or -1 if the value of the header is not recognized. If reason is provided, strdup the reason string into it.
Definition at line 393 of file directory.c.
Referenced by connection_dir_client_reached_eof(), and connection_read_https_proxy_response().
| int purpose_needs_anonymity | ( | uint8_t | dir_purpose, |
| uint8_t | router_purpose, | ||
| const char * | resource | ||
| ) |
Return false if the directory purpose dir_purpose does not require an anonymous (three-hop) connection.
Return true 1) by default, 2) if all directory actions have specifically been configured to be over an anonymous connection, or 3) if the router is a bridge
Definition at line 114 of file directory.c.
Referenced by connection_ap_handshake_send_begin(), connection_dir_client_reached_eof(), dirclient_dump_total_dls(), directory_get_from_dirserver(), directory_initiate_request(), and directory_post_to_dirservers().
| dir_connection_t * TO_DIR_CONN | ( | connection_t * | c | ) |
Cast a connection_t * to a dir_connection_t *.
Exit with an assertion failure if the input is not a dir_connection_t.
Definition at line 89 of file directory.c.
Referenced by close_directory_connections(), connection_about_to_close_connection(), connection_ap_handshake_attach_circuit(), connection_ap_handshake_send_begin(), connection_edge_process_relay_cell_not_open(), connection_edge_send_command(), connection_finished_connecting(), connection_finished_flushing(), connection_flushed_some(), connection_free_minimal(), connection_process_inbuf(), connection_reached_eof(), connection_write_to_buf_impl_(), CONST_TO_DIR_CONN(), directory_request_is_pending(), handle_relay_msg(), list_pending_downloads(), list_pending_fpsk_downloads(), and run_connection_housekeeping().