Tor  0.4.7.0-alpha-dev
Macros | Functions | Variables
dirclient.c File Reference

Download directory information. More...

#include "core/or/or.h"
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
#include "core/or/connection_edge.h"
#include "core/or/policies.h"
#include "feature/client/bridges.h"
#include "feature/client/entrynodes.h"
#include "feature/control/control_events.h"
#include "feature/dirauth/authmode.h"
#include "feature/dirclient/dirclient.h"
#include "feature/dirauth/dirvote.h"
#include "feature/dirauth/shared_random.h"
#include "feature/dircache/dirserv.h"
#include "feature/dirclient/dirclient_modes.h"
#include "feature/dirclient/dlstatus.h"
#include "feature/dircommon/consdiff.h"
#include "feature/dircommon/directory.h"
#include "feature/dircommon/fp_pair.h"
#include "feature/hs/hs_cache.h"
#include "feature/hs/hs_client.h"
#include "feature/hs/hs_control.h"
#include "feature/nodelist/authcert.h"
#include "feature/nodelist/describe.h"
#include "feature/nodelist/dirlist.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/node_select.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerinfo.h"
#include "feature/nodelist/routerlist.h"
#include "feature/nodelist/routerset.h"
#include "feature/relay/relay_find_addr.h"
#include "feature/relay/routermode.h"
#include "feature/relay/selftest.h"
#include "feature/rend/rendcommon.h"
#include "feature/stats/predict_ports.h"
#include "lib/cc/ctassert.h"
#include "lib/compress/compress.h"
#include "lib/crypt_ops/crypto_format.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/encoding/confline.h"
#include "lib/err/backtrace.h"
#include "core/or/entry_connection_st.h"
#include "feature/dircache/cached_dir_st.h"
#include "feature/dirclient/dir_server_st.h"
#include "feature/dircommon/dir_connection_st.h"
#include "feature/nodelist/networkstatus_st.h"
#include "feature/nodelist/node_st.h"
#include "feature/nodelist/routerinfo_st.h"

Go to the source code of this file.

Macros

#define DIRCLIENT_PRIVATE
 
#define MAX_DIR_DL_SIZE   ((1<<24)-1) /* 16 MB - 1 */
 
#define ALLOW_DIRECTORY_TIME_SKEW   (30*60)
 
#define CONDITIONAL_CONSENSUS_FPR_LEN   3
 

Functions

static int body_is_plausible (const char *body, size_t body_len, int purpose)
 
static void connection_dir_download_routerdesc_failed (dir_connection_t *conn)
 
static void connection_dir_bridge_routerdesc_failed (dir_connection_t *conn)
 
static void connection_dir_download_cert_failed (dir_connection_t *conn, int status_code)
 
static void connection_dir_retry_bridges (smartlist_t *descs)
 
static void dir_routerdesc_download_failed (smartlist_t *failed, int status_code, int router_purpose, int was_extrainfo, int was_descriptor_digests)
 
static void dir_microdesc_download_failed (smartlist_t *failed, int status_code, const char *dir_id)
 
static void directory_send_command (dir_connection_t *conn, const int direct, const directory_request_t *req)
 
static void connection_dir_close_consensus_fetches (dir_connection_t *except_this_one, const char *resource)
 
STATIC const char * dir_conn_purpose_to_string (int purpose)
 
STATIC dirinfo_type_t dir_fetch_type (int dir_purpose, int router_purpose, const char *resource)
 
int router_supports_extrainfo (const char *identity_digest, int is_authority)
 
int directories_have_accepted_server_descriptor (void)
 
void directory_post_to_dirservers (uint8_t dir_purpose, uint8_t router_purpose, dirinfo_type_t type, const char *payload, size_t payload_len, size_t extrainfo_len)
 
STATIC int should_use_directory_guards (const or_options_t *options)
 
static const routerstatus_tdirectory_pick_generic_dirserver (dirinfo_type_t type, int pds_flags, uint8_t dir_purpose, circuit_guard_state_t **guard_state_out)
 
static void dir_consensus_request_set_additional_headers (directory_request_t *req, const char *resource)
 
void directory_get_from_dirserver (uint8_t dir_purpose, uint8_t router_purpose, const char *resource, int pds_flags, download_want_authority_t want_authority)
 
