Tor  0.4.7.0-alpha-dev
Macros | Typedefs | Enumerations | Functions
dirclient.h File Reference

Header file for dirclient.c. More...

#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

void dirclient_dump_total_dls (void)
 
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)
 
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)
 
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_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)
 
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 29 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 34 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 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().

◆ 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_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_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_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_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().

◆ 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.