Tor  0.4.5.0-alpha-dev
Macros | Functions
shared_random_client.c File Reference

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/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 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_tsr_get_current (const networkstatus_t *ns)
 
const sr_srv_tsr_get_previous (const networkstatus_t *ns)
 
sr_srv_tsr_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)
 

Detailed Description

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.

Macro Definition Documentation

◆ DEFAULT_NETWORK_VOTING_INTERVAL

#define DEFAULT_NETWORK_VOTING_INTERVAL   (3600)

If we have no consensus and we are not an authority, assume that this is the voting interval. We should never actually use this: only authorities should be trying to figure out the schedule when they don't have a consensus.

Definition at line 41 of file shared_random_client.c.

Function Documentation

◆ get_voting_interval()

int get_voting_interval ( void  )

Return the voting interval of the tor vote subsystem.

Definition at line 55 of file shared_random_client.c.

◆ sr_get_current()

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 142 of file shared_random_client.c.

◆ sr_get_current_for_control()

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 111 of file shared_random_client.c.

Referenced by getinfo_helper_sr().

◆ sr_get_previous()

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 165 of file shared_random_client.c.

◆ sr_get_previous_for_control()

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 127 of file shared_random_client.c.

Referenced by getinfo_helper_sr().

◆ sr_parse_srv()

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 193 of file shared_random_client.c.

◆ sr_srv_encode()

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 89 of file shared_random_client.c.

Referenced by disk_state_put_srv_line(), srv_to_control_string(), and srv_to_ns_string().

◆ sr_state_get_phase_duration()

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 300 of file shared_random_client.c.

Referenced by hs_get_start_time_of_next_time_period(), and hs_get_time_period_num().

◆ sr_state_get_protocol_run_duration()

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 307 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().

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

◆ 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 287 of file shared_random_client.c.

Referenced by set_descriptor_revision_counter().

◆ srv_to_control_string()

static char* srv_to_control_string ( const sr_srv_t srv)
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 24 of file shared_random_client.c.

Referenced by sr_get_current_for_control(), and sr_get_previous_for_control().