Go to the documentation of this file.
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"
68 #define STATE_IS_OPEN(s) ((s) == CONTROL_CONN_STATE_OPEN)
81 smartlist_free(args->
args);
83 config_free_lines(args->
kwargs);
100 memwipe(line->key, 0, strlen(line->key));
101 memwipe(line->value, 0, strlen(line->value));
114 for (
unsigned i = 0; array[i]; ++i) {
115 if (! strcasecmp(array[i], kwd))
132 if (result->
kwargs == NULL) {
133 tor_asprintf(error_out,
"Cannot parse keyword argument(s)");
144 for (line = result->
kwargs; line; line = line->next) {
147 tor_asprintf(error_out,
"Unrecognized keyword argument %s",
172 char *cmdline_alloc = NULL;
182 const char *eol = memchr(body,
'\n', body_len);
184 if (! eol || (eol+1) == body+body_len) {
185 *error_out = tor_strdup(
"Empty body");
188 cmdline_alloc = tor_memdup_nulterm(body, eol-body);
189 cmdline = cmdline_alloc;
194 if (eol && (eol+1) != body+body_len) {
195 *error_out = tor_strdup(
"Unexpected body");
203 SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK,
205 size_t n_args = smartlist_len(result->
args);
206 if (n_args < syntax->min_args) {
211 tor_asprintf(error_out,
"Cannot accept more than %u argument(s)",
230 tor_assert_nonfatal(*error_out == NULL);
233 tor_assert_nonfatal(*error_out != NULL);
234 control_cmd_args_free(result);
248 return line && !strcmp(line->value,
"");
253 .accept_keywords=
true,
254 .kvline_flags=KV_OMIT_VALS|KV_QUOTED,
269 .accept_keywords=
true,
270 .kvline_flags=KV_OMIT_VALS|KV_QUOTED,
301 "Unrecognized configuration key \"%s\"", q);
320 } SMARTLIST_FOREACH_END(q);
322 if (smartlist_len(unrecognized)) {
324 }
else if (smartlist_len(answers)) {
345 char *errstring = NULL;
350 if (retval != SETOPT_OK)
352 "Controller gave us config file that didn't validate: %s",
355 #define SEND_ERRMSG(code, msg) \
356 control_printf_endreply(conn, code, msg "%s%s", \
357 errstring ? ": " : "", \
358 errstring ? errstring : "")
360 case SETOPT_ERR_PARSE:
361 SEND_ERRMSG(552,
"Invalid config file");
363 case SETOPT_ERR_TRANSITION:
364 SEND_ERRMSG(553,
"Transition not allowed");
366 case SETOPT_ERR_SETTING:
367 SEND_ERRMSG(553,
"Unable to set option");
369 case SETOPT_ERR_MISC:
371 SEND_ERRMSG(550,
"Unable to load config");
393 event_mask_t event_mask = 0;
398 if (!strcasecmp(ev,
"EXTENDED") ||
399 !strcasecmp(ev,
"AUTHDIR_NEWDESCS")) {
400 log_warn(
LD_CONTROL,
"The \"%s\" SETEVENTS argument is no longer "
414 if (event_code == -1) {
419 event_mask |= (((event_mask_t)1) << event_code);
421 SMARTLIST_FOREACH_END(ev);
432 .accept_keywords =
true,
433 .kvline_flags=KV_OMIT_VALS,
446 "Unable to write configuration to disk.");
469 const char *s = smartlist_get(args->
args, 0);
471 for (i = 0; signal_table[i].signal_name != NULL; ++i) {
472 if (!strcasecmp(s, signal_table[i].signal_name)) {
473 sig = signal_table[i].sig;
485 if (sig == SIGTERM || sig == SIGINT)
488 activate_signal(sig);
508 log_info(
LD_CONTROL,
"Control connection %d has taken ownership of this "
510 (
int)(conn->base_.
s));
531 log_info(
LD_CONTROL,
"Control connection %d has dropped ownership of this "
533 (
int)(conn->base_.
s));
577 char *errstring = NULL;
578 const unsigned flags =
586 #define SEND_ERRMSG(code, msg) \
587 control_printf_endreply(conn, code, msg ": %s", errstring);
590 case SETOPT_ERR_MISC:
591 SEND_ERRMSG(552,
"Unrecognized option");
593 case SETOPT_ERR_PARSE:
594 SEND_ERRMSG(513,
"Unacceptable option value");
596 case SETOPT_ERR_TRANSITION:
597 SEND_ERRMSG(553,
"Transition not allowed");
599 case SETOPT_ERR_SETTING:
601 SEND_ERRMSG(553,
"Unable to set option");
604 config_free_lines(lines);
610 "Controller gave us config lines that didn't validate: %s",
612 config_free_lines(lines);
633 .accept_keywords=
true,
648 for (line = args->
kwargs; line; line = line->next) {
649 const char *from = line->key;
650 const char *to = line->value;
654 "512-syntax error: invalid address '%s'", to);
656 "Skipping invalid argument '%s' in MapAddress msg", to);
657 }
else if (!strcmp(from,
".") || !strcmp(from,
"0.0.0.0") ||
658 !strcmp(from,
"::")) {
660 !strcmp(from,
".") ? RESOLVED_TYPE_HOSTNAME :
661 (!strcmp(from,
"0.0.0.0") ? RESOLVED_TYPE_IPV4 : RESOLVED_TYPE_IPV6);
663 type, tor_strdup(to));
666 "451-resource exhausted: skipping '%s=%s'", from,to);
668 "Unable to allocate address for '%s' in MapAddress msg",
669 safe_str_client(to));
678 "512-syntax error: invalid address mapping "
679 " '%s=%s': %s", from, to, msg);
681 "Skipping invalid argument '%s=%s' in MapAddress msg: %s",
690 if (smartlist_len(reply)) {
691 ((
char*)smartlist_get(reply,smartlist_len(reply)-1))[3] =
' ';
693 connection_buf_add(r, sz,
TO_CONN(conn));
697 "not enough arguments to mapaddress.");
701 smartlist_free(reply);
710 string += strlen(
"purpose=");
712 if (!strcasecmp(
string,
"general"))
714 else if (!strcasecmp(
string,
"controller"))
723 .accept_keywords=
true,
724 .kvline_flags=KV_OMIT_VALS
737 const char *circ_id = smartlist_get(args->
args, 0);
738 const char *path_str = NULL;
739 char *path_str_alloc = NULL;
750 if (!strcmp(arg1->value,
"")) {
751 path_str = arg1->key;
752 kwargs = kwargs->next;
753 }
else if (arg1->key[0] ==
'$') {
754 tor_asprintf(&path_str_alloc,
"%s=%s", arg1->key, arg1->value);
755 path_str = path_str_alloc;
756 kwargs = kwargs->next;
761 bool zero_circ = !strcmp(
"0", circ_id);
767 purpose_line->value);
786 if (!zero_circ && !(circ =
get_circ(circ_id))) {
799 bool first_node = zero_circ;
812 } SMARTLIST_FOREACH_END(n);
814 if (!smartlist_len(nodes)) {
825 first_node = zero_circ;
830 tor_assert_nonfatal(first_node);
832 "controller tried to connect to a node that lacks a suitable "
833 "descriptor, or which doesn't have any "
834 "addresses that are allowed by the firewall configuration; "
835 "circuit marked for closing.");
836 circuit_mark_for_close(
TO_CIRCUIT(circ), -END_CIRC_REASON_CONNECTFAILED);
844 extend_info_free(info);
852 circuit_mark_for_close(
TO_CIRCUIT(circ), -err_reason);
863 "send_next_onion_skin failed; circuit marked for closing.");
864 circuit_mark_for_close(
TO_CIRCUIT(circ), -err_reason);
877 smartlist_free(router_nicknames);
878 smartlist_free(nodes);
885 .accept_keywords=
true,
896 const char *circ_id = smartlist_get(args->
args,0);
924 static const char *attachstream_keywords[] = {
929 .accept_keywords=
true,
930 .allowed_keywords=attachstream_keywords
942 int hop=0, hop_line_ok=1;
943 const char *stream_id = smartlist_get(args->
args, 0);
944 const char *circ_id = smartlist_get(args->
args, 1);
945 int zero_circ = !strcmp(circ_id,
"0");
951 }
else if (!zero_circ && !(circ =
get_circ(circ_id))) {
970 "Connection is not managed by controller.");
989 "Can't attach stream to non-open origin circuit");
995 "Can't attach stream to this one-hop circuit.");
1015 static const char *postdescriptor_keywords[] = {
1016 "cache",
"purpose", NULL,
1021 .accept_keywords =
true,
1022 .allowed_keywords = postdescriptor_keywords,
1023 .want_cmddata =
true,
1032 const char *msg=NULL;
1048 if (!strcasecmp(line->value,
"no"))
1050 else if (!strcasecmp(line->value,
"yes"))
1061 if (!msg) msg =
"Could not parse descriptor";
1065 if (!msg) msg =
"Descriptor not added";
1079 .max_args = UINT_MAX,
1089 char *new_addr = NULL;
1090 uint16_t new_port = 0;
1093 if (!(ap_conn =
get_stream(smartlist_get(args, 0)))
1096 (
char*)smartlist_get(args, 0));
1099 if (smartlist_len(args) > 2) {
1101 10, 1, 65535, &ok, NULL);
1105 (
char*)smartlist_get(args, 2));
1107 new_addr = tor_strdup(smartlist_get(args, 1));
1125 .max_args = UINT_MAX,
1142 if (!(ap_conn =
get_stream(smartlist_get(args, 0))))
1144 (
char*)smartlist_get(args, 0));
1150 (
char*)smartlist_get(args, 1));
1157 connection_mark_unattached_ap(ap_conn, reason);
1164 .accept_keywords=
true,
1165 .kvline_flags=KV_OMIT_VALS,
1176 const char *circ_id = smartlist_get(args->
args, 0);
1187 circuit_mark_for_close(
TO_CIRCUIT(circ), END_CIRC_REASON_REQUESTED);
1196 .accept_keywords=
true,
1197 .kvline_flags=KV_OMIT_VALS,
1209 if (!(conn->
event_mask & (((event_mask_t)1)<<EVENT_ADDRMAP))) {
1210 log_warn(
LD_CONTROL,
"Controller asked us to resolve an address, but "
1211 "isn't listening for ADDRMAP events. It probably won't see "
1217 if (modearg && !strcasecmp(modearg->value,
"reverse"))
1222 if (!strlen(line->value)) {
1223 const char *addr = line->key;
1238 smartlist_free(failed);
1263 if (!cookies && !passwd)
1266 smartlist_free(mlist);
1276 char *cfile = NULL, *abs_cfile = NULL, *esc_cfile = NULL;
1311 const char *bad_arg = NULL;
1330 connection_mark_for_close(
TO_CONN(conn));
1358 if (!strcasecmp(arg,
"VERBOSE_NAMES"))
1360 else if (!strcasecmp(arg,
"EXTENDED_EVENTS"))
1368 } SMARTLIST_FOREACH_END(arg);
1388 static int have_warned = 0;
1389 if (! have_warned) {
1390 log_warn(
LD_CONTROL,
"DROPGUARDS is dangerous; make sure you understand "
1391 "the risks before using it. It may be removed in a future "
1413 static int have_warned = 0;
1414 if (! have_warned) {
1415 log_warn(
LD_CONTROL,
"DROPTIMEOUTS is dangerous; make sure you understand "
1416 "the risks before using it. It may be removed in a future "
1425 BUILDTIMEOUT_SET_EVENT_RESET);
1430 static const char *hsfetch_keywords[] = {
1435 .accept_keywords =
true,
1436 .allowed_keywords = hsfetch_keywords,
1447 static const char *v2_str =
"v2-";
1448 const size_t v2_str_len = strlen(v2_str);
1452 const char *hsaddress = NULL;
1455 const char *arg1 = smartlist_get(args->
args, 0);
1479 if (!strcasecmp(line->key,
"SERVER")) {
1480 const char *server = line->value;
1501 if (rend_query == NULL) {
1509 if (desc_id && (!hsdirs || !smartlist_len(hsdirs))) {
1530 smartlist_free(hsdirs);
1531 rend_data_free(rend_query);
1535 static const char *hspost_keywords[] = {
1536 "SERVER",
"HSADDRESS", NULL
1540 .accept_keywords =
true,
1541 .want_cmddata =
true,
1542 .allowed_keywords = hspost_keywords
1551 const char *encoded_desc = args->
cmddata;
1553 const char *onion_address = NULL;
1556 for (line = args->
kwargs; line; line = line->next) {
1558 const char *server = line->value;
1561 if (!node || !node->rs) {
1571 const char *address = line->value;
1576 onion_address = address;
1583 if (onion_address) {
1597 desc->
desc_str = tor_memdup_nulterm(encoded_desc, encoded_desc_len);
1600 char *intro_content = NULL;
1602 size_t encoded_size;
1603 const char *next_desc;
1605 &intro_size, &encoded_size,
1620 smartlist_free(descs);
1623 rend_service_descriptor_free(parsed);
1629 rend_encoded_v2_service_descriptor_free(desc);
1631 smartlist_free(hs_dirs);
1652 add_onion_helper_add_service(
int hs_version,
1653 add_onion_secret_key_t *pk,
1655 int max_streams_close_circuit,
int auth_type,
1664 switch (hs_version) {
1667 max_streams_close_circuit, auth_type,
1668 auth_clients, address_out);
1672 max_streams_close_circuit, address_out);
1675 tor_assert_unreached();
1695 static const char *add_onion_keywords[] = {
1696 "Port",
"Flags",
"MaxStreams",
"ClientAuth", NULL
1700 .accept_keywords =
true,
1701 .allowed_keywords = add_onion_keywords
1719 int max_streams = 0;
1720 int max_streams_close_circuit = 0;
1722 int non_anonymous = 0;
1725 for (arg = args->
kwargs; arg; arg = arg->next) {
1726 if (!strcasecmp(arg->key,
"Port")) {
1735 }
else if (!strcasecmp(arg->key,
"MaxStreams")) {
1738 max_streams = (int)
tor_parse_long(arg->value, 10, 0, 65535, &ok, NULL);
1743 }
else if (!strcasecmp(arg->key,
"Flags")) {
1757 static const char *discard_flag =
"DiscardPK";
1758 static const char *detach_flag =
"Detach";
1759 static const char *max_s_close_flag =
"MaxStreamsCloseCircuit";
1760 static const char *basicauth_flag =
"BasicAuth";
1761 static const char *non_anonymous_flag =
"NonAnonymous";
1767 if (smartlist_len(flags) < 1) {
1773 if (!strcasecmp(flag, discard_flag)) {
1775 }
else if (!strcasecmp(flag, detach_flag)) {
1777 }
else if (!strcasecmp(flag, max_s_close_flag)) {
1778 max_streams_close_circuit = 1;
1779 }
else if (!strcasecmp(flag, basicauth_flag)) {
1780 auth_type = REND_BASIC_AUTH;
1781 }
else if (!strcasecmp(flag, non_anonymous_flag)) {
1789 } SMARTLIST_FOREACH_END(flag);
1791 smartlist_free(flags);
1795 }
else if (!strcasecmp(arg->key,
"ClientAuth")) {
1803 if (auth_clients != NULL) {
1806 if (strcmp(ac->client_name, client->client_name) == 0) {
1810 } SMARTLIST_FOREACH_END(ac);
1813 rend_authorized_client_free(client);
1829 if (smartlist_len(port_cfgs) == 0) {
1832 }
else if (auth_type == REND_NO_AUTH && auth_clients != NULL) {
1835 }
else if (auth_type != REND_NO_AUTH && auth_clients == NULL) {
1838 }
else if ((auth_type == REND_BASIC_AUTH &&
1839 smartlist_len(auth_clients) > 512) ||
1840 (auth_type == REND_STEALTH_AUTH &&
1841 smartlist_len(auth_clients) > 16)) {
1844 }
else if (non_anonymous != rend_service_non_anonymous_mode_enabled(
1854 "Tor is in %sanonymous hidden service " "mode",
1855 non_anonymous ?
"" :
"non-");
1861 add_onion_secret_key_t pk = { NULL };
1862 const char *key_new_alg = NULL;
1863 char *key_new_blob = NULL;
1867 &key_new_alg, &key_new_blob, &pk, &hs_version,
1884 char *service_id = NULL;
1885 int ret = add_onion_helper_add_service(hs_version, &pk, port_cfgs,
1887 max_streams_close_circuit, auth_type,
1888 auth_clients, &service_id);
1890 auth_clients = NULL;
1909 key_new_alg, key_new_blob);
1911 if (auth_created_clients) {
1917 ac->client_name, encoded);
1918 memwipe(encoded, 0, strlen(encoded));
1943 memwipe(key_new_blob, 0, strlen(key_new_blob));
1950 rend_service_port_config_free(p));
1951 smartlist_free(port_cfgs);
1956 rend_authorized_client_free(ac));
1957 smartlist_free(auth_clients);
1959 if (auth_created_clients) {
1961 smartlist_free(auth_created_clients);
1981 const char **key_new_alg_out,
char **key_new_blob_out,
1982 add_onion_secret_key_t *decoded_key,
int *hs_version,
1987 const char *key_new_alg = NULL;
1988 char *key_new_blob = NULL;
1992 if (smartlist_len(key_args) != 2) {
1998 static const char *key_type_new =
"NEW";
1999 static const char *key_type_best =
"BEST";
2000 static const char *key_type_rsa1024 =
"RSA1024";
2001 static const char *key_type_ed25519_v3 =
"ED25519-V3";
2003 const char *key_type = smartlist_get(key_args, 0);
2004 const char *key_blob = smartlist_get(key_args, 1);
2006 if (!strcasecmp(key_type_rsa1024, key_type)) {
2018 decoded_key->v2 = pk;
2020 }
else if (!strcasecmp(key_type_ed25519_v3, key_type)) {
2025 strlen(key_blob)) !=
sizeof(sk->
seckey)) {
2030 decoded_key->v3 = sk;
2032 }
else if (!strcasecmp(key_type_new, key_type)) {
2034 if (!strcasecmp(key_type_rsa1024, key_blob)) {
2037 if (crypto_pk_generate_key(pk)) {
2049 key_new_alg = key_type_rsa1024;
2051 decoded_key->v2 = pk;
2053 }
else if (!strcasecmp(key_type_ed25519_v3, key_blob) ||
2054 !strcasecmp(key_type_best, key_blob)) {
2060 key_type_ed25519_v3);
2065 key_new_blob = tor_malloc_zero(len);
2067 sizeof(sk->
seckey), 0) != (len - 1)) {
2071 key_type_ed25519_v3);
2074 key_new_alg = key_type_ed25519_v3;
2076 decoded_key->v3 = sk;
2095 smartlist_free(key_args);
2097 *key_new_alg_out = key_new_alg;
2098 *key_new_blob_out = key_new_blob;
2128 if (smartlist_len(auth_args) < 1 || smartlist_len(auth_args) > 2) {
2132 client->client_name = tor_strdup(smartlist_get(auth_args, 0));
2133 if (smartlist_len(auth_args) == 2) {
2134 char *decode_err_msg = NULL;
2136 client->descriptor_cookie,
2137 NULL, &decode_err_msg) < 0) {
2157 smartlist_free(auth_args);
2159 rend_authorized_client_free(client);
2179 const char *service_id = smartlist_get(args, 0);
2204 onion_services = services[i];
2208 if (onion_services == NULL) {
2212 switch (hs_version) {
2228 log_warn(
LD_BUG,
"Failed to remove Onion Service %s.",
2234 char *cp = smartlist_get(onion_services, idx);
2298 #define CMD_FL_WIPE (1u<<0)
2304 #define ONE_LINE(name, flags) \
2307 handle_control_ ##name, \
2316 #define MULTLINE(name, flags) \
2318 handle_control_ ##name, \
2327 #define OBSOLETE(name) \
2329 handle_control_obsolete, \
2371 ONE_LINE(onion_client_auth_remove, 0),
2372 ONE_LINE(onion_client_auth_view, 0),
2387 uint32_t cmd_data_len,
2406 if (def->
handler(conn, parsed_args))
2412 control_cmd_args_free(parsed_args);
2416 memwipe(args, 0, cmd_data_len);
2427 uint32_t cmd_data_len,
2448 control_cmd_free_all(
void)
unsigned int is_owning_control_connection
void control_reply_add_one_kv(smartlist_t *reply, int code, int flags, const char *key, const char *val)
static int handle_control_redirectstream(control_connection_t *conn, const control_cmd_args_t *cmd_args)
void remove_all_entry_guards(void)
circuit_build_times_t * get_circuit_build_times_mutable(void)
STATIC rend_authorized_client_t * add_onion_helper_clientauth(const char *arg, int *created, control_connection_t *conn)
Header file for connection_edge.c.
static int handle_control_resolve(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)
int smartlist_split_string(smartlist_t *sl, const char *str, const char *sep, int flags, int max)
unsigned int have_sent_protocolinfo
void or_state_mark_dirty(or_state_t *state, time_t when)
#define CIRCUIT_STATE_OPEN
Header file for routerinfo.c.
int rend_service_del_ephemeral(const char *service_id)
static int handle_control_mapaddress(control_connection_t *conn, const control_cmd_args_t *args)
Entry connection structure.
void memwipe(void *mem, uint8_t byte, size_t sz)
static const size_t N_CONTROL_COMMANDS
int circuit_send_next_onion_skin(origin_circuit_t *circ)
#define CIRCUIT_PURPOSE_C_GENERAL
smartlist_t * ephemeral_onion_services
Header file for dnsserv.c.
int options_save_current(void)
void tor_strupper(char *s)
struct config_line_t * HashedControlPassword
unsigned int edge_has_sent_end
int rend_valid_client_name(const char *client_name)
static int handle_control_signal(control_connection_t *conn, const control_cmd_args_t *args)
static const control_cmd_def_t CONTROL_COMMANDS[]
Parsed v2 HS descriptor structure.
static int handle_control_hspost(control_connection_t *conn, const control_cmd_args_t *args)
#define CIRCLAUNCH_NEED_CAPACITY
Header file for control.c.
Header file for rendparse.c.
int handle_control_command(control_connection_t *conn, uint32_t cmd_data_len, char *args)
crypto_pk_t * crypto_pk_new(void)
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)
Circuit-build-stse structure.
Header file for circuituse.c.
void connection_entry_set_controller_wait(entry_connection_t *conn)
int circuit_append_new_exit(origin_circuit_t *circ, extend_info_t *exit_ei)
int router_load_single_router(const char *s, uint8_t purpose, int cache, const char **msg)
#define tor_fragile_assert()
Header file for control_proto.c.
int control_event_address_mapped(const char *from, const char *to, time_t expires, const char *error, const int cached)
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, char **address_out)
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
#define REND_SERVICE_ID_LEN_BASE32
uint64_t tor_parse_uint64(const char *s, int base, uint64_t min, uint64_t max, int *ok, char **next)
void smartlist_add(smartlist_t *sl, void *element)
static entry_connection_t * get_stream(const char *id)
origin_circuit_t * circuit_launch(uint8_t purpose, int flags)
static int handle_control_takeownership(control_connection_t *conn, const control_cmd_args_t *args)
connection_t * connection_get_by_global_id(uint64_t id)
Encoded v2 HS descriptor structure.
int hs_service_del_ephemeral(const char *address)
char * rend_auth_encode_cookie(const uint8_t *cookie_in, rend_auth_type_t auth_type)
static int handle_control_closestream(control_connection_t *conn, const control_cmd_args_t *cmd_args)
int circuit_handle_first_hop(origin_circuit_t *circ)
smartlist_t * get_detached_onion_services(void)
int ed25519_secret_key_generate(ed25519_secret_key_t *seckey_out, int extra_strong)
smartlist_t * smartlist_new(void)
Client request structure.
void send_control_done(control_connection_t *conn)
int base64_encode(char *dest, size_t destlen, const char *src, size_t srclen, int flags)
setopt_err_t options_init_from_string(const char *cf_defaults, const char *cf, int command, const char *command_arg, char **msg)
struct config_line_t * kwargs
long tor_parse_long(const char *s, int base, long min, long max, int *ok, char **next)
void control_cmd_args_free_(control_cmd_args_t *args)
static int handle_control_dropguards(control_connection_t *conn, const control_cmd_args_t *args)
#define MULTLINE(name, flags)
static int kvline_check_keyword_args(const control_cmd_args_t *result, const control_cmd_syntax_t *syntax, char **error_out)
void * smartlist_pop_last(smartlist_t *sl)
int hs_address_is_valid(const char *address)
static int handle_control_loadconf(control_connection_t *conn, const control_cmd_args_t *args)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
or_state_t * get_or_state(void)
static int handle_control_hsfetch(control_connection_t *conn, const control_cmd_args_t *args)
config_line_t * config_lines_dup(const config_line_t *inp)
int base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
int(* handler_fn_t)(control_connection_t *conn, const control_cmd_args_t *args)
uint32_t global_identifier
const control_cmd_syntax_t * syntax
int rend_client_fetch_v2_desc(rend_data_t *query, smartlist_t *hsdirs)
Common functions for cryptographic routines.
hs_service_add_ephemeral_status_t
#define CIRCUIT_PURPOSE_CONTROLLER
struct smartlist_t * args
#define REND_DESC_ID_V2_LEN_BASE32
size_t base64_encode_size(size_t srclen, int flags)
#define ENTRY_TO_EDGE_CONN(c)
int smartlist_string_pos(const smartlist_t *sl, const char *element)
Header file for circuitlist.c.
static int handle_control_setconf(control_connection_t *conn, const control_cmd_args_t *args)
#define AP_CONN_STATE_RESOLVE_WAIT
static char * get_authmethods(const or_options_t *options)
setopt_err_t options_trial_assign(config_line_t *list, unsigned flags, char **msg)
int address_is_invalid_destination(const char *address, int client)
char * get_controller_cookie_file_name(void)
const char * option_get_canonical_name(const char *key)
entry_connection_t * TO_ENTRY_CONN(connection_t *c)
#define control_reply_free(r)
Free and null a smartlist of control_reply_line_t.
static int handle_control_del_onion(control_connection_t *conn, const control_cmd_args_t *cmd_args)
struct config_line_t * HashedControlSessionPassword
Header file for circuitbuild.c.
origin_circuit_t * circuit_get_by_global_id(uint32_t id)
Header file for control_auth.c.
#define tor_assert_nonfatal_unreached()
const struct control_event_t control_event_table[]
static int handle_control_usefeature(control_connection_t *conn, const control_cmd_args_t *cmd_args)
int connection_edge_end(edge_connection_t *conn, uint8_t reason)
#define AP_CONN_STATE_CONNECT_WAIT
static void add_authmethods(smartlist_t *reply)
static int control_setconf_helper(control_connection_t *conn, const control_cmd_args_t *args, int use_defaults)
static int handle_control_add_onion(control_connection_t *conn, const control_cmd_args_t *args)
unsigned int onehop_tunnel
extend_info_t * extend_info_from_node(const node_t *node, int for_direct_connect)
void control_reply_add_done(smartlist_t *reply)
void directory_post_to_hs_dir(rend_service_descriptor_t *renddesc, smartlist_t *descs, smartlist_t *hs_dirs, const char *service_id, int seconds_valid)
const char * escaped(const char *s)
#define ROUTER_PURPOSE_UNKNOWN
static int handle_control_getconf(control_connection_t *conn, const control_cmd_args_t *args)
int strcmpstart(const char *s1, const char *s2)
void circuit_change_purpose(circuit_t *circ, uint8_t new_purpose)
void smartlist_del(smartlist_t *sl, int idx)
static int handle_control_setcircuitpurpose(control_connection_t *conn, const control_cmd_args_t *args)
static uint8_t circuit_purpose_from_string(const char *string)
static int handle_control_postdescriptor(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)
uint16_t marked_for_close
Header file for nodelist.c.
int hs_control_hspost_command(const char *body, const char *onion_address, const smartlist_t *hsdirs_rs)
int rend_valid_v2_service_id(const char *query)
Header file containing control port event related code.
Header file for routerlist.c.
int rend_valid_descriptor_id(const char *query)
rend_service_port_config_t * rend_service_parse_port_config(const char *string, const char *sep, char **err_msg_out)
origin_circuit_t * origin_circuit_init(uint8_t purpose, int flags)
uint8_t router_purpose_from_string(const char *s)
void control_printf_endreply(control_connection_t *conn, int code, const char *fmt,...)
Router descriptor structure.
const circuit_build_times_t * get_circuit_build_times(void)
Header file for rendservice.c.
Header file for circuitstats.c.
char * make_path_absolute(const char *fname)
Header for core/or/extendinfo.c.
static char * get_esc_cfile(const or_options_t *options)
uint8_t seckey[ED25519_SECKEY_LEN]
tor_cmdline_mode_t command
int connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn, origin_circuit_t *circ, crypt_path_t *cpath)
Common functions for using (pseudo-)random number generators.
socks_request_t * socks_request
static int handle_control_closecircuit(control_connection_t *conn, const control_cmd_args_t *args)
crypto_pk_t * crypto_pk_base64_decode_private(const char *str, size_t len)
Header file for control_events.c.
size_t read_escaped_data(const char *data, size_t len, char **out)
const or_options_t * get_options(void)
cpath_build_state_t * build_state
Header file for circuitbuild.c.
void control_reply_append_kv(smartlist_t *reply, const char *key, const char *val)
static int handle_control_dropownership(control_connection_t *conn, const control_cmd_args_t *args)
static bool config_lines_contain_flag(const config_line_t *lines, const char *flag)
void control_write_reply_lines(control_connection_t *conn, smartlist_t *lines)
#define CIRCUIT_PURPOSE_UNKNOWN
static int address_is_invalid_mapaddress_target(const char *addr)
static smartlist_t * detached_onion_services
Header file for connection.c.
int rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out, char *desc_id_out, char **intro_points_encrypted_out, size_t *intro_points_encrypted_size_out, size_t *encoded_size_out, const char **next_out, const char *desc, int as_hsdir)
config_line_t * option_get_assignment(const or_options_t *options, const char *key)
int option_is_recognized(const char *key)
static int handle_control_protocolinfo(control_connection_t *conn, const control_cmd_args_t *cmd_args)
config_line_t * kvline_parse(const char *line, unsigned flags)
static crypto_pk_t * onionkey
Header file for control_cmd.c.
static origin_circuit_t * get_circ(const char *id)
void control_reply_add_printf(smartlist_t *reply, int code, const char *fmt,...)
int rend_auth_decode_cookie(const char *cookie_in, uint8_t *cookie_out, rend_auth_type_t *auth_type_out, char **err_msg_out)
#define REND_DESC_COOKIE_LEN
int tor_asprintf(char **strp, const char *fmt,...)
Hidden-service authorized client structure.
hs_service_add_ephemeral_status_t rend_service_add_ephemeral(crypto_pk_t *pk, smartlist_t *ports, int max_streams_per_circuit, int max_streams_close_circuit, rend_auth_type_t auth_type, smartlist_t *auth_clients, char **service_id_out)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
int addressmap_register_auto(const char *from, const char *to, time_t expires, addressmap_entry_source_t addrmap_source, const char **msg)
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)
int dnsserv_launch_request(const char *name, int reverse, control_connection_t *control_conn)
rend_data_t * rend_data_client_create(const char *onion_address, const char *desc_id, const char *cookie, rend_auth_type_t auth_type)
Node information structure.
int crypto_pk_base64_encode_private(const crypto_pk_t *pk, char **priv_out)
static int handle_control_saveconf(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)
int base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
void control_write_endreply(control_connection_t *conn, int code, const char *s)
char address[MAX_SOCKS_ADDR_LEN]
unsigned long tor_parse_ulong(const char *s, int base, unsigned long min, unsigned long max, int *ok, char **next)
void circuit_set_state(circuit_t *circ, uint8_t state)
void control_printf_midreply(control_connection_t *conn, int code, const char *fmt,...)
Header file for config.c.
void control_reply_add_str(smartlist_t *reply, int code, const char *s)
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
int hs_parse_address(const char *address, ed25519_public_key_t *key_out, uint8_t *checksum_out, uint8_t *version_out)
char * esc_for_log(const char *s)
const node_t * node_get_by_hex_id(const char *hex_id, unsigned flags)
const char * addressmap_register_virtual_address(int type, char *new_address)
void circuit_build_times_reset(circuit_build_times_t *cbt)
#define CIRCUIT_STATE_GUARD_WAIT
int circuit_get_cpath_len(origin_circuit_t *circ)
edge_connection_t * p_streams
#define ROUTER_PURPOSE_GENERAL
void crypto_rand(char *to, size_t n)
int crypto_pk_num_bits(crypto_pk_t *env)
int connection_flush(connection_t *conn)
static int handle_control_attachstream(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_setevents(control_connection_t *conn, const control_cmd_args_t *args)
#define AP_CONN_STATE_CONTROLLER_WAIT
void control_update_global_event_mask(void)
static int handle_control_resetconf(control_connection_t *conn, const control_cmd_args_t *args)
const config_line_t * config_line_find_case(const config_line_t *lines, const char *key)
#define CIRCUIT_STATE_BUILDING
Origin circuit structure.
int node_has_preferred_descriptor(const node_t *node, int for_direct_connect)
circuit_t * circuit_get_by_edge_conn(edge_connection_t *conn)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
Header file for rendclient.c.
Definition for control_cmd_args_t.
Header file for rendcommon.c.
Controller connection structure.
void control_cmd_args_wipe(control_cmd_args_t *args)
static bool string_array_contains_keyword(const char **array, const char *kwd)
const char ** allowed_keywords
int strcasecmpstart(const char *s1, const char *s2)
#define ONE_LINE(name, flags)
int rend_get_service_id(crypto_pk_t *pk, char *out)
Master header file for Tor-specific functionality.
int circuit_event_status(origin_circuit_t *circ, circuit_status_event_t tp, int reason_code)
void circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
crypt_path_t * circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum)
void hs_control_hsfetch_command(const ed25519_public_key_t *onion_identity_pk, const smartlist_t *hsdirs)