10#define CONTROL_MODULE_PRIVATE
11#define CONTROL_CMD_PRIVATE
12#define CONTROL_EVENTS_PRIVATE
31#include "feature/control/control_hs.h"
33#include "feature/control/control_getinfo.h"
63#define STATE_IS_OPEN(s) ((s) == CONTROL_CONN_STATE_OPEN)
76 smartlist_free(args->
args);
78 config_free_lines(args->
kwargs);
95 memwipe(line->key, 0, strlen(line->key));
96 memwipe(line->value, 0, strlen(line->value));
109 for (
unsigned i = 0; array[i]; ++i) {
110 if (! strcasecmp(array[i], kwd))
127 if (result->
kwargs == NULL) {
128 tor_asprintf(error_out,
"Cannot parse keyword argument(s)");
139 for (line = result->
kwargs; line; line = line->next) {
142 tor_asprintf(error_out,
"Unrecognized keyword argument %s",
167 char *cmdline_alloc = NULL;
177 const char *eol = memchr(body,
'\n', body_len);
179 if (! eol || (eol+1) == body+body_len) {
180 *error_out = tor_strdup(
"Empty body");
183 cmdline_alloc = tor_memdup_nulterm(body, eol-body);
184 cmdline = cmdline_alloc;
189 if (eol && (eol+1) != body+body_len) {
190 *error_out = tor_strdup(
"Unexpected body");
198 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK,
200 size_t n_args = smartlist_len(result->
args);
201 if (n_args < syntax->min_args) {
206 tor_asprintf(error_out,
"Cannot accept more than %u argument(s)",
225 tor_assert_nonfatal(*error_out == NULL);
228 tor_assert_nonfatal(*error_out != NULL);
229 control_cmd_args_free(result);
243 return line && !strcmp(line->value,
"");
248 .accept_keywords=
true,
249 .kvline_flags=KV_OMIT_VALS|KV_QUOTED,
264 .accept_keywords=
true,
265 .kvline_flags=KV_OMIT_VALS|KV_QUOTED,
296 "Unrecognized configuration key \"%s\"", q);
315 } SMARTLIST_FOREACH_END(q);
317 if (smartlist_len(unrecognized)) {
319 }
else if (smartlist_len(answers)) {
340 char *errstring = NULL;
345 if (retval != SETOPT_OK)
347 "Controller gave us config file that didn't validate: %s",
350#define SEND_ERRMSG(code, msg) \
351 control_printf_endreply(conn, code, msg "%s%s", \
352 errstring ? ": " : "", \
353 errstring ? errstring : "")
355 case SETOPT_ERR_PARSE:
356 SEND_ERRMSG(552,
"Invalid config file");
358 case SETOPT_ERR_TRANSITION:
359 SEND_ERRMSG(553,
"Transition not allowed");
361 case SETOPT_ERR_SETTING:
362 SEND_ERRMSG(553,
"Unable to set option");
364 case SETOPT_ERR_MISC:
366 SEND_ERRMSG(550,
"Unable to load config");
388 event_mask_t event_mask = 0;
393 if (!strcasecmp(ev,
"EXTENDED") ||
394 !strcasecmp(ev,
"AUTHDIR_NEWDESCS")) {
395 log_warn(
LD_CONTROL,
"The \"%s\" SETEVENTS argument is no longer "
409 if (event_code == -1) {
414 event_mask |= (((event_mask_t)1) << event_code);
416 SMARTLIST_FOREACH_END(ev);
427 .accept_keywords =
true,
428 .kvline_flags=KV_OMIT_VALS,
441 "Unable to write configuration to disk.");
464 const char *s = smartlist_get(args->
args, 0);
466 for (i = 0; signal_table[i].signal_name != NULL; ++i) {
467 if (!strcasecmp(s, signal_table[i].signal_name)) {
468 sig = signal_table[i].sig;
480 if (sig == SIGTERM || sig == SIGINT)
483 activate_signal(sig);
503 log_info(
LD_CONTROL,
"Control connection %d has taken ownership of this "
505 (
int)(conn->base_.
s));
526 log_info(
LD_CONTROL,
"Control connection %d has dropped ownership of this "
528 (
int)(conn->base_.
s));
572 char *errstring = NULL;
573 const unsigned flags =
581#define SEND_ERRMSG(code, msg) \
582 control_printf_endreply(conn, code, msg ": %s", errstring);
585 case SETOPT_ERR_MISC:
586 SEND_ERRMSG(552,
"Unrecognized option");
588 case SETOPT_ERR_PARSE:
589 SEND_ERRMSG(513,
"Unacceptable option value");
591 case SETOPT_ERR_TRANSITION:
592 SEND_ERRMSG(553,
"Transition not allowed");
594 case SETOPT_ERR_SETTING:
596 SEND_ERRMSG(553,
"Unable to set option");
599 config_free_lines(lines);
605 "Controller gave us config lines that didn't validate: %s",
607 config_free_lines(lines);
628 .accept_keywords=
true,
643 for (line = args->
kwargs; line; line = line->next) {
644 const char *from = line->key;
645 const char *to = line->value;
649 "512-syntax error: invalid address '%s'", to);
651 "Skipping invalid argument '%s' in MapAddress msg", to);
652 }
else if (!strcmp(from,
".") || !strcmp(from,
"0.0.0.0") ||
653 !strcmp(from,
"::")) {
655 !strcmp(from,
".") ? RESOLVED_TYPE_HOSTNAME :
656 (!strcmp(from,
"0.0.0.0") ? RESOLVED_TYPE_IPV4 : RESOLVED_TYPE_IPV6);
658 type, tor_strdup(to));
661 "451-resource exhausted: skipping '%s=%s'", from,to);
663 "Unable to allocate address for '%s' in MapAddress msg",
664 safe_str_client(to));
673 "512-syntax error: invalid address mapping "
674 " '%s=%s': %s", from, to, msg);
676 "Skipping invalid argument '%s=%s' in MapAddress msg: %s",
685 if (smartlist_len(reply)) {
686 ((
char*)smartlist_get(reply,smartlist_len(reply)-1))[3] =
' ';
688 connection_buf_add(r, sz,
TO_CONN(conn));
692 "not enough arguments to mapaddress.");
696 smartlist_free(reply);
705 string += strlen(
"purpose=");
707 if (!strcasecmp(
string,
"general"))
709 else if (!strcasecmp(
string,
"controller"))
718 .accept_keywords=
true,
719 .kvline_flags=KV_OMIT_VALS
732 const char *circ_id = smartlist_get(args->
args, 0);
733 const char *path_str = NULL;
734 char *path_str_alloc = NULL;
745 if (!strcmp(arg1->value,
"")) {
746 path_str = arg1->key;
747 kwargs = kwargs->next;
748 }
else if (arg1->key[0] ==
'$') {
749 tor_asprintf(&path_str_alloc,
"%s=%s", arg1->key, arg1->value);
750 path_str = path_str_alloc;
751 kwargs = kwargs->next;
756 bool zero_circ = !strcmp(
"0", circ_id);
762 purpose_line->value);
781 if (!zero_circ && !(circ =
get_circ(circ_id))) {
794 bool first_node = zero_circ;
807 } SMARTLIST_FOREACH_END(n);
809 if (!smartlist_len(nodes)) {
823 first_node = zero_circ;
831 tor_assert_nonfatal(first_node);
833 "controller tried to connect to a node that lacks a suitable "
834 "descriptor, or which doesn't have any "
835 "addresses that are allowed by the firewall configuration; "
836 "circuit marked for closing.");
837 circuit_mark_for_close(
TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED);
845 extend_info_free(info);
853 circuit_mark_for_close(
TO_CIRCUIT(circ), -err_reason);
864 "send_next_onion_skin failed; circuit marked for closing.");
865 circuit_mark_for_close(
TO_CIRCUIT(circ), -err_reason);
878 smartlist_free(router_nicknames);
879 smartlist_free(nodes);
886 .accept_keywords=
true,
897 const char *circ_id = smartlist_get(args->
args,0);
925static const char *attachstream_keywords[] = {
930 .accept_keywords=
true,
931 .allowed_keywords=attachstream_keywords
943 int hop=0, hop_line_ok=1;
944 const char *stream_id = smartlist_get(args->
args, 0);
945 const char *circ_id = smartlist_get(args->
args, 1);
946 int zero_circ = !strcmp(circ_id,
"0");
952 }
else if (!zero_circ && !(circ =
get_circ(circ_id))) {
971 "Connection is not managed by controller.");
990 "Can't attach stream to non-open origin circuit");
996 "Can't attach stream to this one-hop circuit.");
1000 if (circ && hop>0) {
1016static const char *postdescriptor_keywords[] = {
1017 "cache",
"purpose", NULL,
1022 .accept_keywords =
true,
1023 .allowed_keywords = postdescriptor_keywords,
1024 .want_cmddata =
true,
1033 const char *msg=NULL;
1049 if (!strcasecmp(line->value,
"no"))
1051 else if (!strcasecmp(line->value,
"yes"))
1062 if (!msg) msg =
"Could not parse descriptor";
1066 if (!msg) msg =
"Descriptor not added";
1080 .max_args = UINT_MAX,
1090 char *new_addr = NULL;
1091 uint16_t new_port = 0;
1094 if (!(ap_conn =
get_stream(smartlist_get(args, 0)))
1097 (
char*)smartlist_get(args, 0));
1100 if (smartlist_len(args) > 2) {
1102 10, 1, 65535, &ok, NULL);
1106 (
char*)smartlist_get(args, 2));
1108 new_addr = tor_strdup(smartlist_get(args, 1));
1126 .max_args = UINT_MAX,
1143 if (!(ap_conn =
get_stream(smartlist_get(args, 0))))
1145 (
char*)smartlist_get(args, 0));
1151 (
char*)smartlist_get(args, 1));
1158 connection_mark_unattached_ap(ap_conn, reason);
1165 .accept_keywords=
true,
1166 .kvline_flags=KV_OMIT_VALS,
1177 const char *circ_id = smartlist_get(args->
args, 0);
1188 circuit_mark_for_close(
TO_CIRCUIT(circ), END_CIRC_REASON_REQUESTED);
1197 .accept_keywords=
true,
1198 .kvline_flags=KV_OMIT_VALS,
1210 if (!(conn->
event_mask & (((event_mask_t)1)<<EVENT_ADDRMAP))) {
1211 log_warn(
LD_CONTROL,
"Controller asked us to resolve an address, but "
1212 "isn't listening for ADDRMAP events. It probably won't see "
1218 if (modearg && !strcasecmp(modearg->value,
"reverse"))
1223 if (!strlen(line->value)) {
1224 const char *addr = line->key;
1239 smartlist_free(failed);
1264 if (!cookies && !passwd)
1267 smartlist_free(mlist);
1277 char *cfile = NULL, *abs_cfile = NULL, *esc_cfile = NULL;
1312 const char *bad_arg = NULL;
1331 connection_mark_for_close(
TO_CONN(conn));
1359 if (!strcasecmp(arg,
"VERBOSE_NAMES"))
1361 else if (!strcasecmp(arg,
"EXTENDED_EVENTS"))
1369 } SMARTLIST_FOREACH_END(arg);
1389 static int have_warned = 0;
1390 if (! have_warned) {
1391 log_warn(
LD_CONTROL,
"DROPGUARDS is dangerous; make sure you understand "
1392 "the risks before using it. It may be removed in a future "
1414 static int have_warned = 0;
1415 if (! have_warned) {
1416 log_warn(
LD_CONTROL,
"DROPTIMEOUTS is dangerous; make sure you understand "
1417 "the risks before using it. It may be removed in a future "
1426 BUILDTIMEOUT_SET_EVENT_RESET);
1431static const char *hsfetch_keywords[] = {
1436 .accept_keywords =
true,
1437 .allowed_keywords = hsfetch_keywords,
1449 const char *hsaddress = NULL;
1452 const char *arg1 = smartlist_get(args->
args, 0);
1463 if (!strcasecmp(line->key,
"SERVER")) {
1464 const char *server = line->value;
1496 smartlist_free(hsdirs);
1500static const char *hspost_keywords[] = {
1501 "SERVER",
"HSADDRESS", NULL
1505 .accept_keywords =
true,
1506 .want_cmddata =
true,
1507 .allowed_keywords = hspost_keywords
1516 const char *encoded_desc = args->
cmddata;
1517 const char *onion_address = NULL;
1520 for (line = args->
kwargs; line; line = line->next) {
1522 const char *server = line->value;
1525 if (!node || !node->rs) {
1535 const char *address = line->value;
1540 onion_address = address;
1547 if (onion_address) {
1557 smartlist_free(hs_dirs);
1577add_onion_helper_add_service(
int hs_version,
1578 add_onion_secret_key_t *pk,
1580 int max_streams_close_circuit,
1589 switch (hs_version) {
1592 max_streams_close_circuit,
1593 auth_clients_v3, address_out);
1596 tor_assert_unreached();
1616static const char *add_onion_keywords[] = {
1617 "Port",
"Flags",
"MaxStreams",
"ClientAuth",
"ClientAuthV3", NULL
1621 .accept_keywords =
true,
1622 .allowed_keywords = add_onion_keywords
1641 int max_streams = 0;
1642 int max_streams_close_circuit = 0;
1643 int non_anonymous = 0;
1646 for (arg = args->
kwargs; arg; arg = arg->next) {
1647 if (!strcasecmp(arg->key,
"Port")) {
1655 }
else if (!strcasecmp(arg->key,
"MaxStreams")) {
1658 max_streams = (int)
tor_parse_long(arg->value, 10, 0, 65535, &ok, NULL);
1663 }
else if (!strcasecmp(arg->key,
"Flags")) {
1677 static const char *discard_flag =
"DiscardPK";
1678 static const char *detach_flag =
"Detach";
1679 static const char *max_s_close_flag =
"MaxStreamsCloseCircuit";
1680 static const char *v3auth_flag =
"V3Auth";
1681 static const char *non_anonymous_flag =
"NonAnonymous";
1687 if (smartlist_len(flags) < 1) {
1693 if (!strcasecmp(flag, discard_flag)) {
1695 }
else if (!strcasecmp(flag, detach_flag)) {
1697 }
else if (!strcasecmp(flag, max_s_close_flag)) {
1698 max_streams_close_circuit = 1;
1699 }
else if (!strcasecmp(flag, v3auth_flag)) {
1700 auth_type = REND_V3_AUTH;
1701 }
else if (!strcasecmp(flag, non_anonymous_flag)) {
1709 } SMARTLIST_FOREACH_END(flag);
1711 smartlist_free(flags);
1714 }
else if (!strcasecmp(arg->key,
"ClientAuthV3")) {
1722 if (auth_clients_v3 == NULL) {
1734 if (smartlist_len(port_cfgs) == 0) {
1737 }
else if (auth_type == REND_NO_AUTH && auth_clients_v3 != NULL) {
1740 }
else if (auth_type != REND_NO_AUTH && auth_clients_v3 == NULL) {
1743 }
else if (non_anonymous != hs_service_non_anonymous_mode_enabled(
1753 "Tor is in %sanonymous hidden service " "mode",
1754 non_anonymous ?
"" :
"non-");
1760 add_onion_secret_key_t pk = { NULL };
1761 const char *key_new_alg = NULL;
1762 char *key_new_blob = NULL;
1766 &key_new_alg, &key_new_blob, &pk, &hs_version,
1774 char *service_id = NULL;
1775 int ret = add_onion_helper_add_service(hs_version, &pk, port_cfgs,
1777 max_streams_close_circuit,
1778 auth_clients_v3, &service_id);
1780 auth_clients_v3 = NULL;
1799 key_new_alg, key_new_blob);
1801 if (auth_clients_v3_str) {
1827 memwipe(key_new_blob, 0, strlen(key_new_blob));
1834 hs_port_config_free(p));
1835 smartlist_free(port_cfgs);
1837 if (auth_clients_v3) {
1839 service_authorized_client_free(ac));
1840 smartlist_free(auth_clients_v3);
1842 if (auth_clients_v3_str) {
1845 smartlist_free(auth_clients_v3_str);
1866 const char **key_new_alg_out,
char **key_new_blob_out,
1867 add_onion_secret_key_t *decoded_key,
int *hs_version,
1871 const char *key_new_alg = NULL;
1872 char *key_new_blob = NULL;
1876 if (smartlist_len(key_args) != 2) {
1882 static const char *key_type_new =
"NEW";
1883 static const char *key_type_best =
"BEST";
1884 static const char *key_type_ed25519_v3 =
"ED25519-V3";
1886 const char *key_type = smartlist_get(key_args, 0);
1887 const char *key_blob = smartlist_get(key_args, 1);
1889 if (!strcasecmp(key_type_ed25519_v3, key_type)) {
1894 strlen(key_blob)) !=
sizeof(sk->
seckey)) {
1899 decoded_key->v3 = sk;
1901 }
else if (!strcasecmp(key_type_new, key_type)) {
1903 if (!strcasecmp(key_type_ed25519_v3, key_blob) ||
1904 !strcasecmp(key_type_best, key_blob)) {
1910 key_type_ed25519_v3);
1915 key_new_blob = tor_malloc_zero(len);
1917 sizeof(sk->
seckey), 0) != (len - 1)) {
1921 key_type_ed25519_v3);
1924 key_new_alg = key_type_ed25519_v3;
1926 decoded_key->v3 = sk;
1945 smartlist_free(key_args);
1947 *key_new_alg_out = key_new_alg;
1948 *key_new_blob_out = key_new_blob;
1967 const char *service_id = smartlist_get(args, 0);
1990 onion_services = services[i];
1994 if (onion_services == NULL) {
1998 switch (hs_version) {
2011 log_warn(
LD_BUG,
"Failed to remove Onion Service %s.",
2017 char *cp = smartlist_get(onion_services, idx);
2081#define CMD_FL_WIPE (1u<<0)
2087#define ONE_LINE(name, flags) \
2090 handle_control_ ##name, \
2099#define MULTLINE(name, flags) \
2101 handle_control_ ##name, \
2110#define OBSOLETE(name) \
2112 handle_control_obsolete, \
2154 ONE_LINE(onion_client_auth_remove, 0),
2155 ONE_LINE(onion_client_auth_view, 0),
2170 uint32_t cmd_data_len,
2189 if (def->
handler(conn, parsed_args))
2195 control_cmd_args_free(parsed_args);
2199 memwipe(args, 0, cmd_data_len);
2210 uint32_t cmd_data_len,
2231control_cmd_free_all(
void)
const char * addressmap_register_virtual_address(int type, char *new_address)
int base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen, int flags)
size_t base64_encode_size(size_t srclen, int flags)
int circuit_handle_first_hop(origin_circuit_t *circ)
int circuit_send_next_onion_skin(origin_circuit_t *circ)
int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
origin_circuit_t * origin_circuit_init(uint8_t purpose, int flags)
Header file for circuitbuild.c.
void circuit_set_state(circuit_t *circ, uint8_t state)
circuit_t * circuit_get_by_edge_conn(edge_connection_t *conn)
origin_circuit_t * circuit_get_by_global_id(uint32_t id)
int circuit_get_cpath_len(origin_circuit_t *circ)
int circuit_event_status(origin_circuit_t *circ, circuit_status_event_t tp, int reason_code)
crypt_path_t * circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum)
Header file for circuitlist.c.
#define CIRCUIT_PURPOSE_UNKNOWN
#define CIRCUIT_STATE_OPEN
#define CIRCUIT_STATE_BUILDING
#define CIRCUIT_PURPOSE_CONTROLLER
#define CIRCUIT_STATE_GUARD_WAIT
#define CIRCUIT_PURPOSE_C_GENERAL
circuit_build_times_t * get_circuit_build_times_mutable(void)
const circuit_build_times_t * get_circuit_build_times(void)
void circuit_build_times_reset(circuit_build_times_t *cbt)
Header file for circuitstats.c.
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
origin_circuit_t * circuit_launch(uint8_t purpose, int flags)
void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
Header file for circuituse.c.
#define CIRCLAUNCH_NEED_CAPACITY
int options_save_current(void)
const or_options_t * get_options(void)
int option_is_recognized(const char *key)
setopt_err_t options_trial_assign(config_line_t *list, unsigned flags, char **msg)
int addressmap_register_auto(const char *from, const char *to, time_t expires, addressmap_entry_source_t addrmap_source, const char **msg)
tor_cmdline_mode_t command
setopt_err_t options_init_from_string(const char *cf_defaults, const char *cf, int command, const char *command_arg, char **msg)
const char * option_get_canonical_name(const char *key)
config_line_t * option_get_assignment(const or_options_t *options, const char *key)
Header file for config.c.
const config_line_t * config_line_find_case(const config_line_t *lines, const char *key)
config_line_t * config_lines_dup(const config_line_t *inp)
int connection_flush(connection_t *conn)
connection_t * connection_get_by_global_id(uint64_t id)
Header file for connection.c.
int connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
int connection_edge_end(edge_connection_t *conn, uint8_t reason)
entry_connection_t * TO_ENTRY_CONN(connection_t *c)
void connection_entry_set_controller_wait(entry_connection_t *conn)
Header file for connection_edge.c.
#define AP_CONN_STATE_CONTROLLER_WAIT
int address_is_invalid_destination(const char *address, int client)
#define AP_CONN_STATE_CONNECT_WAIT
#define AP_CONN_STATE_RESOLVE_WAIT
Header file for control.c.
char * get_controller_cookie_file_name(void)
Header file for control_auth.c.
static int handle_control_saveconf(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_droptimeouts(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_usefeature(control_connection_t *conn, const control_cmd_args_t *cmd_args)
static int control_setconf_helper(control_connection_t *conn, const control_cmd_args_t *args, int use_defaults)
static int kvline_check_keyword_args(const control_cmd_args_t *result, const control_cmd_syntax_t *syntax, char **error_out)
static const size_t N_CONTROL_COMMANDS
void control_cmd_args_free_(control_cmd_args_t *args)
static int handle_control_hspost(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_extendcircuit(control_connection_t *conn, const control_cmd_args_t *args)
static uint8_t circuit_purpose_from_string(const char *string)
static int handle_control_setevents(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_obsolete(control_connection_t *conn, const control_cmd_args_t *args)
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)
static int handle_control_hsfetch(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_closestream(control_connection_t *conn, const control_cmd_args_t *cmd_args)
static const control_cmd_def_t CONTROL_COMMANDS[]
static int handle_control_signal(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_single_control_command(const control_cmd_def_t *def, control_connection_t *conn, uint32_t cmd_data_len, char *args)
static smartlist_t * detached_onion_services
static int handle_control_loadconf(control_connection_t *conn, const control_cmd_args_t *args)
static bool string_array_contains_keyword(const char **array, const char *kwd)
void control_cmd_args_wipe(control_cmd_args_t *args)
int(* handler_fn_t)(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_getconf(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_attachstream(control_connection_t *conn, const control_cmd_args_t *args)
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)
static int address_is_invalid_mapaddress_target(const char *addr)
static bool config_lines_contain_flag(const config_line_t *lines, const char *flag)
static int handle_control_dropguards(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_setconf(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_postdescriptor(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_add_onion(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_closecircuit(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_takeownership(control_connection_t *conn, const control_cmd_args_t *args)
static void add_authmethods(smartlist_t *reply)
#define MULTLINE(name, flags)
static origin_circuit_t * get_circ(const char *id)
static char * get_authmethods(const or_options_t *options)
smartlist_t * get_detached_onion_services(void)
static int handle_control_redirectstream(control_connection_t *conn, const control_cmd_args_t *cmd_args)
static int handle_control_resolve(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_dropownership(control_connection_t *conn, const control_cmd_args_t *args)
int handle_control_command(control_connection_t *conn, uint32_t cmd_data_len, char *args)
static int handle_control_setcircuitpurpose(control_connection_t *conn, const control_cmd_args_t *args)
#define ONE_LINE(name, flags)
static int handle_control_mapaddress(control_connection_t *conn, const control_cmd_args_t *args)
static int handle_control_protocolinfo(control_connection_t *conn, const control_cmd_args_t *cmd_args)
static char * get_esc_cfile(const or_options_t *options)
static int handle_control_resetconf(control_connection_t *conn, const control_cmd_args_t *args)
static entry_connection_t * get_stream(const char *id)
static int handle_control_del_onion(control_connection_t *conn, const control_cmd_args_t *cmd_args)
Header file for control_cmd.c.
Definition for control_cmd_args_t.
Controller connection structure.
const struct control_event_t control_event_table[]
int control_event_address_mapped(const char *from, const char *to, time_t expires, const char *error, const int cached, uint64_t stream_id)
void control_update_global_event_mask(void)
Header file for control_events.c.
void control_write_endreply(control_connection_t *conn, int code, const char *s)
void control_printf_midreply(control_connection_t *conn, int code, const char *fmt,...)
void send_control_done(control_connection_t *conn)
void control_printf_endreply(control_connection_t *conn, int code, const char *fmt,...)
size_t read_escaped_data(const char *data, size_t len, char **out)
Header file for control_proto.c.
Circuit-build-stse structure.
int ed25519_secret_key_generate(ed25519_secret_key_t *seckey_out, int extra_strong)
Common functions for using (pseudo-)random number generators.
void memwipe(void *mem, uint8_t byte, size_t sz)
Common functions for cryptographic routines.
int dnsserv_launch_request(const char *name, int reverse, control_connection_t *control_conn)
Header file for dnsserv.c.
Entry connection structure.
#define ENTRY_TO_EDGE_CONN(c)
void remove_all_entry_guards(void)
Header file for circuitbuild.c.
char * esc_for_log(const char *s)
const char * escaped(const char *s)
extend_info_t * extend_info_from_node(const node_t *node, int for_direct_connect, bool for_exit)
Header for core/or/extendinfo.c.
void control_reply_append_kv(smartlist_t *reply, const char *key, const char *val)
void control_write_reply_lines(control_connection_t *conn, smartlist_t *lines)
void control_reply_add_printf(smartlist_t *reply, int code, const char *fmt,...)
#define control_reply_free(r)
Free and null a smartlist of control_reply_line_t.
void control_reply_add_one_kv(smartlist_t *reply, int code, int flags, const char *key, const char *val)
void control_reply_add_str(smartlist_t *reply, int code, const char *s)
void control_reply_add_done(smartlist_t *reply)
hs_port_config_t * hs_parse_port_config(const char *string, const char *sep, char **err_msg_out)
int hs_parse_address(const char *address, ed25519_public_key_t *key_out, uint8_t *checksum_out, uint8_t *version_out)
int hs_address_is_valid(const char *address)
hs_service_add_ephemeral_status_t
int hs_control_hspost_command(const char *body, const char *onion_address, const smartlist_t *hsdirs_rs)
void hs_control_hsfetch_command(const ed25519_public_key_t *onion_identity_pk, const smartlist_t *hsdirs)
Header file containing control port event related code.
hs_service_add_ephemeral_status_t hs_service_add_ephemeral(ed25519_secret_key_t *sk, smartlist_t *ports, int max_streams_per_rdv_circuit, int max_streams_close_circuit, smartlist_t *auth_clients_v3, char **address_out)
int hs_service_del_ephemeral(const char *address)
hs_service_authorized_client_t * parse_authorized_client_key(const char *key_str, int severity)
Header file containing service data for the HS subsystem.
config_line_t * kvline_parse(const char *line, unsigned flags)
Node information structure.
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
int node_has_preferred_descriptor(const node_t *node, int for_direct_connect)
const node_t * node_get_by_hex_id(const char *hex_id, unsigned flags)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
Origin circuit structure.
uint64_t tor_parse_uint64(const char *s, int base, uint64_t min, uint64_t max, int *ok, char **next)
long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next)
unsigned long tor_parse_ulong(const char *s, int base, unsigned long min, unsigned long max, int *ok, char **next)
char * make_path_absolute(const char *fname)
int tor_asprintf(char **strp, const char *fmt,...)
Header file for rendcommon.c.
static crypto_pk_t * onionkey
uint8_t router_purpose_from_string(const char *s)
Header file for routerinfo.c.
Router descriptor structure.
#define ROUTER_PURPOSE_UNKNOWN
#define ROUTER_PURPOSE_GENERAL
int router_load_single_router(const char *s, uint8_t purpose, int cache, const char **msg)
Header file for routerlist.c.
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
int smartlist_string_pos(const smartlist_t *sl, const char *element)
void * smartlist_pop_last(smartlist_t *sl)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
void smartlist_del(smartlist_t *sl, int idx)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
Client request structure.
void or_state_mark_dirty(or_state_t *state, time_t when)
or_state_t * get_or_state(void)
uint16_t marked_for_close
struct smartlist_t * args
struct config_line_t * kwargs
const control_cmd_syntax_t * syntax
const char ** allowed_keywords
smartlist_t * ephemeral_onion_services
unsigned int is_owning_control_connection
unsigned int have_sent_protocolinfo
unsigned int onehop_tunnel
uint8_t seckey[ED25519_SECKEY_LEN]
unsigned int edge_has_sent_end
socks_request_t * socks_request
struct config_line_t * HashedControlPassword
struct config_line_t * HashedControlSessionPassword
uint32_t global_identifier
edge_connection_t * p_streams
unsigned int any_hop_from_controller
cpath_build_state_t * build_state
unsigned first_hop_from_controller
char address[MAX_SOCKS_ADDR_LEN]
#define tor_assert_nonfatal_unreached()
#define tor_fragile_assert()
int strcasecmpstart(const char *s1, const char *s2)
int strcmpstart(const char *s1, const char *s2)
void tor_strupper(char *s)