|
Tor
0.4.7.0-alpha-dev
|
Implementation for miscellaneous controller getinfo commands. More...
#include "core/or/or.h"#include "app/config/config.h"#include "core/mainloop/connection.h"#include "core/mainloop/mainloop.h"#include "core/or/circuitlist.h"#include "core/or/connection_edge.h"#include "core/or/connection_or.h"#include "core/or/policies.h"#include "core/or/versions.h"#include "feature/client/addressmap.h"#include "feature/client/bridges.h"#include "feature/client/entrynodes.h"#include "feature/control/control.h"#include "feature/control/control_cmd.h"#include "feature/control/control_events.h"#include "feature/control/control_fmt.h"#include "feature/control/control_getinfo.h"#include "feature/control/control_proto.h"#include "feature/control/getinfo_geoip.h"#include "feature/dircache/dirserv.h"#include "feature/dirclient/dirclient.h"#include "feature/dirclient/dlstatus.h"#include "feature/dircommon/directory.h"#include "feature/hibernate/hibernate.h"#include "feature/hs/hs_cache.h"#include "feature/hs_common/shared_random_client.h"#include "feature/nodelist/authcert.h"#include "feature/nodelist/microdesc.h"#include "feature/nodelist/networkstatus.h"#include "feature/nodelist/nodelist.h"#include "feature/nodelist/routerinfo.h"#include "feature/nodelist/routerlist.h"#include "feature/relay/relay_find_addr.h"#include "feature/relay/router.h"#include "feature/relay/routermode.h"#include "feature/relay/selftest.h"#include "feature/stats/geoip_stats.h"#include "feature/stats/predict_ports.h"#include "feature/stats/rephist.h"#include "lib/version/torversion.h"#include "lib/encoding/kvline.h"#include "core/or/entry_connection_st.h"#include "core/or/or_connection_st.h"#include "core/or/origin_circuit_st.h"#include "core/or/socks_request_st.h"#include "feature/control/control_connection_st.h"#include "feature/control/control_cmd_args_st.h"#include "feature/dircache/cached_dir_st.h"#include "feature/nodelist/extrainfo_st.h"#include "feature/nodelist/microdesc_st.h"#include "feature/nodelist/networkstatus_st.h"#include "feature/nodelist/node_st.h"#include "feature/nodelist/routerinfo_st.h"#include "feature/nodelist/routerlist_st.h"#include <pwd.h>Go to the source code of this file.
Data Structures | |
| struct | getinfo_item_t |
Macros | |
| #define | CONTROL_EVENTS_PRIVATE |
| #define | CONTROL_MODULE_PRIVATE |
| #define | CONTROL_GETINFO_PRIVATE |
| #define | ITEM(name, fn, desc) { name, getinfo_helper_##fn, desc, 0 } |
| #define | PREFIX(name, fn, desc) { name, getinfo_helper_##fn, desc, 1 } |
| #define | DOC(name, desc) { name, NULL, desc, 0 } |
Typedefs | |
| typedef int(* | getinfo_helper_t) (control_connection_t *, const char *q, char **a, const char **error_out) |
Functions | |
| static char * | list_getinfo_options (void) |
| static char * | download_status_to_string (const download_status_t *dl) |
| static int | getinfo_helper_misc (control_connection_t *conn, const char *question, char **answer, const char **errmsg) |
| static char * | munge_extrainfo_into_routerinfo (const char *ri_body, const signed_descriptor_t *ri, const signed_descriptor_t *ei) |
| static int | getinfo_helper_listeners (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| STATIC int | getinfo_helper_current_time (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| STATIC int | getinfo_helper_current_consensus (consensus_flavor_t flavor, char **answer, const char **errmsg) |
| static int | controller_get_routerdescs (smartlist_t *descs_out, const char *key, const char **msg) |
| STATIC int | getinfo_helper_dir (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| static char * | digest_list_to_string (const smartlist_t *sl) |
| STATIC void | getinfo_helper_downloads_networkstatus (const char *flavor, download_status_t **dl_to_emit, const char **errmsg) |
| STATIC void | getinfo_helper_downloads_cert (const char *fp_sk_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg) |
| STATIC void | getinfo_helper_downloads_desc (const char *desc_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg) |
| STATIC void | getinfo_helper_downloads_bridge (const char *bridge_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg) |
| STATIC int | getinfo_helper_downloads (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| static int | getinfo_helper_events (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| STATIC int | getinfo_helper_onions (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| static int | getinfo_helper_liveness (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| STATIC int | getinfo_helper_rephist (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| static int | getinfo_helper_sr (control_connection_t *control_conn, const char *question, char **answer, const char **errmsg) |
| static int | handle_getinfo_helper (control_connection_t *control_conn, const char *question, char **answer, const char **err_out) |
| int | handle_control_getinfo (control_connection_t *conn, const control_cmd_args_t *args) |
Variables | |
| static const getinfo_item_t | getinfo_items [] |
| const control_cmd_syntax_t | getinfo_syntax |
Implementation for miscellaneous controller getinfo commands.
Definition in file control_getinfo.c.
| typedef int(* getinfo_helper_t) (control_connection_t *, const char *q, char **a, const char **error_out) |
Callback function for GETINFO: on a given control connection, try to answer the question q and store the newly-allocated answer in *a. If an internal error occurs, return -1 and optionally set *error_out to point to an error message to be delivered to the controller. On success, or if the key is not recognized, return 0. Do not set a if the key is not recognized but you may set error_out to improve the error message.
Definition at line 1481 of file control_getinfo.c.
|
static |
Helper for getinfo_helper_dir.
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.
Definition at line 396 of file control_getinfo.c.
|
static |
Given a smartlist of 20-byte digests, return a newly allocated string containing each of those digests in order, formatted in HEX, and terminated with a newline.
Definition at line 732 of file control_getinfo.c.
Referenced by getinfo_helper_downloads().
|
static |
Turn a download_status_t into a human-readable description in a newly allocated string. The format is specified in control-spec.txt, under the documentation for "GETINFO download/..." .
Definition at line 756 of file control_getinfo.c.
Referenced by getinfo_helper_downloads().
| STATIC int getinfo_helper_current_consensus | ( | consensus_flavor_t | flavor, |
| char ** | answer, | ||
| const char ** | errmsg | ||
| ) |
GETINFO helper for dumping different consensus flavors returns: 0 on success -1 on error.
Check from the cache
Definition at line 346 of file control_getinfo.c.
| STATIC int getinfo_helper_current_time | ( | control_connection_t * | control_conn, |
| const char * | question, | ||
| char ** | answer, | ||
| const char ** | errmsg | ||
| ) |
Implementation helper for GETINFO: answers requests for information about the current time in both local and UTC forms.
Definition at line 321 of file control_getinfo.c.
| STATIC int getinfo_helper_dir | ( | control_connection_t * | control_conn, |
| const char * | question, | ||
| char ** | answer, | ||
| const char ** | errmsg | ||
| ) |
Implementation helper for GETINFO: knows the answers for questions about directory information.
Definition at line 461 of file control_getinfo.c.
| STATIC int getinfo_helper_downloads | ( | control_connection_t * | control_conn, |
| const char * | question, | ||
| char ** | answer, | ||
| const char ** | errmsg | ||
| ) |
Implementation helper for GETINFO: knows the answers for questions about download status information.
Definition at line 1053 of file control_getinfo.c.
| STATIC void getinfo_helper_downloads_bridge | ( | const char * | bridge_req, |
| download_status_t ** | dl_to_emit, | ||
| smartlist_t ** | digest_list, | ||
| const char ** | errmsg | ||
| ) |
Handle the bridge download cases for getinfo_helper_downloads()
Definition at line 1010 of file control_getinfo.c.
Referenced by getinfo_helper_downloads().
| STATIC void getinfo_helper_downloads_cert | ( | const char * | fp_sk_req, |
| download_status_t ** | dl_to_emit, | ||
| smartlist_t ** | digest_list, | ||
| const char ** | errmsg | ||
| ) |
Handle the cert download cases for getinfo_helper_downloads()
Definition at line 864 of file control_getinfo.c.
Referenced by getinfo_helper_downloads().
| STATIC void getinfo_helper_downloads_desc | ( | const char * | desc_req, |
| download_status_t ** | dl_to_emit, | ||
| smartlist_t ** | digest_list, | ||
| const char ** | errmsg | ||
| ) |
Handle the routerdesc download cases for getinfo_helper_downloads()
Definition at line 964 of file control_getinfo.c.
Referenced by getinfo_helper_downloads().
| STATIC void getinfo_helper_downloads_networkstatus | ( | const char * | flavor, |
| download_status_t ** | dl_to_emit, | ||
| const char ** | errmsg | ||
| ) |
Handle the consensus download cases for getinfo_helper_downloads()
Definition at line 835 of file control_getinfo.c.
Referenced by getinfo_helper_downloads().
|
static |
Implementation helper for GETINFO: knows how to generate summaries of the current states of things we send events about.
Definition at line 1115 of file control_getinfo.c.
|
static |
Implementation helper for GETINFO: answers requests for information about which ports are bound.
Definition at line 260 of file control_getinfo.c.
|
static |
Implementation helper for GETINFO: answers queries about network liveness.
Definition at line 1403 of file control_getinfo.c.
|
static |
Implementation helper for GETINFO: knows the answers for various trivial-to-implement questions.
Definition at line 84 of file control_getinfo.c.
| STATIC int getinfo_helper_onions | ( | control_connection_t * | control_conn, |
| const char * | question, | ||
| char ** | answer, | ||
| const char ** | errmsg | ||
| ) |
Implementation helper for GETINFO: knows how to enumerate hidden services created via the control port.
Definition at line 1373 of file control_getinfo.c.
| STATIC int getinfo_helper_rephist | ( | control_connection_t * | control_conn, |
| const char * | question, | ||
| char ** | answer, | ||
| const char ** | errmsg | ||
| ) |
Implementation helper for GETINFO: answers queries about circuit onion handshake rephist values
Definition at line 1423 of file control_getinfo.c.
|
static |
Implementation helper for GETINFO: answers queries about shared random value.
Definition at line 1456 of file control_getinfo.c.
| int handle_control_getinfo | ( | control_connection_t * | conn, |
| const control_cmd_args_t * | args | ||
| ) |
Called when we receive a GETINFO command. Try to fetch all requested information, and reply with information or error message.
Definition at line 1753 of file control_getinfo.c.
|
static |
Lookup the 'getinfo' entry question, and return the answer in *answer (or NULL if key not recognized). Return 0 if success or unrecognized, or -1 if recognized but internal error.
Definition at line 1724 of file control_getinfo.c.
Referenced by handle_control_getinfo().
|
static |
Allocate and return a list of recognized GETINFO options.
Definition at line 1696 of file control_getinfo.c.
|
static |
Awful hack: return a newly allocated string based on a routerinfo and (possibly) an extrainfo, sticking the read-history and write-history from ei into the resulting string. The thing you get back won't necessarily have a valid signature.
New code should never use this; it's for backward compatibility.
NOTE: ri_body is as returned by signed_descriptor_get_body: it might not be NUL-terminated.
Definition at line 216 of file control_getinfo.c.
|
static |
Table mapping questions accepted by GETINFO to the functions that know how to answer them.
Definition at line 1500 of file control_getinfo.c.
Referenced by handle_getinfo_helper(), and list_getinfo_options().
| const control_cmd_syntax_t getinfo_syntax |
Definition at line 1746 of file control_getinfo.c.