Tor
0.4.7.0-alpha-dev
|
This file contains functions that are from the shared random subsystem but used by many part of tor. The full feature is built as part of the dirauth module. More...
#include "feature/hs_common/shared_random_client.h"
#include "app/config/config.h"
#include "feature/dirauth/authmode.h"
#include "feature/dirauth/voting_schedule.h"
#include "feature/nodelist/microdesc.h"
#include "feature/nodelist/networkstatus.h"
#include "lib/encoding/binascii.h"
#include "feature/nodelist/networkstatus_st.h"
Go to the source code of this file.
Macros | |
#define | DEFAULT_NETWORK_VOTING_INTERVAL (3600) |
#define | TESTING_DEFAULT_NETWORK_VOTING_INTERVAL (20) |
#define | ASSUME_AUTHORITY_SCHEDULING 0 |
Functions | |
static char * | srv_to_control_string (const sr_srv_t *srv) |
int | get_voting_interval (void) |
void | sr_srv_encode (char *dst, size_t dst_len, const sr_srv_t *srv) |
char * | sr_get_current_for_control (void) |
char * | sr_get_previous_for_control (void) |
const sr_srv_t * | sr_get_current (const networkstatus_t *ns) |
const sr_srv_t * | sr_get_previous (const networkstatus_t *ns) |
sr_srv_t * | sr_parse_srv (const smartlist_t *args) |
time_t | sr_state_get_start_time_of_current_protocol_run (void) |
time_t | sr_state_get_start_time_of_previous_protocol_run (void) |
unsigned int | sr_state_get_phase_duration (void) |
unsigned int | sr_state_get_protocol_run_duration (void) |
This file contains functions that are from the shared random subsystem but used by many part of tor. The full feature is built as part of the dirauth module.
Definition in file shared_random_client.c.
#define DEFAULT_NETWORK_VOTING_INTERVAL (3600) |
If we have no consensus and we are not an authority, assume that this is the voting interval. This can be used while bootstrapping as a relay and we are asked to initialize HS stats (see rep_hist_hs_stats_init())
Definition at line 40 of file shared_random_client.c.
int get_voting_interval | ( | void | ) |
Return the voting interval of the tor vote subsystem.
Definition at line 55 of file shared_random_client.c.
const sr_srv_t* sr_get_current | ( | const networkstatus_t * | ns | ) |
Return current shared random value from the latest consensus. Caller can NOT keep a reference to the returned pointer. Return NULL if none.
Definition at line 146 of file shared_random_client.c.
char* sr_get_current_for_control | ( | void | ) |
Return the current SRV string representation for the control port. Return a newly allocated string on success containing the value else "" if not found or if we don't have a valid consensus yet.
Definition at line 115 of file shared_random_client.c.
Referenced by getinfo_helper_sr().
const sr_srv_t* sr_get_previous | ( | const networkstatus_t * | ns | ) |
Return previous shared random value from the latest consensus. Caller can NOT keep a reference to the returned pointer. Return NULL if none.
Definition at line 170 of file shared_random_client.c.
char* sr_get_previous_for_control | ( | void | ) |
Return the previous SRV string representation for the control port. Return a newly allocated string on success containing the value else "" if not found or if we don't have a valid consensus yet.
Definition at line 131 of file shared_random_client.c.
Referenced by getinfo_helper_sr().
sr_srv_t* sr_parse_srv | ( | const smartlist_t * | args | ) |
Parse a list of arguments from a SRV value either from a vote, consensus or from our disk state and return a newly allocated srv object. NULL is returned on error.
The arguments' order: num_reveals, value
Definition at line 199 of file shared_random_client.c.
void sr_srv_encode | ( | char * | dst, |
size_t | dst_len, | ||
const sr_srv_t * | srv | ||
) |
Encode the given shared random value and put it in dst. Destination buffer must be at least SR_SRV_VALUE_BASE64_LEN plus the NULL byte.
Definition at line 93 of file shared_random_client.c.
Referenced by disk_state_put_srv_line(), srv_to_control_string(), and srv_to_ns_string().
unsigned int sr_state_get_phase_duration | ( | void | ) |
Return the time (in seconds) it takes to complete a full SR protocol phase (e.g. the commit phase).
Definition at line 303 of file shared_random_client.c.
Referenced by hs_get_start_time_of_next_time_period(), and hs_get_time_period_num().
unsigned int sr_state_get_protocol_run_duration | ( | void | ) |
Return the time (in seconds) it takes to complete a full SR protocol run
Definition at line 310 of file shared_random_client.c.
Referenced by get_time_period_length(), set_rotation_time(), and sr_state_get_start_time_of_previous_protocol_run().
time_t sr_state_get_start_time_of_current_protocol_run | ( | void | ) |
Return the start time of the current SR protocol run using the times from the current consensus. For example, if the latest consensus valid-after is 23/06/2017 23:00:00 and a full SR protocol run is 24 hours, this function returns 23/06/2017 00:00:00.
Definition at line 245 of file shared_random_client.c.
Referenced by hs_in_period_between_tp_and_srv(), set_descriptor_revision_counter(), set_rotation_time(), and sr_state_get_start_time_of_previous_protocol_run().
time_t sr_state_get_start_time_of_previous_protocol_run | ( | void | ) |
Return the start time of the previous SR protocol run. See sr_state_get_start_time_of_current_protocol_run() for more details.
Definition at line 290 of file shared_random_client.c.
Referenced by set_descriptor_revision_counter().
|
static |
Convert a given srv object to a string for the control port. This doesn't fail and the srv object MUST be valid.
Definition at line 25 of file shared_random_client.c.
Referenced by sr_get_current_for_control(), and sr_get_previous_for_control().