void directory_get_from_all_authorities (uint8_t dir_purpose, uint8_t router_purpose, const char *resource)
 
static int dirind_is_anon (dir_indirection_t ind)
 
static int directory_choose_address_routerstatus (const routerstatus_t *status, dir_indirection_t indirection, tor_addr_port_t *use_or_ap, tor_addr_port_t *use_dir_ap)
 
void connection_dir_client_request_failed (dir_connection_t *conn)
 
static int directory_command_should_use_begindir (const or_options_t *options, const directory_request_t *req, const char **reason)
 
directory_request_tdirectory_request_new (uint8_t dir_purpose)
 
void directory_request_free_ (directory_request_t *req)
 
void directory_request_set_or_addr_port (directory_request_t *req, const tor_addr_port_t *p)
 
void directory_request_set_dir_addr_port (directory_request_t *req, const tor_addr_port_t *p)
 
void directory_request_set_directory_id_digest (directory_request_t *req, const char *digest)
 
void directory_request_set_router_purpose (directory_request_t *req, uint8_t router_purpose)
 
void directory_request_set_indirection (directory_request_t *req, dir_indirection_t indirection)
 
void directory_request_set_resource (directory_request_t *req, const char *resource)
 
void directory_request_set_payload (directory_request_t *req, const char *payload, size_t payload_len)
 
void directory_request_set_if_modified_since (directory_request_t *req, time_t if_modified_since)
 
void directory_request_add_header (directory_request_t *req, const char *key, const char *val)
 
void directory_request_upload_set_hs_ident (directory_request_t *req, const hs_ident_dir_conn_t *ident)
 
void directory_request_fetch_set_hs_ident (directory_request_t *req, const hs_ident_dir_conn_t *ident)
 
void directory_request_set_guard_state (directory_request_t *req, circuit_guard_state_t *state)
 
static int directory_request_dir_contact_info_specified (const directory_request_t *req)
 
void directory_request_set_routerstatus (directory_request_t *req, const routerstatus_t *status)
 
static int directory_request_set_dir_from_routerstatus (directory_request_t *req)
 
void directory_initiate_request (directory_request_t *request)
 
static int compare_strs_ (const void **a, const void **b)
 
 CTASSERT (CONDITIONAL_CONSENSUS_FPR_LEN<=DIGEST_LEN)
 
static char * directory_get_consensus_url (const char *resource)
 
static void copy_ipv6_address (char *destination, const char *source, size_t len, int decorate)
 
static int load_downloaded_routers (const char *body, smartlist_t *which, int descriptor_digests, int router_purpose, const char *source)
 
