tor  0.4.0.1-alpha
Macros | Typedefs | Enumerations | Functions
dirclient.h File Reference
#include "feature/hs/hs_ident.h"

Go to the source code of this file.

Macros

#define directory_request_free(req)   FREE_AND_NULL(directory_request_t, directory_request_free_, (req))
 

Typedefs

typedef struct directory_request_t directory_request_t
 

Enumerations

enum  dir_indirection_t { DIRIND_ONEHOP =0, DIRIND_ANONYMOUS =1, DIRIND_DIRECT_CONN, DIRIND_ANON_DIRPORT }
 

Functions

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)
 
 MOCK_DECL (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)
 
int directory_must_use_begindir (const or_options_t *options)
 
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_guard_state (directory_request_t *req, struct circuit_guard_state_t *state)
 
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_set_rend_query (directory_request_t *req, const rend_data_t *query)
 
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_routerstatus (directory_request_t *req, const routerstatus_t *rs)
 
void directory_request_add_header (directory_request_t *req, const char *key, const char *val)
 
 MOCK_DECL (void, directory_initiate_request,(directory_request_t *request))
 
int router_supports_extrainfo (const char *identity_digest, int is_authority)
 
void connection_dir_client_request_failed (dir_connection_t *conn)
 
void connection_dir_client_refetch_hsdesc_if_needed (dir_connection_t *dir_conn)
 

Detailed Description

Header file for dirclient.c.

Definition in file dirclient.h.

Typedef Documentation

◆ directory_request_t

A directory_request_t describes the information about a directory request at the client side. It describes what we're going to ask for, which directory we're going to ask for it, how we're going to contact that directory, and (in some cases) what to do with it when we're done.

Definition at line 52 of file dirclient.h.

Enumeration Type Documentation

◆ dir_indirection_t

Enumeration of ways to connect to a directory server

Enumerator
DIRIND_ONEHOP 

Default: connect over a one-hop Tor circuit. Relays fall back to direct DirPort connections, clients, onion services, and bridges do not

DIRIND_ANONYMOUS 

Connect over a multi-hop anonymizing Tor circuit

DIRIND_DIRECT_CONN 

Connect to the DirPort directly

DIRIND_ANON_DIRPORT 

Connect over a multi-hop anonymizing Tor circuit to our dirport

Definition at line 32 of file dirclient.h.

Function Documentation

◆ 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 3009 of file dirclient.c.

References DIR_PURPOSE_FETCH_RENDDESC_V2, connection_t::purpose, dir_connection_t::rend_data, rend_valid_v2_service_id(), and TO_CONN.

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 719 of file dirclient.c.

References DIR_PURPOSE_FETCH_EXTRAINFO, DIR_PURPOSE_FETCH_SERVERDESC, entry_guard_failed(), entry_list_is_constrained(), dir_connection_t::guard_state, dir_connection_t::identity_digest, connection_t::purpose, and router_set_status().

Referenced by connection_dir_about_to_close().

◆ 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 197 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 579 of file dirclient.c.

References DIR_PURPOSE_FETCH_DETACHED_SIGNATURES, DIR_PURPOSE_FETCH_STATUS_VOTE, SMARTLIST_FOREACH_BEGIN, and tor_assert().

◆ 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 228 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 1082 of file dirclient.c.

References config_line_prepend().

◆ 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 1123 of file dirclient.c.

References DIR_PURPOSE_FETCH_HSDESC, and tor_assert().

◆ directory_request_free_()

void directory_request_free_ ( directory_request_t req)

Release all resources held by req.

Definition at line 968 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 946 of file dirclient.c.

References tor_assert().

◆ 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 992 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 1002 of file dirclient.c.

References DIGEST_LEN.

◆ 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 1135 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 1068 of file dirclient.c.

References get_handler_args_t::if_modified_since.

◆ 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 1030 of file dirclient.c.

◆ 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 981 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 1054 of file dirclient.c.

References DIR_PURPOSE_IS_UPLOAD, and tor_assert().

◆ directory_request_set_rend_query()

void directory_request_set_rend_query ( directory_request_t req,
const rend_data_t query 
)

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

Definition at line 1094 of file dirclient.c.

References DIR_PURPOSE_FETCH_RENDDESC_V2, DIR_PURPOSE_UPLOAD_RENDDESC_V2, and tor_assert().

◆ 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 1043 of file dirclient.c.

◆ 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 1014 of file dirclient.c.

References tor_assert().

◆ 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 1160 of file dirclient.c.

◆ 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 1109 of file dirclient.c.

References DIR_PURPOSE_UPLOAD_HSDESC, and tor_assert().

◆ 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 174 of file dirclient.c.

References routerinfo_t::caches_extra_info.