tor
master
|
Directory server core implementation. Manages directory contents and generates directories. More...
#include "or.h"
#include "buffers.h"
#include "config.h"
#include "confparse.h"
#include "channel.h"
#include "channeltls.h"
#include "command.h"
#include "connection.h"
#include "connection_or.h"
#include "conscache.h"
#include "consdiffmgr.h"
#include "control.h"
#include "directory.h"
#include "dirserv.h"
#include "hibernate.h"
#include "keypin.h"
#include "main.h"
#include "microdesc.h"
#include "networkstatus.h"
#include "nodelist.h"
#include "policies.h"
#include "protover.h"
#include "rephist.h"
#include "router.h"
#include "routerlist.h"
#include "routerparse.h"
#include "routerset.h"
#include "torcert.h"
#include "voting_schedule.h"
#include "dirauth/dirvote.h"
Data Structures | |
struct | authdir_config_t |
struct | mbw_cache_entry_s |
Macros | |
#define | DIRSERV_PRIVATE |
#define | ROUTER_ALLOW_SKEW (60*60*12) |
#define | DIR_REGEN_SLACK_TIME 30 |
#define | MAX_UNTRUSTED_NETWORKSTATUSES 16 |
#define | FP_INVALID 2 |
#define | FP_REJECT 4 |
#define | FP_BADEXIT 16 |
#define | DISABLE_DISABLING_ED25519 |
#define | REACHABLE_TIMEOUT (45*60) |
#define | HIBERNATION_PUBLICATION_SKEW (60*60) |
#define | UPTIME_TO_GUARANTEE_STABLE (3600*24*30) |
#define | MTBF_TO_GUARANTEE_STABLE (60*60*24*5) |
#define | TIME_KNOWN_TO_GUARANTEE_FAMILIAR (8*24*60*60) |
#define | WFU_TO_GUARANTEE_GUARD (0.98) |
#define | ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4 |
#define | ABSOLUTE_MIN_VALUE_FOR_FAST_FLAG 4 |
#define | V_LINE_OVERHEAD 7 |
#define | MAX_GUARDFRACTION_FILE_AGE (7*24*60*60) /* approx a week */ |
#define | GUARDFRACTION_DATE_STR "written-at" |
#define | GUARDFRACTION_INPUTS "n-inputs" |
#define | GUARDFRACTION_GUARD "guard-seen" |
#define | GUARDFRACTION_VERSION "guardfraction-file-version" |
#define | DIRSERV_CACHED_DIR_CHUNK_SIZE 8192 |
#define | DIRSERV_BUFFER_MIN 16384 |
#define | WORD() |
Typedefs | |
typedef uint32_t | router_status_t |
typedef struct authdir_config_t | authdir_config_t |
typedef struct mbw_cache_entry_s | mbw_cache_entry_t |
Enumerations | |
enum | spooled_resource_flush_status_t { SRFS_ERR = -1, SRFS_MORE = 0, SRFS_DONE } |
Functions | |
int | dirserv_add_own_fingerprint (crypto_pk_t *pk) |
int | dirserv_load_fingerprint_file (void) |
uint32_t | dirserv_router_get_status (const routerinfo_t *router, const char **msg, int severity) |
int | dirserv_would_reject_router (const routerstatus_t *rs) |
void | dirserv_free_fingerprint_list (void) |
int | authdir_wants_to_reject_router (routerinfo_t *ri, const char **msg, int complain, int *valid_out) |
void | dirserv_set_node_flags_from_authoritative_status (node_t *node, uint32_t authstatus) |
was_router_added_t | dirserv_add_multiple_descriptors (const char *desc, uint8_t purpose, const char *source, const char **msg) |
was_router_added_t | dirserv_add_descriptor (routerinfo_t *ri, const char **msg, const char *source) |
int | running_long_enough_to_decide_unreachable (void) |
void | dirserv_set_router_is_running (routerinfo_t *router, time_t now) |
int | list_server_status_v1 (smartlist_t *routers, char **router_status_out, int for_controller) |
int | directory_fetches_from_authorities (const or_options_t *options) |
int | directory_fetches_dir_info_early (const or_options_t *options) |
int | directory_fetches_dir_info_later (const or_options_t *options) |
int | directory_caches_unknown_auth_certs (const or_options_t *options) |
int | directory_caches_dir_info (const or_options_t *options) |
int | directory_permits_begindir_requests (const or_options_t *options) |
int | directory_too_idle_to_fetch_descriptors (const or_options_t *options, time_t now) |
void | cached_dir_decref (cached_dir_t *d) |
cached_dir_t * | new_cached_dir (char *s, time_t published) |
void | dirserv_set_cached_consensus_networkstatus (const char *networkstatus, const char *flavor_name, const common_digests_t *digests, const uint8_t *sha3_as_signed, time_t published) |
cached_dir_t * | dirserv_get_consensus (const char *flavor_name) |
void | dirserv_count_measured_bws (const smartlist_t *routers) |
void | dirserv_compute_performance_thresholds (digestmap_t *omit_as_sybil) |
void | dirserv_compute_bridge_flag_thresholds (void) |
STATIC void | dirserv_cache_measured_bw (const measured_bw_line_t *parsed_line, time_t as_of) |
void | dirserv_clear_measured_bw_cache (void) |
STATIC void | dirserv_expire_measured_bw_cache (time_t now) |
int | dirserv_query_measured_bw_cache_kb (const char *node_id, long *bw_kb_out, time_t *as_of_out) |
int | dirserv_has_measured_bw (const char *node_id) |
int | dirserv_get_measured_bw_cache_size (void) |
char * | dirserv_get_flag_thresholds_line (void) |
char * | routerstatus_format_entry (const routerstatus_t *rs, const char *version, const char *protocols, routerstatus_format_type_t format, int consensus_method, const vote_routerstatus_t *vrs) |
void | set_routerstatus_from_routerinfo (routerstatus_t *rs, node_t *node, routerinfo_t *ri, time_t now, int listbadexits) |
STATIC void | dirserv_set_routerstatus_testing (routerstatus_t *rs) |
STATIC int | dirserv_read_guardfraction_file_from_str (const char *guardfraction_file_str, smartlist_t *vote_routerstatuses) |
int | dirserv_read_guardfraction_file (const char *fname, smartlist_t *vote_routerstatuses) |
STATIC int | measured_bw_line_parse (measured_bw_line_t *out, const char *orig_line) |
STATIC int | measured_bw_line_apply (measured_bw_line_t *parsed_line, smartlist_t *routerstatuses) |
int | dirserv_read_measured_bandwidths (const char *from_file, smartlist_t *routerstatuses) |
int | dirserv_get_routerdesc_spool (smartlist_t *spool_out, const char *key, dir_spool_source_t source, int conn_is_encrypted, const char **msg_out) |
int | dirserv_get_routerdescs (smartlist_t *descs_out, const char *key, const char **msg) |
void | dirserv_orconn_tls_done (const tor_addr_t *addr, uint16_t or_port, const char *digest_rcvd, const ed25519_public_key_t *ed_id_rcvd) |
int | dirserv_should_launch_reachability_test (const routerinfo_t *ri, const routerinfo_t *ri_old) |
void | dirserv_single_reachability_test (time_t now, routerinfo_t *router) |
void | dirserv_test_reachability (time_t now) |
spooled_resource_t * | spooled_resource_new (dir_spool_source_t source, const uint8_t *digest, size_t digestlen) |
spooled_resource_t * | spooled_resource_new_from_cache_entry (consensus_cache_entry_t *entry) |
void | spooled_resource_free_ (spooled_resource_t *spooled) |
void | dirserv_spool_remove_missing_and_guess_size (dir_connection_t *conn, time_t cutoff, int compression, size_t *size_out, int *n_expired_out) |
void | dirserv_spool_sort (dir_connection_t *conn) |
int | connection_dirserv_flushed_some (dir_connection_t *conn) |
void | dir_conn_clear_spool (dir_connection_t *conn) |
int | validate_recommended_package_line (const char *line) |
void | dirserv_free_all (void) |
Directory server core implementation. Manages directory contents and generates directories.
This module implements most of directory cache functionality, and some of the directory authority functionality. The directory.c module delegates here in order to handle incoming requests from clients, via connection_dirserv_flushed_some() and its kin. In order to save RAM, this module is responsible for spooling directory objects (in whole or in part) onto buf_t instances, and then closing the dir_connection_t once the objects are totally flushed.
The directory.c module also delegates here for handling descriptor uploads via dirserv_add_multiple_descriptors().
Additionally, this module handles some aspects of voting, including: deciding how to vote on individual flags (based on decisions reached in rephist.c), of formatting routerstatus lines, and deciding what relays to include in an authority's vote. (TODO: Those functions could profitably be split off. They only live in this file because historically they were shared among the v1, v2, and v3 directory code.)
#define ABSOLUTE_MIN_BW_VALUE_TO_CONSIDER_KB 4 |
Don't consider routers with less bandwidth than this when computing thresholds.
#define DIR_REGEN_SLACK_TIME 30 |
How many seconds do we wait before regenerating the directory?
#define DIRSERV_BUFFER_MIN 16384 |
When we're spooling data onto our outbuf, add more whenever we dip below this threshold.
#define DIRSERV_CACHED_DIR_CHUNK_SIZE 8192 |
When spooling data from a cached_dir_t object, we always add at least this much.
#define FP_BADEXIT 16 |
We'll tell clients not to use this as an exit.
#define FP_INVALID 2 |
Believed invalid.
#define FP_REJECT 4 |
We will not publish this router.
#define GUARDFRACTION_DATE_STR "written-at" |
Static strings of guardfraction files.
#define HIBERNATION_PUBLICATION_SKEW (60*60) |
If we tested a router and found it reachable at least this long after it declared itself hibernating, it is probably done hibernating and we just missed a descriptor from it.
#define MAX_UNTRUSTED_NETWORKSTATUSES 16 |
If we're a cache, keep this many networkstatuses around from non-trusted directory authorities.
#define MTBF_TO_GUARANTEE_STABLE (60*60*24*5) |
If a router's MTBF is at least this value, then it is always stable. See above. (Corresponds to about 7 days for current decay rates.)
#define REACHABLE_TIMEOUT (45*60) |
Each server needs to have passed a reachability test no more than this number of seconds ago, or it is listed as down in the directory.
#define ROUTER_ALLOW_SKEW (60*60*12) |
How far in the future do we allow a router to get? (seconds)
#define TIME_KNOWN_TO_GUARANTEE_FAMILIAR (8*24*60*60) |
Similarly, every node with at least this much weighted time known can be considered familiar enough to be a guard. Corresponds to about 20 days for current decay rates.
#define UPTIME_TO_GUARANTEE_STABLE (3600*24*30) |
If a router's uptime is at least this value, then it is always considered stable, regardless of the rest of the network. This way we resist attacks where an attacker doubles the size of the network using allegedly high-uptime nodes, displacing all the current guards.
#define WFU_TO_GUARANTEE_GUARD (0.98) |
Similarly, every node with sufficient WFU is around enough to be a guard.
#define WORD | ( | ) |
typedef struct authdir_config_t authdir_config_t |
List of nickname->identity fingerprint mappings for all the routers that we name. Used to prevent router impersonation.
typedef struct mbw_cache_entry_s mbw_cache_entry_t |
Measured bandwidth cache entry
typedef uint32_t router_status_t |
Target of status_by_digest map.
Return code for spooled_resource_flush_some
int authdir_wants_to_reject_router | ( | routerinfo_t * | ri, |
const char ** | msg, | ||
int | complain, | ||
int * | valid_out | ||
) |
Check whether we, as a directory server, want to accept ri. If so, set its is_valid,running fields and return 0. Otherwise, return -1.
If the router is rejected, set *msg to an explanation of why.
If complain then explain at log-level 'notice' why we refused a descriptor; else explain at log-level 'info'.
void cached_dir_decref | ( | cached_dir_t * | d | ) |
Decrement the reference count on d, and free it if it no longer has any references.
int connection_dirserv_flushed_some | ( | dir_connection_t * | conn | ) |
Called whenever we have flushed some directory data in state SERVER_WRITING, or whenever we want to fill the buffer with initial directory data (so that subsequent writes will occur, and trigger this function again.)
Return 0 on success, and -1 on failure.
void dir_conn_clear_spool | ( | dir_connection_t * | conn | ) |
Remove every element from conn's outgoing spool, and delete the spool.
int directory_caches_dir_info | ( | const or_options_t * | options | ) |
Return 1 if we want to fetch and serve descriptors, networkstatuses, etc Else return 0. Check options->DirPort_set and directory_permits_begindir_requests() to see if we are willing to serve these directory documents to others via the DirPort and begindir-over-ORPort, respectively.
To check if we should fetch documents, use we_want_to_fetch_flavor and we_want_to_fetch_unknown_auth_certs instead of this function.
int directory_caches_unknown_auth_certs | ( | const or_options_t * | options | ) |
Return true iff we want to serve certificates for authorities that we don't acknowledge as authorities ourself. Use we_want_to_fetch_unknown_auth_certs to check if we want to fetch and keep these certificates.
int directory_fetches_dir_info_early | ( | const or_options_t * | options | ) |
Return 1 if we should fetch new networkstatuses, descriptors, etc on the "mirror" schedule rather than the "client" schedule.
int directory_fetches_dir_info_later | ( | const or_options_t * | options | ) |
Return 1 if we should fetch new networkstatuses, descriptors, etc on a very passive schedule – waiting long enough for ordinary clients to probably have the info we want. These would include bridge users, and maybe others in the future e.g. if a Tor client uses another Tor client as a directory guard.
int directory_fetches_from_authorities | ( | const or_options_t * | options | ) |
Return 1 if we fetch our directory material directly from the authorities, rather than from a mirror.
int directory_permits_begindir_requests | ( | const or_options_t * | options | ) |
Return 1 if we want to allow remote clients to ask us directory requests via the "begin_dir" interface, which doesn't require having any separate port open.
int directory_too_idle_to_fetch_descriptors | ( | const or_options_t * | options, |
time_t | now | ||
) |
Return 1 if we have no need to fetch new descriptors. This generally happens when we're not a dir cache and we haven't built any circuits lately.
was_router_added_t dirserv_add_descriptor | ( | routerinfo_t * | ri, |
const char ** | msg, | ||
const char * | source | ||
) |
Examine the parsed server descriptor in ri and maybe insert it into the list of server descriptors. Set *msg to a message that should be passed back to the origin of this descriptor, or NULL if there is no such message. Use source to produce better log messages.
If ri is not added to the list of server descriptors, free it. That means the caller must not access ri after this function returns, since it might have been freed.
Return the status of the operation.
This function is only called when fresh descriptors are posted, not when we re-load the cache.
was_router_added_t dirserv_add_multiple_descriptors | ( | const char * | desc, |
uint8_t | purpose, | ||
const char * | source, | ||
const char ** | msg | ||
) |
As for dirserv_add_descriptor(), but accepts multiple documents, and returns the most severe error that occurred for any one of them.
int dirserv_add_own_fingerprint | ( | crypto_pk_t * | pk | ) |
Add the fingerprint for this OR to the global list of recognized identity key fingerprints.
STATIC void dirserv_cache_measured_bw | ( | const measured_bw_line_t * | parsed_line, |
time_t | as_of | ||
) |
Store a measured bandwidth cache entry when reading the measured bandwidths file.
void dirserv_clear_measured_bw_cache | ( | void | ) |
Clear and free the measured bandwidth cache
void dirserv_compute_performance_thresholds | ( | digestmap_t * | omit_as_sybil | ) |
Look through the routerlist, the Mean Time Between Failure history, and the Weighted Fractional Uptime history, and use them to set thresholds for the Stable, Fast, and Guard flags. Update the fields stable_uptime, stable_mtbf, enough_mtbf_info, guard_wfu, guard_tk, fast_bandwidth, guard_bandwidth_including_exits, and guard_bandwidth_excluding_exits.
Also, set the is_exit flag of each router appropriately.
void dirserv_count_measured_bws | ( | const smartlist_t * | routers | ) |
Look through the routerlist, and using the measured bandwidth cache count how many measured bandwidths we know. This is used to decide whether we ever trust advertised bandwidths for purposes of assigning flags.
STATIC void dirserv_expire_measured_bw_cache | ( | time_t | now | ) |
Scan the measured bandwidth cache and remove expired entries
void dirserv_free_all | ( | void | ) |
Release all storage used by the directory server.
void dirserv_free_fingerprint_list | ( | void | ) |
Clear the current fingerprint list.
cached_dir_t* dirserv_get_consensus | ( | const char * | flavor_name | ) |
Return the latest downloaded consensus networkstatus in encoded, signed, optionally compressed format, suitable for sending to clients.
char* dirserv_get_flag_thresholds_line | ( | void | ) |
Give a statement of our current performance thresholds for inclusion in a vote document.
int dirserv_get_measured_bw_cache_size | ( | void | ) |
Get the current size of the measured bandwidth cache
int dirserv_get_routerdesc_spool | ( | smartlist_t * | spool_out, |
const char * | key, | ||
dir_spool_source_t | source, | ||
int | conn_is_encrypted, | ||
const char ** | msg_out | ||
) |
As dirserv_get_routerdescs(), but instead of getting signed_descriptor_t pointers, adds copies of digests to fps_out, and doesn't use the /tor/server/ prefix. For a /d/ request, adds descriptor digests; for other requests, adds identity digests.
int dirserv_get_routerdescs | ( | smartlist_t * | descs_out, |
const char * | key, | ||
const char ** | msg | ||
) |
Add a signed_descriptor_t to descs_out for each router matching key. The key should be either
Return 0 if we found some matching descriptors, or -1 if we do not have any descriptors, no matching descriptors, or if we did not recognize the key (URL). If -1 is returned *msg will be set to an appropriate error message.
XXXX rename this function. It's only called from the controller. XXXX in fact, refactor this function, merging as much as possible.
int dirserv_has_measured_bw | ( | const char * | node_id | ) |
Predicate wrapper for dirserv_query_measured_bw_cache()
int dirserv_load_fingerprint_file | ( | void | ) |
Load the nickname->fingerprint mappings stored in the approved-routers file. The file format is line-based, with each non-blank holding one nickname, some space, and a fingerprint for that nickname. On success, replace the current fingerprint list with the new list and return 0. On failure, leave the current fingerprint list untouched, and return -1.
void dirserv_orconn_tls_done | ( | const tor_addr_t * | addr, |
uint16_t | or_port, | ||
const char * | digest_rcvd, | ||
const ed25519_public_key_t * | ed_id_rcvd | ||
) |
Called when a TLS handshake has completed successfully with a router listening at address:or_port, and has yielded a certificate with digest digest_rcvd.
Inform the reachability checker that we could get to this relay.
int dirserv_query_measured_bw_cache_kb | ( | const char * | node_id, |
long * | bw_kb_out, | ||
time_t * | as_of_out | ||
) |
Query the cache by identity digest, return value indicates whether we found it. The bw_out and as_of_out pointers receive the cached bandwidth value and the time it was cached if not NULL.
int dirserv_read_guardfraction_file | ( | const char * | fname, |
smartlist_t * | vote_routerstatuses | ||
) |
Read a guardfraction file at fname and load all its information to vote_routerstatuses.
STATIC int dirserv_read_guardfraction_file_from_str | ( | const char * | guardfraction_file_str, |
smartlist_t * | vote_routerstatuses | ||
) |
Given a guardfraction file in a string, parse it and register the guardfraction information to the provided vote routerstatuses.
This is the rough format of the guardfraction file:
guardfraction-file-version 1 written-at <date and time> n-inputs <number of consesuses parsed> <number of days considered> guard-seen <fpr 1> <guardfraction percentage> <consensus appearances> guard-seen <fpr 2> <guardfraction percentage> <consensus appearances> guard-seen <fpr 3> <guardfraction percentage> <consensus appearances> guard-seen <fpr 4> <guardfraction percentage> <consensus appearances> guard-seen <fpr 5> <guardfraction percentage> <consensus appearances> ...
Return -1 if the parsing failed and 0 if it went smoothly. Parsing should tolerate errors in all lines but the written-at header.
int dirserv_read_measured_bandwidths | ( | const char * | from_file, |
smartlist_t * | routerstatuses | ||
) |
Read the measured bandwidth file and apply it to the list of vote_routerstatus_t. Returns -1 on error, 0 otherwise.
uint32_t dirserv_router_get_status | ( | const routerinfo_t * | router, |
const char ** | msg, | ||
int | severity | ||
) |
Check whether router has a nickname/identity key combination that we recognize from the fingerprint list, or an IP we automatically act on according to our configuration. Return the appropriate router status.
If the status is 'FP_REJECT' and msg is provided, set *msg to an explanation of why.
void dirserv_set_cached_consensus_networkstatus | ( | const char * | networkstatus, |
const char * | flavor_name, | ||
const common_digests_t * | digests, | ||
const uint8_t * | sha3_as_signed, | ||
time_t | published | ||
) |
Replace the v3 consensus networkstatus of type flavor_name that we're serving with networkstatus, published at published. No validation is performed.
void dirserv_set_node_flags_from_authoritative_status | ( | node_t * | node, |
uint32_t | authstatus | ||
) |
Update the relevant flags of node based on our opinion as a directory authority in authstatus, as returned by dirserv_router_get_status or equivalent.
void dirserv_set_router_is_running | ( | routerinfo_t * | router, |
time_t | now | ||
) |
Treat a router as alive if
STATIC void dirserv_set_routerstatus_testing | ( | routerstatus_t * | rs | ) |
Use TestingDirAuthVoteExit, TestingDirAuthVoteGuard, and TestingDirAuthVoteHSDir to give out the Exit, Guard, and HSDir flags, respectively. But don't set the corresponding node flags. Should only be called if TestingTorNetwork is set.
int dirserv_should_launch_reachability_test | ( | const routerinfo_t * | ri, |
const routerinfo_t * | ri_old | ||
) |
Called when we, as an authority, receive a new router descriptor either as an upload or a download. Used to decide whether to relaunch reachability testing for the server.
void dirserv_single_reachability_test | ( | time_t | now, |
routerinfo_t * | router | ||
) |
Helper function for dirserv_test_reachability(). Start a TLS connection to router, and annotate it with when we started the test.
void dirserv_spool_remove_missing_and_guess_size | ( | dir_connection_t * | conn, |
time_t | cutoff, | ||
int | compression, | ||
size_t * | size_out, | ||
int * | n_expired_out | ||
) |
Try to guess the number of bytes that will be needed to send the spooled objects for conn's outgoing spool. In the process, remove every element of the spool that refers to an absent object, or which was published earlier than cutoff. Set *size_out to the number of bytes, and *n_expired_out to the number of objects removed for being too old.
void dirserv_spool_sort | ( | dir_connection_t * | conn | ) |
Sort all the entries in conn by digest.
void dirserv_test_reachability | ( | time_t | now | ) |
Auth dir server only: load balance such that we only try a few connections per call.
The load balancing is such that if we get called once every ten seconds, we will cycle through all the tests in REACHABILITY_TEST_CYCLE_PERIOD seconds (a bit over 20 minutes).
int dirserv_would_reject_router | ( | const routerstatus_t * | rs | ) |
Return true if there is no point in downloading the router described by rs because this directory would reject it.
int list_server_status_v1 | ( | smartlist_t * | routers, |
char ** | router_status_out, | ||
int | for_controller | ||
) |
Based on the routerinfo_ts in routers, allocate the contents of a v1-style router-status line, and store it in *router_status_out. Return 0 on success, -1 on failure.
If for_controller is true, include the routers with very old descriptors.
This is deprecated: it's only used for controllers that want outputs in the old format.
STATIC int measured_bw_line_apply | ( | measured_bw_line_t * | parsed_line, |
smartlist_t * | routerstatuses | ||
) |
Helper function to apply a parsed measurement line to a list of bandwidth statuses. Returns true if a line is found, false otherwise.
STATIC int measured_bw_line_parse | ( | measured_bw_line_t * | out, |
const char * | orig_line | ||
) |
Helper function to parse out a line in the measured bandwidth file into a measured_bw_line_t output structure. Returns -1 on failure or 0 on success.
cached_dir_t* new_cached_dir | ( | char * | s, |
time_t | published | ||
) |
Allocate and return a new cached_dir_t containing the string s, published at published.
char* routerstatus_format_entry | ( | const routerstatus_t * | rs, |
const char * | version, | ||
const char * | protocols, | ||
routerstatus_format_type_t | format, | ||
int | consensus_method, | ||
const vote_routerstatus_t * | vrs | ||
) |
Helper: write the router-status information in rs into a newly allocated character buffer. Use the same format as in network-status documents. If version is non-NULL, add a "v" line for the platform.
consensus_method is the current consensus method when format is NS_V3_CONSENSUS or NS_V3_CONSENSUS_MICRODESC. It is ignored for other formats: pass ROUTERSTATUS_FORMAT_NO_CONSENSUS_METHOD.
Return 0 on success, -1 on failure.
The format argument has one of the following values: NS_V2 - Output an entry suitable for a V2 NS opinion document NS_V3_CONSENSUS - Output the first portion of a V3 NS consensus entry for consensus_method. NS_V3_CONSENSUS_MICRODESC - Output the first portion of a V3 microdesc consensus entry for consensus_method. NS_V3_VOTE - Output a complete V3 NS vote. If vrs is present, it contains additional information for the vote. NS_CONTROL_PORT - Output a NS document for the control port.
void set_routerstatus_from_routerinfo | ( | routerstatus_t * | rs, |
node_t * | node, | ||
routerinfo_t * | ri, | ||
time_t | now, | ||
int | listbadexits | ||
) |
Extract status information from ri and from other authority functions and store it in rs. rs is zeroed out before it is set.
We assume that ri->is_running has already been set, e.g. by dirserv_set_router_is_running(ri, now);
void spooled_resource_free_ | ( | spooled_resource_t * | spooled | ) |
Release all storage held by spooled.
spooled_resource_t* spooled_resource_new_from_cache_entry | ( | consensus_cache_entry_t * | entry | ) |
Create a new spooled_resource_t to spool the contents of entry to the user. Return the spooled object on success, or NULL on failure (which is probably caused by a failure to map the body of the item from disk).
Adds a reference to entry's reference counter.
int validate_recommended_package_line | ( | const char * | line | ) |
Return true iff line is a valid RecommendedPackages line.