static int handle_response_fetch_certificate (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_fetch_status_vote (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_fetch_detached_signatures (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_fetch_desc (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_upload_dir (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_upload_vote (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_upload_signatures (dir_connection_t *, const response_handler_args_t *)
 
static int handle_response_upload_hsdesc (dir_connection_t *, const response_handler_args_t *)
 
static int dir_client_decompress_response_body (char **bodyp, size_t *bodylenp, dir_connection_t *conn, compress_method_t compression, int anonymized_connection)
 
void dirclient_dump_total_dls (void)
 
static int connection_dir_client_reached_eof (dir_connection_t *conn)
 
STATIC int handle_response_fetch_consensus (dir_connection_t *conn, const response_handler_args_t *args)
 
STATIC int handle_response_fetch_microdesc (dir_connection_t *conn, const response_handler_args_t *args)
 
STATIC int handle_response_fetch_hsdesc_v3 (dir_connection_t *conn, const response_handler_args_t *args)
 
int connection_dir_reached_eof (dir_connection_t *conn)
 
void connection_dir_client_refetch_hsdesc_if_needed (dir_connection_t *dir_conn)
 
STATIC char * accept_encoding_header (void)
 
STATIC int allowed_anonymous_connection_compression_method (compress_method_t method)
 
STATIC void warn_disallowed_anonymous_compression_method (compress_method_t method)
 

Variables

static uint64_t total_dl [DIR_PURPOSE_MAX_][2]
 
static compress_method_t client_meth_pref []
 
static compress_method_t client_meth_allowed_anonymous_compression []
 

Detailed Description

Download directory information.

Definition in file dirclient.c.

Macro Definition Documentation

◆ ALLOW_DIRECTORY_TIME_SKEW

#define ALLOW_DIRECTORY_TIME_SKEW   (30*60)

How far in the future do we allow a directory server to tell us it is before deciding that one of us has the wrong time?

Definition at line 73 of file dirclient.c.

◆ MAX_DIR_DL_SIZE

#define MAX_DIR_DL_SIZE   ((1<<24)-1) /* 16 MB - 1 */

Maximum size, in bytes, for any directory object that we've downloaded.

Definition at line 69 of file dirclient.c.

Function Documentation

◆ accept_encoding_header()

STATIC char* accept_encoding_header ( void  )

Return a newly allocated string containing a comma separated list of supported encodings.

Definition at line 2864 of file dirclient.c.

◆ allowed_anonymous_connection_compression_method()

STATIC int allowed_anonymous_connection_compression_method ( compress_method_t  method)

Check if the given compression method is allowed for a connection that is supposed to be anonymous. Returns 1 if the compression method is allowed, otherwise 0.

Definition at line 2887 of file dirclient.c.

◆ body_is_plausible()

static int body_is_plausible ( const char *  body,
size_t  len,
int  purpose 
)
static

Return true iff body doesn't start with a plausible router or network-status or microdescriptor opening. This is a sign of possible compression.

Definition at line 1740 of file dirclient.c.

◆ compare_strs_()

static int compare_strs_ ( const void **  a,
const void **  b 
)
static

Helper for sorting

sort strings alphabetically

XXXX we have a smartlist_sort_strings() function, right?

Definition at line 1425 of file dirclient.c.

◆ connection_dir_bridge_routerdesc_failed()

static void connection_dir_bridge_routerdesc_failed ( dir_connection_t conn)
static

Called when an attempt to download a bridge's routerdesc from one of the authorities failed due to a network error. If possible attempt to download descriptors from the bridge directly.

Definition at line 784 of file dirclient.c.

◆ connection_dir_client_reached_eof()

static int connection_dir_client_reached_eof ( dir_connection_t conn)
static

We are a client, and we've finished reading the server's response. Parse it and act appropriately.

If we're still happy with using this directory server in the future, return 0. Otherwise return -1; and the caller should consider trying the request again.

The caller will take care of marking the connection for close.

Definition at line 1987 of file dirclient.c.

◆ connection_dir_client_refetch_hsdesc_if_needed()

void connection_dir_client_refetch_hsdesc_if_needed ( dir_connection_t dir_conn)

We are closing a dir connection: If dir_conn is a dir connection that tried to fetch an HS descriptor, check if it successfully fetched it, or if we need to try again.

Definition at line 2831 of file dirclient.c.

Referenced by connection_dir_about_to_close().

◆ connection_dir_client_request_failed()

void connection_dir_client_request_failed ( dir_connection_t conn)

Called when we are unable to complete the client's request to a directory server due to a network error: Mark the router as down and try again if possible.

Definition at line 704 of file dirclient.c.

Referenced by connection_dir_about_to_close().

◆ connection_dir_download_cert_failed()

static void connection_dir_download_cert_failed ( dir_connection_t conn,
int  status 
)
static

Called when an attempt to fetch a certificate fails.

Definition at line 808 of file dirclient.c.

◆ connection_dir_download_routerdesc_failed()

static void connection_dir_download_routerdesc_failed ( dir_connection_t conn)
static

Called when an attempt to download one or more router descriptors or extra-info documents on connection conn failed.

Definition at line 765 of file dirclient.c.

◆ connection_dir_reached_eof()

int connection_dir_reached_eof ( dir_connection_t conn)

Called when a directory connection reaches EOF.

Definition at line 2810 of file dirclient.c.

Referenced by connection_reached_eof().

◆ connection_dir_retry_bridges()

static void connection_dir_retry_bridges ( smartlist_t descs)
static

Helper: Attempt to fetch directly the descriptors of each bridge listed in failed.

Definition at line 747 of file dirclient.c.

Referenced by dir_routerdesc_download_failed().

◆ copy_ipv6_address()

static void copy_ipv6_address ( char *  destination,
const char *  source,
size_t  len,
int  decorate 
)
static

Copies the ipv6 from source to destination, subject to buffer size limit size. If decorate is true, makes sure the copied address is decorated.

Definition at line 1489 of file dirclient.c.

◆ dir_conn_purpose_to_string()

STATIC const char* dir_conn_purpose_to_string ( int  purpose)

Return a string describing a given directory connection purpose.

Definition at line 97 of file dirclient.c.

◆ dir_consensus_request_set_additional_headers()

static void dir_consensus_request_set_additional_headers ( directory_request_t req,
const char *  resource 
)
static

Set the extra fields in req that are used when requesting a consensus of type resource.

Right now, these fields are if-modified-since and x-or-diff-from-consensus.

Definition at line 364 of file dirclient.c.

◆ dir_fetch_type()

STATIC dirinfo_type_t dir_fetch_type ( int  dir_purpose,
int  router_purpose,
const char *  resource 
)

Return the requisite directory information types.

Definition at line 133 of file dirclient.c.

◆ dir_microdesc_download_failed()

static void dir_microdesc_download_failed ( smartlist_t failed,
int  status_code,
const char *  dir_id 
)
static

Called when a connection to download microdescriptors from relay with dir_id has failed in whole or in part. failed is a list of every microdesc digest we didn't get. status_code is the http status code we received. Reschedule the microdesc downloads as appropriate.

Definition at line 2994 of file dirclient.c.

◆ dir_routerdesc_download_failed()

static void dir_routerdesc_download_failed ( smartlist_t failed,
int  status_code,
int  router_purpose,
int  was_extrainfo,
int  was_descriptor_digests 
)
static

Called when one or more routerdesc (or extrainfo, if was_extrainfo) fetches have failed (with uppercase fingerprints listed in failed, either as descriptor digests or as identity digests based on was_descriptor_digests).

Definition at line 2951 of file dirclient.c.

◆ dirclient_dump_total_dls()

void dirclient_dump_total_dls ( void  )

Heartbeat: dump a summary of how many bytes of which purpose we've downloaded, when bootstrapping and when not bootstrapping.

Definition at line 1949 of file dirclient.c.

◆ directories_have_accepted_server_descriptor()

int directories_have_accepted_server_descriptor ( void  )

Return true iff any trusted directory authority has accepted our server descriptor.

We consider any authority sufficient because waiting for all of them means it never happens while any authority is down; we don't go for something more complex in the middle (like >1/3 or >1/2 or >=1/2) because that doesn't seem necessary yet.

Definition at line 198 of file dirclient.c.

◆ directory_command_should_use_begindir()

static int directory_command_should_use_begindir ( const or_options_t options,
const directory_request_t req,
const char **  reason 
)
static

Evaluate the situation and decide if we should use an encrypted "begindir-style" connection for this directory request. 0) If there is no DirPort, yes. 1) If or_port is 0, or it's a direct conn and or_port is firewalled or we're a dir mirror, no. 2) If we prefer to avoid begindir conns, and we're not fetching or publishing a bridge relay descriptor, no. 3) Else yes. If returning 0, return in *reason why we can't use begindir. reason must not be NULL.

Definition at line 864 of file dirclient.c.

◆ directory_get_consensus_url()

static char* directory_get_consensus_url ( const char *  resource)
static

Return the URL we should use for a consensus download.

Use the "conditional consensus downloading" feature described in dir-spec.txt, i.e. GET .../consensus/fpr+fpr+fpr

If 'resource' is provided, it is the name of a consensus flavor to request.

Definition at line 1443 of file dirclient.c.

◆ directory_get_from_all_authorities()

void directory_get_from_all_authorities ( uint8_t  dir_purpose,
uint8_t  router_purpose,
const char *  resource 
)

As directory_get_from_dirserver, but initiates a request to every directory authority other than ourself. Only for use by authorities when searching for missing information while voting.

Definition at line 580 of file dirclient.c.

◆ directory_get_from_dirserver()

void directory_get_from_dirserver ( uint8_t  dir_purpose,
uint8_t  router_purpose,
const char *  resource,
int  pds_flags,
download_want_authority_t  want_authority 
)

Start a connection to a random running directory server, using connection purpose dir_purpose, intending to fetch descriptors of purpose router_purpose, and requesting resource. Use pds_flags as arguments to router_pick_directory_server() or router_pick_trusteddirserver().

Definition at line 448 of file dirclient.c.

◆ directory_initiate_request()

void directory_initiate_request ( directory_request_t request)

Launch the provided directory request, configured in request. After this function is called, you can free request.

Definition at line 1222 of file dirclient.c.

Referenced by directory_launch_v3_desc_fetch(), and hs_service_upload_desc_to_dir().

◆ directory_pick_generic_dirserver()

static const routerstatus_t* directory_pick_generic_dirserver ( dirinfo_type_t  type,
int  pds_flags,
uint8_t  dir_purpose,
circuit_guard_state_t **  guard_state_out 
)
static

Pick an unconstrained directory server from among our guards, the latest networkstatus, or the fallback dirservers, for use in downloading information of type type, and return its routerstatus.

Definition at line 330 of file dirclient.c.

◆ directory_post_to_dirservers()

void directory_post_to_dirservers ( uint8_t  dir_purpose,
uint8_t  router_purpose,
dirinfo_type_t  type,
const char *  payload,
size_t  payload_len,
size_t  extrainfo_len 
)

Start a connection to every suitable directory authority, using connection purpose dir_purpose and uploading payload (of length payload_len). The dir_purpose should be one of 'DIR_PURPOSE_UPLOAD_{DIR|VOTE|SIGNATURES}'.

router_purpose describes the type of descriptor we're publishing, if we're publishing a descriptor – e.g. general or bridge.

type specifies what sort of dir authorities (V3, BRIDGE, etc) we should upload to.

If extrainfo_len is nonzero, the first payload_len bytes of payload hold a router descriptor, and the next extrainfo_len bytes of payload hold an extra-info document. Upload the descriptor to all authorities, and the extra-info document to all authorities that support it.

Definition at line 229 of file dirclient.c.

◆ directory_request_add_header()

void directory_request_add_header ( directory_request_t req,
const char *  key,
const char *  val 
)

Include a header of name key with content val in the request. Neither may include newlines or other odd characters. Their ordering is not currently guaranteed.

Note that, as elsewhere in this module, header keys include a trailing colon and space.

Definition at line 1054 of file dirclient.c.

◆ directory_request_dir_contact_info_specified()

static int directory_request_dir_contact_info_specified ( const directory_request_t req)
static

Internal: Return true if any information for contacting the directory in req has been set, other than by the routerstatus.

Definition at line 1102 of file dirclient.c.

◆ directory_request_fetch_set_hs_ident()

void directory_request_fetch_set_hs_ident ( directory_request_t req,
const hs_ident_dir_conn_t ident 
)

Set an object containing HS connection identifier to be associated with this fetch request. Note that only an alias to ident is stored, so the ident object must outlive the request.

Definition at line 1080 of file dirclient.c.

Referenced by directory_launch_v3_desc_fetch().

◆ directory_request_free_()

void directory_request_free_ ( directory_request_t req)

Release all resources held by req.

Definition at line 940 of file dirclient.c.

◆ directory_request_new()

directory_request_t* directory_request_new ( uint8_t  dir_purpose)

Create and return a new directory_request_t with purpose dir_purpose.

Definition at line 919 of file dirclient.c.

Referenced by directory_launch_v3_desc_fetch(), and hs_service_upload_desc_to_dir().

◆ directory_request_set_dir_addr_port()

void directory_request_set_dir_addr_port ( directory_request_t req,
const tor_addr_port_t p 
)

Set the address and dirport to use for this directory request. If there is no dirport, we'll have to connect over the OR port. (If there are both, the indirection setting determines which to use.)

Definition at line 964 of file dirclient.c.

◆ directory_request_set_dir_from_routerstatus()

static int directory_request_set_dir_from_routerstatus ( directory_request_t req)
static

Helper: update the addresses, ports, and identities in req from the routerstatus object in req. Return 0 on success. On failure, warn and return -1.

Definition at line 1129 of file dirclient.c.

◆ directory_request_set_directory_id_digest()

void directory_request_set_directory_id_digest ( directory_request_t req,
const char *  digest 
)

Set the RSA identity digest of the directory to use for this directory request.

Definition at line 974 of file dirclient.c.

◆ directory_request_set_guard_state()

void directory_request_set_guard_state ( directory_request_t req,
circuit_guard_state_t *  state 
)

Set a static circuit_guard_state_t object to affliate with the request in req. This object will receive notification when the attempt to connect to the guard either succeeds or fails.

Definition at line 1092 of file dirclient.c.

◆ directory_request_set_if_modified_since()

void directory_request_set_if_modified_since ( directory_request_t req,
time_t  if_modified_since 
)

Set an if-modified-since date to send along with the request. The default is 0 (meaning, send no if-modified-since header).

Definition at line 1040 of file dirclient.c.

◆ directory_request_set_indirection()

void directory_request_set_indirection ( directory_request_t req,
dir_indirection_t  indirection 
)

Set the indirection to be used for the directory request. The indirection parameter configures whether to connect to a DirPort or ORPort, and whether to anonymize the connection. DIRIND_ONEHOP (use ORPort, don't anonymize) is the default. See dir_indirection_t for more information.

Definition at line 1002 of file dirclient.c.

Referenced by directory_launch_v3_desc_fetch(), and hs_service_upload_desc_to_dir().

◆ directory_request_set_or_addr_port()

void directory_request_set_or_addr_port ( directory_request_t req,
const tor_addr_port_t p 
)

Set the address and OR port to use for this directory request. If there is no OR port, we'll have to connect over the dirport. (If there are both, the indirection setting determines which to use.)

Definition at line 953 of file dirclient.c.

◆ directory_request_set_payload()

void directory_request_set_payload ( directory_request_t req,
const char *  payload,
size_t  payload_len 
)

Set a pointer to the payload to include with this directory request, along with its length. Note that only an alias to payload is stored, so the payload must outlive the request.

Definition at line 1026 of file dirclient.c.

Referenced by hs_service_upload_desc_to_dir().

◆ directory_request_set_resource()

void directory_request_set_resource ( directory_request_t req,
const char *  resource 
)

Set a pointer to the resource to request from a directory. Different request types use resources to indicate different components of their URL. Note that only an alias to resource is stored, so the resource must outlive the request.

Definition at line 1015 of file dirclient.c.

Referenced by directory_launch_v3_desc_fetch(), and hs_service_upload_desc_to_dir().

◆ directory_request_set_router_purpose()

void directory_request_set_router_purpose ( directory_request_t req,
uint8_t  router_purpose 
)

Set the router purpose associated with uploaded and downloaded router descriptors and extrainfo documents in this directory request. The purpose must be one of ROUTER_PURPOSE_GENERAL (the default) or ROUTER_PURPOSE_BRIDGE.

Definition at line 986 of file dirclient.c.

◆ directory_request_set_routerstatus()

void directory_request_set_routerstatus ( directory_request_t req,
const routerstatus_t status 
)

Set the routerstatus to use for the directory associated with this request. If this option is set, then no other function to set the directory's address or identity should be called.

Definition at line 1117 of file dirclient.c.

Referenced by directory_launch_v3_desc_fetch(), and hs_service_upload_desc_to_dir().

◆ directory_request_upload_set_hs_ident()

void directory_request_upload_set_hs_ident ( directory_request_t req,
const hs_ident_dir_conn_t ident 
)

Set an object containing HS connection identifier to be associated with this request. Note that only an alias to ident is stored, so the ident object must outlive the request.

Definition at line 1066 of file dirclient.c.

Referenced by hs_service_upload_desc_to_dir().

◆ directory_send_command()

static void directory_send_command ( dir_connection_t conn,
const int  direct,
const directory_request_t req 
)
static

Queue an appropriate HTTP command for request on conn->outbuf. If direct is true, we're making a non-anonymized connection to the dirport.

Definition at line 1506 of file dirclient.c.

◆ dirind_is_anon()

static int dirind_is_anon ( dir_indirection_t  ind)
static

Return true iff ind requires a multihop circuit.

Definition at line 605 of file dirclient.c.

Referenced by directory_send_command().

◆ handle_response_fetch_certificate()

static int handle_response_fetch_certificate ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to a request for one or more authority certificates

Definition at line 2307 of file dirclient.c.

◆ handle_response_fetch_consensus()

STATIC int handle_response_fetch_consensus ( dir_connection_t conn,
const response_handler_args_t *  args 
)

Handler function: processes a response to a request for a networkstatus consensus document by checking the consensus, storing it, and marking router requests as reachable.

Definition at line 2194 of file dirclient.c.

◆ handle_response_fetch_desc()

static int handle_response_fetch_desc ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to a request for a group of server descriptors or an extrainfo documents.

Definition at line 2440 of file dirclient.c.

◆ handle_response_fetch_detached_signatures()

static int handle_response_fetch_detached_signatures ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to a request for the signatures that an authority knows about on a given consensus.

Definition at line 2405 of file dirclient.c.

◆ handle_response_fetch_hsdesc_v3()

STATIC int handle_response_fetch_hsdesc_v3 ( dir_connection_t conn,
const response_handler_args_t *  args 
)

Handler function: processes a response to a request for a v3 hidden service descriptor.

Definition at line 2742 of file dirclient.c.

◆ handle_response_fetch_microdesc()

STATIC int handle_response_fetch_microdesc ( dir_connection_t conn,
const response_handler_args_t *  args 
)

Handler function: processes a response to a request for a group of microdescriptors

Definition at line 2541 of file dirclient.c.

◆ handle_response_fetch_status_vote()

static int handle_response_fetch_status_vote ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to a request for an authority's current networkstatus vote.

Definition at line 2368 of file dirclient.c.

◆ handle_response_upload_dir()

static int handle_response_upload_dir ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to a POST request to upload our router descriptor.

Definition at line 2601 of file dirclient.c.

◆ handle_response_upload_hsdesc()

static int handle_response_upload_hsdesc ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to a POST request to upload an hidden service descriptor.

Definition at line 2764 of file dirclient.c.

◆ handle_response_upload_signatures()

static int handle_response_upload_signatures ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to POST request to upload our view of the signatures on the current consensus.

Definition at line 2705 of file dirclient.c.

◆ handle_response_upload_vote()

static int handle_response_upload_vote ( dir_connection_t conn,
const response_handler_args_t *  args 
)
static

Handler function: processes a response to POST request to upload our own networkstatus vote.

Definition at line 2669 of file dirclient.c.

◆ load_downloaded_routers()

static int load_downloaded_routers ( const char *  body,
smartlist_t which,
int  descriptor_digests,
int  router_purpose,
const char *  source 
)
static

Called when we've just fetched a bunch of router descriptors in body. The list which, if present, holds digests for descriptors we requested: descriptor digests if descriptor_digests is true, or identity digests otherwise. Parse the descriptors, validate them, and annotate them as having purpose purpose and as having been downloaded from source.

Return the number of routers actually added.

Definition at line 1771 of file dirclient.c.

◆ router_supports_extrainfo()

int router_supports_extrainfo ( const char *  identity_digest,
int  is_authority 
)

Return true iff identity_digest is the digest of a router which says that it caches extrainfos. (If is_authority we always believe that to be true.)

Definition at line 175 of file dirclient.c.

◆ should_use_directory_guards()

STATIC int should_use_directory_guards ( const or_options_t options)

Return true iff, according to the values in options, we should be using directory guards for direct downloads of directory information.

Definition at line 309 of file dirclient.c.

◆ warn_disallowed_anonymous_compression_method()

STATIC void warn_disallowed_anonymous_compression_method ( compress_method_t  method)

Log a warning when a remote server has sent us a document using a compression method that is not allowed for anonymous directory requests.

Definition at line 2909 of file dirclient.c.

Variable Documentation

◆ client_meth_allowed_anonymous_compression

compress_method_t client_meth_allowed_anonymous_compression[]
static
Initial value:
= {
ZLIB_METHOD,
GZIP_METHOD,
NO_METHOD
}

Array of allowed compression methods to use (if supported) when receiving a response from a request that was required to be anonymous.

Definition at line 2855 of file dirclient.c.

◆ client_meth_pref

compress_method_t client_meth_pref[]
static
Initial value:
= {
LZMA_METHOD,
ZSTD_METHOD,
ZLIB_METHOD,
GZIP_METHOD,
NO_METHOD
}

Array of compression methods to use (if supported) for requesting compressed data, ordered from best to worst.

Definition at line 2845 of file dirclient.c.

◆ total_dl

uint64_t total_dl[DIR_PURPOSE_MAX_][2]
static

Total number of bytes downloaded of each directory purpose, when bootstrapped, and when not bootstrapped.

(For example, the number of bytes downloaded of purpose p while not fully bootstrapped is total_dl[p][false].)

Definition at line 1942 of file dirclient.c.