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)) {
821 first_node = zero_circ;
826 tor_assert_nonfatal(first_node);
828 "controller tried to connect to a node that lacks a suitable "
829 "descriptor, or which doesn't have any "
830 "addresses that are allowed by the firewall configuration; "
831 "circuit marked for closing.");
832 circuit_mark_for_close(
TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED);
840 extend_info_free(info);
848 circuit_mark_for_close(
TO_CIRCUIT(circ), -err_reason);
859 "send_next_onion_skin failed; circuit marked for closing.");
860 circuit_mark_for_close(
TO_CIRCUIT(circ), -err_reason);
873 smartlist_free(router_nicknames);
874 smartlist_free(nodes);
881 .accept_keywords=
true,
892 const char *circ_id = smartlist_get(args->
args,0);
920 static const char *attachstream_keywords[] = {
925 .accept_keywords=
true,
926 .allowed_keywords=attachstream_keywords
938 int hop=0, hop_line_ok=1;
939 const char *stream_id = smartlist_get(args->
args, 0);
940 const char *circ_id = smartlist_get(args->
args, 1);
941 int zero_circ = !strcmp(circ_id,
"0");
947 }
else if (!zero_circ && !(circ =
get_circ(circ_id))) {
966 "Connection is not managed by controller.");
985 "Can't attach stream to non-open origin circuit");
991 "Can't attach stream to this one-hop circuit.");
1011 static const char *postdescriptor_keywords[] = {
1012 "cache",
"purpose", NULL,
1017 .accept_keywords =
true,
1018 .allowed_keywords = postdescriptor_keywords,
1019 .want_cmddata =
true,
1028 const char *msg=NULL;
1044 if (!strcasecmp(line->value,
"no"))
1046 else if (!strcasecmp(line->value,
"yes"))
1057 if (!msg) msg =
"Could not parse descriptor";
1061 if (!msg) msg =
"Descriptor not added";
1075 .max_args = UINT_MAX,
1085 char *new_addr = NULL;
1086 uint16_t new_port = 0;
1089 if (!(ap_conn =
get_stream(smartlist_get(args, 0)))
1092 (
char*)smartlist_get(args, 0));
1095 if (smartlist_len(args) > 2) {
1097 10, 1, 65535, &ok, NULL);
1101 (
char*)smartlist_get(args, 2));
1103 new_addr = tor_strdup(smartlist_get(args, 1));
1121 .max_args = UINT_MAX,
1138 if (!(ap_conn =
get_stream(smartlist_get(args, 0))))
1140 (
char*)smartlist_get(args, 0));
1146 (
char*)smartlist_get(args, 1));
1153 connection_mark_unattached_ap(ap_conn, reason);
1160 .accept_keywords=
true,
1161 .kvline_flags=KV_OMIT_VALS,
1172 const char *circ_id = smartlist_get(args->
args, 0);
1183 circuit_mark_for_close(
TO_CIRCUIT(circ), END_CIRC_REASON_REQUESTED);
1192 .accept_keywords=
true,
1193 .kvline_flags=KV_OMIT_VALS,
1205 if (!(conn->
event_mask & (((event_mask_t)1)<<EVENT_ADDRMAP))) {
1206 log_warn(
LD_CONTROL,
"Controller asked us to resolve an address, but "
1207 "isn't listening for ADDRMAP events. It probably won't see "
1213 if (modearg && !strcasecmp(modearg->value,
"reverse"))
1218 if (!strlen(line->value)) {
1219 const char *addr = line->key;
1234 smartlist_free(failed);
1259 if (!cookies && !passwd)
1262 smartlist_free(mlist);
1272 char *cfile = NULL, *abs_cfile = NULL, *esc_cfile = NULL;
1307 const char *bad_arg = NULL;
1326 connection_mark_for_close(
TO_CONN(conn));
1354 if (!strcasecmp(arg,
"VERBOSE_NAMES"))
1356 else if (!strcasecmp(arg,
"EXTENDED_EVENTS"))
1364 } SMARTLIST_FOREACH_END(arg);
1384 static int have_warned = 0;
1385 if (! have_warned) {
1386 log_warn(
LD_CONTROL,
"DROPGUARDS is dangerous; make sure you understand "
1387 "the risks before using it. It may be removed in a future "
1409 static int have_warned = 0;
1410 if (! have_warned) {
1411 log_warn(
LD_CONTROL,
"DROPTIMEOUTS is dangerous; make sure you understand "
1412 "the risks before using it. It may be removed in a future "
1421 BUILDTIMEOUT_SET_EVENT_RESET);
1426 static const char *hsfetch_keywords[] = {
1431 .accept_keywords =
true,
1432 .allowed_keywords = hsfetch_keywords,
1444 const char *hsaddress = NULL;
1447 const char *arg1 = smartlist_get(args->
args, 0);
1458 if (!strcasecmp(line->key,
"SERVER")) {
1459 const char *server = line->value;
1491 smartlist_free(hsdirs);
1495 static const char *hspost_keywords[] = {
1496 "SERVER",
"HSADDRESS", NULL
1500 .accept_keywords =
true,
1501 .want_cmddata =
true,
1502 .allowed_keywords = hspost_keywords
1511 const char *encoded_desc = args->
cmddata;
1512 const char *onion_address = NULL;
1515 for (line = args->
kwargs; line; line = line->next) {
1517 const char *server = line->value;
1520 if (!node || !node->rs) {
1530 const char *address = line->value;
1535 onion_address = address;
1542 if (onion_address) {
1552 smartlist_free(hs_dirs);
1572 add_onion_helper_add_service(
int hs_version,
1573 add_onion_secret_key_t *pk,
1575 int max_streams_close_circuit,
1584 switch (hs_version) {
1587 max_streams_close_circuit,
1588 auth_clients_v3, address_out);
1591 tor_assert_unreached();
1611 static const char *add_onion_keywords[] = {
1612 "Port",
"Flags",
"MaxStreams",
"ClientAuth",
"ClientAuthV3", NULL
1616 .accept_keywords =
true,
1617 .allowed_keywords = add_onion_keywords
1636 int max_streams = 0;
1637 int max_streams_close_circuit = 0;
1638 int non_anonymous = 0;
1641 for (arg = args->
kwargs; arg; arg = arg->next) {
1642 if (!strcasecmp(arg->key,
"Port")) {
1650 }
else if (!strcasecmp(arg->key,
"MaxStreams")) {
1653 max_streams = (int)
tor_parse_long(arg->value, 10, 0, 65535, &ok, NULL);
1658 }
else if (!strcasecmp(arg->key,
"Flags")) {
1672 static const char *discard_flag =
"DiscardPK";
1673 static const char *detach_flag =
"Detach";
1674 static const char *max_s_close_flag =
"MaxStreamsCloseCircuit";
1675 static const char *v3auth_flag =
"V3Auth";
1676 static const char *non_anonymous_flag =
"NonAnonymous";
1682 if (smartlist_len(flags) < 1) {
1688 if (!strcasecmp(flag, discard_flag)) {
1690 }
else if (!strcasecmp(flag, detach_flag)) {
1692 }
else if (!strcasecmp(flag, max_s_close_flag)) {
1693 max_streams_close_circuit = 1;
1694 }
else if (!strcasecmp(flag, v3auth_flag)) {
1695 auth_type = REND_V3_AUTH;
1696 }
else if (!strcasecmp(flag, non_anonymous_flag)) {
1704 } SMARTLIST_FOREACH_END(flag);
1706 smartlist_free(flags);
1709 }
else if (!strcasecmp(arg->key,
"ClientAuthV3")) {
1717 if (auth_clients_v3 == NULL) {
1729 if (smartlist_len(port_cfgs) == 0) {
1732 }
else if (auth_type == REND_NO_AUTH && auth_clients_v3 != NULL) {
1735 }
else if (auth_type != REND_NO_AUTH && auth_clients_v3 == NULL) {
1738 }
else if (non_anonymous != hs_service_non_anonymous_mode_enabled(
1748 "Tor is in %sanonymous hidden service " "mode",
1749 non_anonymous ?
"" :
"non-");
1755 add_onion_secret_key_t pk = { NULL };
1756 const char *key_new_alg = NULL;
1757 char *key_new_blob = NULL;
1761 &key_new_alg, &key_new_blob, &pk, &hs_version,
1769 char *service_id = NULL;
1770 int ret = add_onion_helper_add_service(hs_version, &pk, port_cfgs,
1772 max_streams_close_circuit,
1773 auth_clients_v3, &service_id);
1775 auth_clients_v3 = NULL;
1794 key_new_alg, key_new_blob);
1796 if (auth_clients_v3_str) {
1822 memwipe(key_new_blob, 0, strlen(key_new_blob));
1829 hs_port_config_free(p));
1830 smartlist_free(port_cfgs);
1832 if (auth_clients_v3) {
1834 service_authorized_client_free(ac));
1835 smartlist_free(auth_clients_v3);
1837 if (auth_clients_v3_str) {
1840 smartlist_free(auth_clients_v3_str);
1861 const char **key_new_alg_out,
char **key_new_blob_out,
1862 add_onion_secret_key_t *decoded_key,
int *hs_version,
1866 const char *key_new_alg = NULL;
1867 char *key_new_blob = NULL;
1871 if (smartlist_len(key_args) != 2) {
1877 static const char *key_type_new =
"NEW";
1878 static const char *key_type_best =
"BEST";
1879 static const char *key_type_ed25519_v3 =
"ED25519-V3";
1881 const char *key_type = smartlist_get(key_args, 0);
1882 const char *key_blob = smartlist_get(key_args, 1);
1884 if (!strcasecmp(key_type_ed25519_v3, key_type)) {
1889 strlen(key_blob)) !=
sizeof(sk->
seckey)) {
1894 decoded_key->v3 = sk;
1896 }
else if (!strcasecmp(key_type_new, key_type)) {
1898 if (!strcasecmp(key_type_ed25519_v3, key_blob) ||
1899 !strcasecmp(key_type_best, key_blob)) {
1905 key_type_ed25519_v3);
1910 key_new_blob = tor_malloc_zero(len);
1912 sizeof(sk->
seckey), 0) != (len - 1)) {
1916 key_type_ed25519_v3);
1919 key_new_alg = key_type_ed25519_v3;
1921 decoded_key->v3 = sk;
1940 smartlist_free(key_args);
1942 *key_new_alg_out = key_new_alg;
1943 *key_new_blob_out = key_new_blob;
1962 const char *service_id = smartlist_get(args, 0);
1985 onion_services = services[i];
1989 if (onion_services == NULL) {
1993 switch (hs_version) {
2006 log_warn(
LD_BUG,
"Failed to remove Onion Service %s.",
2012 char *cp = smartlist_get(onion_services, idx);
2076 #define CMD_FL_WIPE (1u<<0)
2082 #define ONE_LINE(name, flags) \
2085 handle_control_ ##name, \
2094 #define MULTLINE(name, flags) \
2096 handle_control_ ##name, \
2105 #define OBSOLETE(name) \
2107 handle_control_obsolete, \
2149 ONE_LINE(onion_client_auth_remove, 0),
2150 ONE_LINE(onion_client_auth_view, 0),
2165 uint32_t cmd_data_len,
2184 if (def->
handler(conn, parsed_args))
2190 control_cmd_args_free(parsed_args);
2194 memwipe(args, 0, cmd_data_len);
2205 uint32_t cmd_data_len,
2226 control_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)
origin_circuit_t * origin_circuit_init(uint8_t purpose, int flags)
int circuit_send_next_onion_skin(origin_circuit_t *circ)
int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
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)
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)
origin_circuit_t * circuit_get_by_global_id(uint32_t id)
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
const circuit_build_times_t * get_circuit_build_times(void)
circuit_build_times_t * get_circuit_build_times_mutable(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)
const char * option_get_canonical_name(const char *key)
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)
config_line_t * option_get_assignment(const or_options_t *options, const char *key)
Header file for config.c.
config_line_t * config_lines_dup(const config_line_t *inp)
const config_line_t * config_line_find_case(const config_line_t *lines, const char *key)
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 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)
static entry_connection_t * get_stream(const char *id)
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 origin_circuit_t * get_circ(const char *id)
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 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_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 char * get_authmethods(const or_options_t *options)
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)
smartlist_t * get_detached_onion_services(void)
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 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.
const char * escaped(const char *s)
char * esc_for_log(const char *s)
extend_info_t * extend_info_from_node(const node_t *node, int for_direct_connect)
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)
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_port_config_t * hs_parse_port_config(const char *string, const char *sep, char **err_msg_out)
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)
hs_service_authorized_client_t * parse_authorized_client_key(const char *key_str, int severity)
int hs_service_del_ephemeral(const char *address)
Header file containing service data for the HS subsystem.
config_line_t * kvline_parse(const char *line, unsigned flags)
Node information structure.
int node_has_preferred_descriptor(const node_t *node, int for_direct_connect)
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
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.
or_state_t * get_or_state(void)
void or_state_mark_dirty(or_state_t *state, time_t when)
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
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)