Tor 0.4.9.2-alpha-dev
|
Implement various commands for Tor's control-socket interface. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "lib/confmgt/confmgt.h"
#include "app/main/main.h"
#include "core/mainloop/connection.h"
#include "core/or/circuitbuild.h"
#include "core/or/circuitlist.h"
#include "core/or/circuituse.h"
#include "core/or/connection_edge.h"
#include "core/or/circuitstats.h"
#include "core/or/extendinfo.h"
#include "feature/client/addressmap.h"
#include "feature/client/dnsserv.h"
#include "feature/client/entrynodes.h"
#include "feature/control/control.h"
#include "feature/control/control_auth.h"
#include "feature/control/control_cmd.h"
#include "feature/control/control_hs.h"
#include "feature/control/control_events.h"
#include "feature/control/control_getinfo.h"
#include "feature/control/control_proto.h"
#include "feature/hs/hs_config.h"
#include "feature/hs/hs_control.h"
#include "feature/hs/hs_service.h"
#include "feature/nodelist/nodelist.h"
#include "feature/nodelist/routerinfo.h"
#include "feature/nodelist/routerlist.h"
#include "feature/rend/rendcommon.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_util.h"
#include "lib/encoding/confline.h"
#include "lib/encoding/kvline.h"
#include "core/or/cpath_build_state_st.h"
#include "core/or/entry_connection_st.h"
#include "core/or/origin_circuit_st.h"
#include "core/or/socks_request_st.h"
#include "feature/control/control_cmd_args_st.h"
#include "feature/control/control_connection_st.h"
#include "feature/nodelist/node_st.h"
#include "feature/nodelist/routerinfo_st.h"
#include "app/config/statefile.h"
Go to the source code of this file.
Data Structures | |
struct | control_cmd_def_t |
Macros | |
#define | CONTROL_MODULE_PRIVATE |
#define | CONTROL_CMD_PRIVATE |
#define | CONTROL_EVENTS_PRIVATE |
#define | STATE_IS_OPEN(s) ((s) == CONTROL_CONN_STATE_OPEN) |
#define | SEND_ERRMSG(code, msg) |
#define | SEND_ERRMSG(code, msg) control_printf_endreply(conn, code, msg ": %s", errstring); |
#define | CMD_FL_WIPE (1u<<0) |
#define | ONE_LINE(name, flags) |
#define | MULTLINE(name, flags) |
#define | OBSOLETE(name) |
Typedefs | |
typedef int(* | handler_fn_t) (control_connection_t *conn, const control_cmd_args_t *args) |
Implement various commands for Tor's control-socket interface.
Definition in file control_cmd.c.
#define CMD_FL_WIPE (1u<<0) |
Indicates that the command's arguments are sensitive, and should be memwiped after use.
Definition at line 2126 of file control_cmd.c.
#define CONTROL_CMD_PRIVATE |
Definition at line 11 of file control_cmd.c.
#define CONTROL_EVENTS_PRIVATE |
Definition at line 12 of file control_cmd.c.
#define CONTROL_MODULE_PRIVATE |
Definition at line 10 of file control_cmd.c.
#define MULTLINE | ( | name, | |
flags | |||
) |
Macro: declare a command with a multi-line argument and a given set of flags.
Definition at line 2144 of file control_cmd.c.
#define OBSOLETE | ( | name | ) |
Macro: declare an obsolete command. (Obsolete commands give a different error than non-existent ones.)
Definition at line 2155 of file control_cmd.c.
#define ONE_LINE | ( | name, | |
flags | |||
) |
Macro: declare a command with a one-line argument, a given set of flags, and a syntax definition.
Definition at line 2132 of file control_cmd.c.
#define SEND_ERRMSG | ( | code, | |
msg | |||
) |
#define STATE_IS_OPEN | ( | s | ) | ((s) == CONTROL_CONN_STATE_OPEN) |
Yield true iff s is the state of a control_connection_t that has finished authentication and is accepting commands.
Definition at line 64 of file control_cmd.c.
typedef int(* handler_fn_t) (control_connection_t *conn, const control_cmd_args_t *args) |
Function pointer to a handler function for a controller command.
Definition at line 2097 of file control_cmd.c.
|
static |
Compose the auth methods line of a PROTOCOLINFO reply.
Definition at line 1293 of file control_cmd.c.
STATIC hs_service_add_ephemeral_status_t add_onion_helper_add_service | ( | int | hs_version, |
add_onion_secret_key_t * | pk, | ||
smartlist_t * | port_cfgs, | ||
int | max_streams, | ||
int | max_streams_close_circuit, | ||
int | pow_defenses_enabled, | ||
uint32_t | pow_queue_rate, | ||
uint32_t | pow_queue_burst, | ||
smartlist_t * | auth_clients_v3, | ||
char ** | address_out | ||
) |
Definition at line 1578 of file control_cmd.c.
STATIC int add_onion_helper_keyarg | ( | const char * | arg, |
int | discard_pk, | ||
const char ** | key_new_alg_out, | ||
char ** | key_new_blob_out, | ||
add_onion_secret_key_t * | decoded_key, | ||
int * | hs_version, | ||
control_connection_t * | conn | ||
) |
Helper function to handle parsing the KeyType:KeyBlob argument to the ADD_ONION command. Return a new crypto_pk_t and if a new key was generated and the private key not discarded, the algorithm and serialized private key, or NULL and an optional control protocol error message on failure. The caller is responsible for freeing the returned key_new_blob.
Note: The error messages returned are deliberately vague to avoid echoing key material.
Note: conn is only used for writing control replies. For testing purposes, it can be NULL if control_write_reply() is appropriately mocked.
Definition at line 1910 of file control_cmd.c.
|
static |
Return true iff addr is unusable as a mapaddress target because of containing funny characters.
Definition at line 617 of file control_cmd.c.
Referenced by handle_control_mapaddress().
|
static |
Given a string, convert it to a circuit purpose.
Definition at line 703 of file control_cmd.c.
|
static |
Return true iff lines contains flags as a no-value (keyword-only) entry.
Definition at line 241 of file control_cmd.c.
Referenced by handle_control_saveconf().
void control_cmd_args_free_ | ( | control_cmd_args_t * | args | ) |
Release all storage held in args
Definition at line 70 of file control_cmd.c.
void control_cmd_args_wipe | ( | control_cmd_args_t * | args | ) |
Erase all memory held in args.
Definition at line 87 of file control_cmd.c.
void control_cmd_free_all | ( | void | ) |
Definition at line 2276 of file control_cmd.c.
STATIC control_cmd_args_t * control_cmd_parse_args | ( | const char * | command, |
const control_cmd_syntax_t * | syntax, | ||
size_t | body_len, | ||
const char * | body, | ||
char ** | error_out | ||
) |
Helper: parse the arguments to a command according to syntax. On success, set *error_out to NULL and return a newly allocated control_cmd_args_t. On failure, set *error_out to newly allocated error string, and return NULL.
Definition at line 159 of file control_cmd.c.
Referenced by handle_single_control_command().
|
static |
Helper for setconf and resetconf. Acts like setconf, except it passes use_defaults on to options_trial_assign(). Modifies the contents of body.
Definition at line 568 of file control_cmd.c.
Referenced by handle_control_resetconf(), and handle_control_setconf().
|
static |
Return a comma-separated list of authentication methods for handle_control_protocolinfo(). Caller must free this string.
Definition at line 1251 of file control_cmd.c.
Referenced by add_authmethods().
|
static |
Given a text circuit id, return the corresponding circuit.
Definition at line 537 of file control_cmd.c.
smartlist_t * get_detached_onion_services | ( | void | ) |
Return a list of detached onion services, or NULL if none exist.
Definition at line 1618 of file control_cmd.c.
Referenced by getinfo_helper_onions().
|
static |
Return escaped cookie filename. Caller must free this string. Return NULL if cookie authentication is disabled.
Definition at line 1276 of file control_cmd.c.
Referenced by add_authmethods().
|
static |
Given a text stream id, return the corresponding AP connection.
Definition at line 549 of file control_cmd.c.
Referenced by handle_control_redirectstream().
|
static |
Called when we get a ADD_ONION command; parse the body, and set up the new ephemeral Onion Service.
Definition at line 1643 of file control_cmd.c.
|
static |
Called when we get an ATTACHSTREAM message. Try to attach the requested stream, and report success or failure.
Definition at line 938 of file control_cmd.c.
|
static |
Called when we get a CLOSECIRCUIT command; try to close the named circuit and report success or failure.
Definition at line 1175 of file control_cmd.c.
|
static |
Called when we get a CLOSESTREAM command; try to close the named stream and report success or failure.
Definition at line 1134 of file control_cmd.c.
int handle_control_command | ( | control_connection_t * | conn, |
uint32_t | cmd_data_len, | ||
char * | args | ||
) |
Run a given controller command, as selected by the current_cmd field of conn.
Definition at line 2254 of file control_cmd.c.
|
static |
Called when we get a DEL_ONION command; parse the body, and remove the existing ephemeral Onion Service.
Definition at line 2005 of file control_cmd.c.
|
static |
Implementation for the DROPGUARDS command.
Definition at line 1385 of file control_cmd.c.
|
static |
Called when we get a DROPOWNERSHIP command. Mark this connection as a non-owning connection, so that we will not exit if the connection closes.
Definition at line 520 of file control_cmd.c.
|
static |
Implementation for the DROPTIMEOUTS command.
Definition at line 1410 of file control_cmd.c.
|
static |
Called when we get an EXTENDCIRCUIT message. Try to extend the listed circuit, and report success or failure.
Definition at line 726 of file control_cmd.c.
|
static |
Called when we receive a GETCONF message. Parse the request, and reply with a CONFVALUE or an ERROR message
Definition at line 286 of file control_cmd.c.
|
static |
Implementation for the HSFETCH command.
Definition at line 1443 of file control_cmd.c.
|
static |
Implementation for the HSPOST command.
Definition at line 1513 of file control_cmd.c.
|
static |
Called when we get a +LOADCONF message.
Definition at line 337 of file control_cmd.c.
|
static |
Called when we get a MAPADDRESS command; try to bind all listed addresses, and report success or failure.
Definition at line 635 of file control_cmd.c.
|
static |
Called when we get an obsolete command: tell the controller that it is obsolete.
Definition at line 2083 of file control_cmd.c.
|
static |
Called when we get a POSTDESCRIPTOR message. Try to learn the provided descriptor, and report success or failure.
Definition at line 1031 of file control_cmd.c.
|
static |
Called when we get a PROTOCOLINFO command: send back a reply.
Definition at line 1310 of file control_cmd.c.
|
static |
Called when we receive a REDIRECTSTREAM command. Try to change the target address of the named AP stream, and report success or failure.
Definition at line 1087 of file control_cmd.c.
|
static |
Called when we receive a RESETCONF message: parse the body and try to update our configuration. Reply with a DONE or ERROR message. Modifies the contents of body.
Definition at line 273 of file control_cmd.c.
|
static |
Called when we get a RESOLVE command: start trying to resolve the listed addresses.
Definition at line 1205 of file control_cmd.c.
|
static |
Called when we get a SAVECONF command. Try to flush the current options to disk, and report success or failure.
Definition at line 435 of file control_cmd.c.
|
static |
Called when we get a SETCIRCUITPURPOSE message. If we can find the circuit and it's a valid purpose, change it.
Definition at line 893 of file control_cmd.c.
|
static |
Called when we receive a SETCONF message: parse the body and try to update our configuration. Reply with a DONE or ERROR message. Modifies the contents of body.
Definition at line 257 of file control_cmd.c.
|
static |
Called when we get a SETEVENTS message: update conn->event_mask, and reply with DONE or ERROR.
Definition at line 385 of file control_cmd.c.
|
static |
Called when we get a SIGNAL command. React to the provided signal, and report success or failure. (If the signal results in a shutdown, success may not be reported.)
Definition at line 458 of file control_cmd.c.
|
static |
Called when we get a TAKEOWNERSHIP command. Mark this connection as an owning connection, so that we will exit if the connection closes.
Definition at line 497 of file control_cmd.c.
|
static |
Called when we get a USEFEATURE command: parse the feature list, and set up the control_connection's options properly.
Definition at line 1354 of file control_cmd.c.
|
static |
Run a single control command, as defined by a control_cmd_def_t, with a given set of arguments.
Definition at line 2213 of file control_cmd.c.
Referenced by handle_control_command().
|
static |
Helper for argument parsing: check whether the keyword arguments just parsed in result were well-formed according to syntax.
On success, return 0. On failure, return -1 and set *error_out to a newly allocated error string.
Definition at line 124 of file control_cmd.c.
|
static |
Return true iff any element of the NULL-terminated array matches kwd. Case-insensitive.
Definition at line 108 of file control_cmd.c.
Referenced by kvline_check_keyword_args().
|
static |
Definition at line 1623 of file control_cmd.c.
|
static |
Definition at line 1634 of file control_cmd.c.
|
static |
Definition at line 926 of file control_cmd.c.
|
static |
Definition at line 929 of file control_cmd.c.
|
static |
Definition at line 1164 of file control_cmd.c.
|
static |
Definition at line 1125 of file control_cmd.c.
|
static |
An array defining all the recognized controller commands.
Definition at line 2166 of file control_cmd.c.
Referenced by handle_control_command().
|
static |
Definition at line 1998 of file control_cmd.c.
|
static |
The list of onion services that have been added via ADD_ONION that do not belong to any particular control connection.
Definition at line 1612 of file control_cmd.c.
Referenced by get_detached_onion_services().
|
static |
Definition at line 1379 of file control_cmd.c.
|
static |
Definition at line 512 of file control_cmd.c.
|
static |
Definition at line 1404 of file control_cmd.c.
|
static |
Definition at line 716 of file control_cmd.c.
|
static |
Definition at line 279 of file control_cmd.c.
|
static |
Definition at line 1432 of file control_cmd.c.
|
static |
Definition at line 1435 of file control_cmd.c.
|
static |
Definition at line 1501 of file control_cmd.c.
|
static |
Definition at line 1504 of file control_cmd.c.
|
static |
Definition at line 331 of file control_cmd.c.
|
static |
Definition at line 625 of file control_cmd.c.
|
static |
The number of entries in CONTROL_COMMANDS.
Definition at line 2206 of file control_cmd.c.
Referenced by handle_control_command().
|
static |
Definition at line 2074 of file control_cmd.c.
|
static |
Definition at line 1017 of file control_cmd.c.
|
static |
Definition at line 1021 of file control_cmd.c.
|
static |
Definition at line 1244 of file control_cmd.c.
|
static |
Definition at line 1079 of file control_cmd.c.
|
static |
Definition at line 263 of file control_cmd.c.
|
static |
Definition at line 1196 of file control_cmd.c.
|
static |
Definition at line 426 of file control_cmd.c.
|
static |
Definition at line 885 of file control_cmd.c.
|
static |
Definition at line 247 of file control_cmd.c.
|
static |
Definition at line 378 of file control_cmd.c.
|
static |
Definition at line 449 of file control_cmd.c.
|
static |
Definition at line 489 of file control_cmd.c.
|
static |
Definition at line 1347 of file control_cmd.c.