10 #define CONTROL_EVENTS_PRIVATE
11 #define CONTROL_MODULE_PRIVATE
12 #define CONTROL_GETINFO_PRIVATE
30 #include "feature/control/control_getinfo.h"
85 char **answer,
const char **errmsg)
88 if (!strcmp(question,
"version")) {
90 }
else if (!strcmp(question,
"bw-event-cache")) {
91 *answer = get_bw_samples();
92 }
else if (!strcmp(question,
"config-file")) {
95 *answer = tor_strdup(a);
96 }
else if (!strcmp(question,
"config-defaults-file")) {
99 *answer = tor_strdup(a);
100 }
else if (!strcmp(question,
"config-text")) {
102 }
else if (!strcmp(question,
"config-can-saveconf")) {
103 *answer = tor_strdup(
get_options()->IncludeUsed ?
"0" :
"1");
104 }
else if (!strcmp(question,
"info/names")) {
106 }
else if (!strcmp(question,
"dormant")) {
108 *answer = tor_strdup(dormant ?
"1" :
"0");
109 }
else if (!strcmp(question,
"events/names")) {
119 smartlist_free(event_names);
120 }
else if (!strcmp(question,
"signal/names")) {
123 for (j = 0; signal_table[j].signal_name != NULL; ++j) {
124 smartlist_add(signal_names, (
char*)signal_table[j].signal_name);
129 smartlist_free(signal_names);
130 }
else if (!strcmp(question,
"features/names")) {
131 *answer = tor_strdup(
"VERBOSE_NAMES EXTENDED_EVENTS");
132 }
else if (!strcmp(question,
"address") || !strcmp(question,
"address/v4")) {
135 RELAY_FIND_ADDR_CACHE_ONLY, &addr)) {
136 *errmsg =
"Address unknown";
140 tor_assert_nonfatal(*answer);
141 }
else if (!strcmp(question,
"address/v6")) {
144 RELAY_FIND_ADDR_CACHE_ONLY, &addr)) {
145 *errmsg =
"Address unknown";
149 tor_assert_nonfatal(*answer);
150 }
else if (!strcmp(question,
"traffic/read")) {
152 }
else if (!strcmp(question,
"traffic/written")) {
154 }
else if (!strcmp(question,
"uptime")) {
157 }
else if (!strcmp(question,
"process/pid")) {
167 }
else if (!strcmp(question,
"process/uid")) {
169 *answer = tor_strdup(
"-1");
171 int myUid = geteuid();
174 }
else if (!strcmp(question,
"process/user")) {
176 *answer = tor_strdup(
"");
178 int myUid = geteuid();
182 *answer = tor_strdup(myPwEntry->pw_name);
184 *answer = tor_strdup(
"");
187 }
else if (!strcmp(question,
"process/descriptor-limit")) {
190 }
else if (!strcmp(question,
"limits/max-mem-in-queues")) {
193 }
else if (!strcmp(question,
"fingerprint")) {
196 *errmsg =
"Not running in server mode";
199 server_key = get_server_identity_key();
220 char *out = NULL, *outp;
222 const char *router_sig;
229 outp = out = tor_malloc(ri_len+ei_len+1);
230 if (!(router_sig = tor_memstr(ri_body, ri_len,
"\nrouter-signature")))
233 memcpy(out, ri_body, router_sig-ri_body);
234 outp += router_sig-ri_body;
236 for (i=0; i < 2; ++i) {
237 const char *kwd = i ?
"\nwrite-history " :
"\nread-history ";
238 const char *cp, *eol;
239 if (!(cp = tor_memstr(ei_body, ei_len, kwd)))
242 if (!(eol = memchr(cp,
'\n', ei_len - (cp-ei_body))))
244 memcpy(outp, cp, eol-cp+1);
247 memcpy(outp, router_sig, ri_len - (router_sig-ri_body));
249 tor_assert(outp-out < (
int)(ri_len+ei_len+1));
261 const char *question,
262 char **answer,
const char **errmsg)
270 if (!strcmp(question,
"net/listeners/or"))
272 else if (!strcmp(question,
"net/listeners/extor"))
274 else if (!strcmp(question,
"net/listeners/dir"))
276 else if (!strcmp(question,
"net/listeners/socks"))
278 else if (!strcmp(question,
"net/listeners/trans"))
280 else if (!strcmp(question,
"net/listeners/natd"))
282 else if (!strcmp(question,
"net/listeners/httptunnel"))
284 else if (!strcmp(question,
"net/listeners/dns"))
286 else if (!strcmp(question,
"net/listeners/control"))
288 else if (!strcmp(question,
"net/listeners/metrics"))
295 struct sockaddr_storage ss;
296 socklen_t ss_len =
sizeof(ss);
298 if (conn->type != type || conn->marked_for_close || !
SOCKET_OK(conn->s))
301 if (getsockname(conn->s, (
struct sockaddr *)&ss, &ss_len) < 0) {
309 } SMARTLIST_FOREACH_END(conn);
322 const char *question,
323 char **answer,
const char **errmsg)
330 char timebuf[ISO_TIME_LEN+1];
332 if (!strcmp(question,
"current-time/local"))
334 else if (!strcmp(question,
"current-time/utc"))
339 *answer = tor_strdup(timebuf);
351 if (BUG(!strcmp(flavor_name,
"??"))) {
352 *errmsg =
"Internal error: unrecognized flavor name.";
359 *answer = tor_strdup(consensus->
dir);
366 *answer = tor_memdup_nulterm(mapped->
data, mapped->
size);
367 tor_munmap_file(mapped);
370 *errmsg =
"Could not open cached consensus. "
371 "Make sure FetchUselessDescriptors is set to 1.";
401 if (!strcmp(key,
"/tor/server/all")) {
405 }
else if (!strcmp(key,
"/tor/server/authority")) {
411 key += strlen(
"/tor/server/d/");
413 DSR_HEX|DSR_SORT_UNIQ);
421 smartlist_free(digests);
425 key += strlen(
"/tor/server/fp/");
427 DSR_HEX|DSR_SORT_UNIQ);
443 } SMARTLIST_FOREACH_END(d);
445 smartlist_free(digests);
447 *msg =
"Key not recognized";
451 if (!smartlist_len(descs_out)) {
452 *msg =
"Servers unavailable";
462 const char *question,
char **answer,
477 *errmsg =
"We fetch microdescriptors, not router "
478 "descriptors. You'll need to use md/id/* "
479 "instead of desc/id/*.";
496 *errmsg =
"We fetch microdescriptors, not router "
497 "descriptors. You'll need to use md/name/* "
498 "instead of desc/name/*.";
501 }
else if (!strcmp(question,
"desc/download-enabled")) {
504 }
else if (!strcmp(question,
"desc/all-recent")) {
510 const char *body = signed_descriptor_get_body(&ri->cache_info);
513 tor_strndup(body, ri->cache_info.signed_descriptor_len));
519 }
else if (!strcmp(question,
"desc/all-recent-extrainfo-hack")) {
527 ri->cache_info.extra_info_digest);
530 &ri->cache_info, ei));
533 tor_strndup(body, ri->cache_info.signed_descriptor_len));
535 } SMARTLIST_FOREACH_END(ri);
540 }
else if (!
strcmpstart(question,
"hs/client/desc/id/")) {
543 question += strlen(
"hs/client/desc/id/");
545 addr_type = ONION_V3_HOSTNAME;
547 *errmsg =
"Invalid address";
551 if (addr_type == ONION_V3_HOSTNAME) {
559 *errmsg =
"Invalid v3 address";
565 *answer = tor_strdup(desc);
567 *errmsg =
"Not found in cache";
571 }
else if (!
strcmpstart(question,
"hs/service/desc/id/")) {
574 question += strlen(
"hs/service/desc/id/");
576 addr_type = ONION_V3_HOSTNAME;
578 *errmsg =
"Invalid address";
582 if (addr_type == ONION_V3_HOSTNAME) {
590 *errmsg =
"Invalid v3 address";
599 *errmsg =
"Not found in cache";
603 }
else if (!strcmp(question,
"md/all")) {
607 if (smartlist_len(nodes) == 0) {
608 *answer = tor_strdup(
"");
615 if (n->md && n->md->body) {
616 char *copy = tor_strndup(n->md->body, n->md->bodylen);
619 } SMARTLIST_FOREACH_END(n);
623 smartlist_free(microdescs);
627 if (node) md = node->md;
628 if (md && md->
body) {
637 if (node) md = node->md;
638 if (md && md->
body) {
641 }
else if (!strcmp(question,
"md/download-enabled")) {
644 }
else if (!
strcmpstart(question,
"desc-annotations/id/")) {
651 const char *annotations =
654 *answer = tor_strndup(annotations,
657 }
else if (!
strcmpstart(question,
"dir/server/")) {
658 size_t answer_len = 0;
667 log_warn(
LD_CONTROL,
"getinfo '%s': %s", question, msg);
668 smartlist_free(descs);
675 cp = *answer = tor_malloc(answer_len+1);
679 sd->signed_descriptor_len);
680 cp += sd->signed_descriptor_len;
684 smartlist_free(descs);
685 }
else if (!
strcmpstart(question,
"dir/status/")) {
686 *answer = tor_strdup(
"");
687 }
else if (!strcmp(question,
"dir/status-vote/current/consensus")) {
690 if (consensus_result < 0) {
693 }
else if (!strcmp(question,
694 "dir/status-vote/current/consensus-microdesc")) {
697 if (consensus_result < 0) {
700 }
else if (!
strcmpstart(question,
"extra-info/digest/")) {
701 question += strlen(
"extra-info/digest/");
739 result = tor_malloc_zero(len);
746 } SMARTLIST_FOREACH_END(digest);
759 char tbuf[ISO_TIME_LEN+1];
760 const char *schedule_str, *want_authority_str;
761 const char *increment_on_str, *backoff_str;
768 case DL_SCHED_GENERIC:
769 schedule_str =
"DL_SCHED_GENERIC";
771 case DL_SCHED_CONSENSUS:
772 schedule_str =
"DL_SCHED_CONSENSUS";
774 case DL_SCHED_BRIDGE:
775 schedule_str =
"DL_SCHED_BRIDGE";
778 schedule_str =
"unknown";
783 case DL_WANT_ANY_DIRSERVER:
784 want_authority_str =
"DL_WANT_ANY_DIRSERVER";
786 case DL_WANT_AUTHORITY:
787 want_authority_str =
"DL_WANT_AUTHORITY";
790 want_authority_str =
"unknown";
795 case DL_SCHED_INCREMENT_FAILURE:
796 increment_on_str =
"DL_SCHED_INCREMENT_FAILURE";
798 case DL_SCHED_INCREMENT_ATTEMPT:
799 increment_on_str =
"DL_SCHED_INCREMENT_ATTEMPT";
802 increment_on_str =
"unknown";
806 backoff_str =
"DL_SCHED_RANDOM_EXPONENTIAL";
810 "next-attempt-at %s\n"
811 "n-download-failures %u\n"
812 "n-download-attempts %u\n"
814 "want-authority %s\n"
817 "last-backoff-position %u\n"
818 "last-delay-used %d\n",
843 if (strcmp(flavor,
"ns") == 0) {
845 }
else if (strcmp(flavor,
"ns/bootstrap") == 0) {
847 }
else if (strcmp(flavor,
"ns/running") == 0 ) {
849 }
else if (strcmp(flavor,
"microdesc") == 0) {
851 }
else if (strcmp(flavor,
"microdesc/bootstrap") == 0) {
854 }
else if (strcmp(flavor,
"microdesc/running") == 0) {
858 *errmsg =
"Unknown flavor";
901 if (strcmp(fp_sk_req,
"fps") == 0) {
903 if (!(*digest_list)) {
904 *errmsg =
"Failed to get list of authority identity digests (!)";
907 fp_sk_req += strlen(
"fp/");
909 sk_req = strchr(fp_sk_req,
'/');
913 fp_sk_req, sk_req - fp_sk_req) ==
DIGEST_LEN) {
916 if (strcmp(sk_req,
"sks") == 0) {
919 if (!(*digest_list)) {
920 *errmsg =
"Failed to get list of signing key digests for this "
921 "authority identity digest";
929 if (!(*dl_to_emit)) {
930 *errmsg =
"Failed to get download status for this identity/"
931 "signing key digest pair";
934 *errmsg =
"That didn't look like a signing key digest";
938 *errmsg =
"That didn't look like an identity digest";
944 fp_sk_req, strlen(fp_sk_req)) ==
DIGEST_LEN) {
946 if (!(*dl_to_emit)) {
947 *errmsg =
"Failed to get download status for this authority "
951 *errmsg =
"That didn't look like a digest";
954 *errmsg =
"That didn't look like a digest";
958 *errmsg =
"Unknown certificate download status query";
983 if (strcmp(desc_req,
"descs") == 0) {
985 if (!(*digest_list)) {
986 *errmsg =
"We don't seem to have a networkstatus-flavored consensus";
997 if (!(*dl_to_emit)) {
998 *errmsg =
"No such descriptor digest found";
1001 *errmsg =
"That didn't look like a digest";
1004 *errmsg =
"Unknown router descriptor download status query";
1013 const char **errmsg)
1029 if (strcmp(bridge_req,
"bridges") == 0) {
1031 if (!(*digest_list)) {
1032 *errmsg =
"We don't seem to be using bridges";
1036 bridge_req, strlen(bridge_req)) ==
DIGEST_LEN) {
1039 if (!(*dl_to_emit)) {
1040 *errmsg =
"No such bridge identity digest found";
1043 *errmsg =
"That didn't look like a digest";
1046 *errmsg =
"Unknown bridge descriptor download status query";
1054 const char *question,
char **answer,
1055 const char **errmsg)
1070 if (!
strcmpstart(question,
"downloads/networkstatus/")) {
1072 question + strlen(
"downloads/networkstatus/"),
1073 &dl_to_emit, errmsg);
1075 }
else if (!
strcmpstart(question,
"downloads/cert/")) {
1077 question + strlen(
"downloads/cert/"),
1078 &dl_to_emit, &digest_list, errmsg);
1080 }
else if (!
strcmpstart(question,
"downloads/desc/")) {
1082 question + strlen(
"downloads/desc/"),
1083 &dl_to_emit, &digest_list, errmsg);
1085 }
else if (!
strcmpstart(question,
"downloads/bridge/")) {
1087 question + strlen(
"downloads/bridge/"),
1088 &dl_to_emit, &digest_list, errmsg);
1090 *errmsg =
"Unknown download status query";
1097 }
else if (digest_list) {
1100 smartlist_free(digest_list);
1105 *errmsg =
"Unknown error";
1116 const char *question,
char **answer,
1117 const char **errmsg)
1120 (void) control_conn;
1121 if (!strcmp(question,
"circuit-status")) {
1134 state =
"GUARD_WAIT";
1135 else if (circ->
cpath)
1144 state, *circdesc ?
" " :
"", circdesc);
1147 SMARTLIST_FOREACH_END(circ_);
1150 smartlist_free(status);
1151 }
else if (!strcmp(question,
"stream-status")) {
1161 base_conn->marked_for_close ||
1166 switch (base_conn->state)
1172 state =
"NEWRESOLVE";
1178 state =
"SENTCONNECT";
break;
1180 state =
"SENTRESOLVE";
break;
1182 state =
"SUCCEEDED";
break;
1184 log_warn(
LD_BUG,
"Asked for stream in unknown state %d",
1193 (
unsigned long) base_conn->global_identifier,state,
1197 } SMARTLIST_FOREACH_END(base_conn);
1200 smartlist_free(status);
1201 }
else if (!strcmp(question,
"orconn-status")) {
1208 if (base_conn->type !=
CONN_TYPE_OR || base_conn->marked_for_close)
1212 state =
"CONNECTED";
1219 } SMARTLIST_FOREACH_END(base_conn);
1222 smartlist_free(status);
1223 }
else if (!
strcmpstart(question,
"address-mappings/")) {
1224 time_t min_e, max_e;
1226 question += strlen(
"address-mappings/");
1227 if (!strcmp(question,
"all")) {
1228 min_e = 0; max_e = TIME_MAX;
1229 }
else if (!strcmp(question,
"cache")) {
1230 min_e = 2; max_e = TIME_MAX;
1231 }
else if (!strcmp(question,
"config")) {
1232 min_e = 0; max_e = 0;
1233 }
else if (!strcmp(question,
"control")) {
1234 min_e = 1; max_e = 1;
1242 smartlist_free(mappings);
1246 if (!strcmp(question,
"status/circuit-established")) {
1248 }
else if (!strcmp(question,
"status/enough-dir-info")) {
1250 }
else if (!strcmp(question,
"status/good-server-descriptor") ||
1251 !strcmp(question,
"status/accepted-server-descriptor")) {
1257 }
else if (!strcmp(question,
"status/reachability-succeeded/or")) {
1258 *answer = tor_strdup(
1259 router_all_orports_seem_reachable(options) ?
1261 }
else if (!strcmp(question,
"status/reachability-succeeded/dir")) {
1262 *answer = tor_strdup(
1265 }
else if (!strcmp(question,
"status/reachability-succeeded")) {
1267 answer,
"OR=%d DIR=%d",
1268 router_all_orports_seem_reachable(options) ? 1 : 0,
1270 }
else if (!strcmp(question,
"status/bootstrap-phase")) {
1272 }
else if (!
strcmpstart(question,
"status/version/")) {
1276 const char *recommended;
1285 if (!strcmp(question,
"status/version/recommended")) {
1286 *answer = tor_strdup(recommended);
1289 if (!strcmp(question,
"status/version/current")) {
1293 case VS_OLD: *answer = tor_strdup(
"obsolete");
break;
1294 case VS_NEW: *answer = tor_strdup(
"new");
break;
1297 case VS_EMPTY: *answer = tor_strdup(
"none recommended");
break;
1298 case VS_UNKNOWN: *answer = tor_strdup(
"unknown");
break;
1302 }
else if (!strcmp(question,
"status/clients-seen")) {
1304 if (!bridge_stats) {
1305 *errmsg =
"No bridge-client stats available";
1308 *answer = bridge_stats;
1309 }
else if (!strcmp(question,
"status/fresh-relay-descs")) {
1311 *errmsg =
"Only relays have descriptors";
1319 case TOR_ROUTERINFO_ERROR_NO_EXT_ADDR:
1320 *errmsg =
"Cannot get relay address while generating descriptor";
1322 case TOR_ROUTERINFO_ERROR_DIGEST_FAILED:
1323 *errmsg =
"Key digest failed";
1325 case TOR_ROUTERINFO_ERROR_CANNOT_GENERATE:
1326 *errmsg =
"Cannot generate router descriptor";
1329 *errmsg =
"Error generating descriptor";
1339 char *descs = tor_malloc(size);
1345 if (cp[0] ==
'\0') {
1347 }
else if (cp[0] !=
'\n') {
1355 if (cp[0] ==
'\n') {
1357 }
else if (cp[0] !=
'\0') {
1374 const char *question,
char **answer,
1375 const char **errmsg)
1380 if (control_conn && !strcmp(question,
"onions/current")) {
1382 }
else if (!strcmp(question,
"onions/detached")) {
1387 if (!onion_list || smartlist_len(onion_list) == 0) {
1389 *answer = tor_strdup(
"");
1404 const char *question,
char **answer,
1405 const char **errmsg)
1409 if (strcmp(question,
"network-liveness") == 0) {
1410 if (get_cached_network_liveness()) {
1411 *answer = tor_strdup(
"up");
1413 *answer = tor_strdup(
"down");
1424 const char *question,
char **answer,
1425 const char **errmsg)
1427 (void) control_conn;
1431 if (!strcmp(question,
"stats/ntor/assigned")) {
1434 }
else if (!strcmp(question,
"stats/ntor/requested")) {
1437 }
else if (!strcmp(question,
"stats/tap/assigned")) {
1440 }
else if (!strcmp(question,
"stats/tap/requested")) {
1444 *errmsg =
"Unrecognized handshake type";
1457 const char *question,
char **answer,
1458 const char **errmsg)
1460 (void) control_conn;
1463 if (!strcmp(question,
"sr/current")) {
1465 }
else if (!strcmp(question,
"sr/previous")) {
1482 const char *q,
char **a,
1483 const char **error_out);
1494 #define ITEM(name, fn, desc) { name, getinfo_helper_##fn, desc, 0 }
1495 #define PREFIX(name, fn, desc) { name, getinfo_helper_##fn, desc, 1 }
1496 #define DOC(name, desc) { name, NULL, desc, 0 }
1501 ITEM(
"version", misc,
"The current version of Tor."),
1502 ITEM(
"bw-event-cache", misc,
"Cached BW events for a short interval."),
1503 ITEM(
"config-file", misc,
"Current location of the \"torrc\" file."),
1504 ITEM(
"config-defaults-file", misc,
"Current location of the defaults file."),
1505 ITEM(
"config-text", misc,
1506 "Return the string that would be written by a saveconf command."),
1507 ITEM(
"config-can-saveconf", misc,
1508 "Is it possible to save the configuration to the \"torrc\" file?"),
1509 ITEM(
"accounting/bytes", accounting,
1510 "Number of bytes read/written so far in the accounting interval."),
1511 ITEM(
"accounting/bytes-left", accounting,
1512 "Number of bytes left to write/read so far in the accounting interval."),
1513 ITEM(
"accounting/enabled", accounting,
"Is accounting currently enabled?"),
1514 ITEM(
"accounting/hibernating", accounting,
"Are we hibernating or awake?"),
1515 ITEM(
"accounting/interval-start", accounting,
1516 "Time when the accounting period starts."),
1517 ITEM(
"accounting/interval-end", accounting,
1518 "Time when the accounting period ends."),
1519 ITEM(
"accounting/interval-wake", accounting,
1520 "Time to wake up in this accounting period."),
1521 ITEM(
"helper-nodes", entry_guards, NULL),
1522 ITEM(
"entry-guards", entry_guards,
1523 "Which nodes are we using as entry guards?"),
1524 ITEM(
"fingerprint", misc, NULL),
1525 PREFIX(
"config/", config,
"Current configuration values."),
1527 "List of configuration options, types, and documentation."),
1528 DOC(
"config/defaults",
1529 "List of default values for configuration options. "
1530 "See also config/names"),
1531 PREFIX(
"current-time/", current_time,
"Current time."),
1532 DOC(
"current-time/local",
"Current time on the local system."),
1533 DOC(
"current-time/utc",
"Current UTC time."),
1534 PREFIX(
"downloads/networkstatus/", downloads,
1535 "Download statuses for networkstatus objects"),
1536 DOC(
"downloads/networkstatus/ns",
1537 "Download status for current-mode networkstatus download"),
1538 DOC(
"downloads/networkstatus/ns/bootstrap",
1539 "Download status for bootstrap-time networkstatus download"),
1540 DOC(
"downloads/networkstatus/ns/running",
1541 "Download status for run-time networkstatus download"),
1542 DOC(
"downloads/networkstatus/microdesc",
1543 "Download status for current-mode microdesc download"),
1544 DOC(
"downloads/networkstatus/microdesc/bootstrap",
1545 "Download status for bootstrap-time microdesc download"),
1546 DOC(
"downloads/networkstatus/microdesc/running",
1547 "Download status for run-time microdesc download"),
1548 PREFIX(
"downloads/cert/", downloads,
1549 "Download statuses for certificates, by id fingerprint and "
1551 DOC(
"downloads/cert/fps",
1552 "List of authority fingerprints for which any download statuses "
1554 DOC(
"downloads/cert/fp/<fp>",
1555 "Download status for <fp> with the default signing key; corresponds "
1556 "to /fp/ URLs on directory server."),
1557 DOC(
"downloads/cert/fp/<fp>/sks",
1558 "List of signing keys for which specific download statuses are "
1559 "available for this id fingerprint"),
1560 DOC(
"downloads/cert/fp/<fp>/<sk>",
1561 "Download status for <fp> with signing key <sk>; corresponds "
1562 "to /fp-sk/ URLs on directory server."),
1563 PREFIX(
"downloads/desc/", downloads,
1564 "Download statuses for router descriptors, by descriptor digest"),
1565 DOC(
"downloads/desc/descs",
1566 "Return a list of known router descriptor digests"),
1567 DOC(
"downloads/desc/<desc>",
1568 "Return a download status for a given descriptor digest"),
1569 PREFIX(
"downloads/bridge/", downloads,
1570 "Download statuses for bridge descriptors, by bridge identity "
1572 DOC(
"downloads/bridge/bridges",
1573 "Return a list of configured bridge identity digests with download "
1575 DOC(
"downloads/bridge/<desc>",
1576 "Return a download status for a given bridge identity digest"),
1577 ITEM(
"info/names", misc,
1578 "List of GETINFO options, types, and documentation."),
1579 ITEM(
"events/names", misc,
1580 "Events that the controller can ask for with SETEVENTS."),
1581 ITEM(
"signal/names", misc,
"Signal names recognized by the SIGNAL command"),
1582 ITEM(
"features/names", misc,
"What arguments can USEFEATURE take?"),
1583 PREFIX(
"desc/id/", dir,
"Router descriptors by ID."),
1584 PREFIX(
"desc/name/", dir,
"Router descriptors by nickname."),
1585 ITEM(
"desc/all-recent", dir,
1586 "All non-expired, non-superseded router descriptors."),
1587 ITEM(
"desc/download-enabled", dir,
1588 "Do we try to download router descriptors?"),
1589 ITEM(
"desc/all-recent-extrainfo-hack", dir, NULL),
1590 ITEM(
"md/all", dir,
"All known microdescriptors."),
1591 PREFIX(
"md/id/", dir,
"Microdescriptors by ID"),
1592 PREFIX(
"md/name/", dir,
"Microdescriptors by name"),
1593 ITEM(
"md/download-enabled", dir,
1594 "Do we try to download microdescriptors?"),
1595 PREFIX(
"extra-info/digest/", dir,
"Extra-info documents by digest."),
1596 PREFIX(
"hs/client/desc/id", dir,
1597 "Hidden Service descriptor in client's cache by onion."),
1598 PREFIX(
"hs/service/desc/id/", dir,
1599 "Hidden Service descriptor in services's cache by onion."),
1600 PREFIX(
"net/listeners/", listeners,
"Bound addresses by type"),
1601 ITEM(
"ns/all", networkstatus,
1602 "Brief summary of router status (v2 directory format)"),
1603 PREFIX(
"ns/id/", networkstatus,
1604 "Brief summary of router status by ID (v2 directory format)."),
1605 PREFIX(
"ns/name/", networkstatus,
1606 "Brief summary of router status by nickname (v2 directory format)."),
1607 PREFIX(
"ns/purpose/", networkstatus,
1608 "Brief summary of router status by purpose (v2 directory format)."),
1609 PREFIX(
"consensus/", networkstatus,
1610 "Information about and from the ns consensus."),
1611 ITEM(
"network-status", dir,
1612 "Brief summary of router status (v1 directory format)"),
1613 ITEM(
"network-liveness", liveness,
1614 "Current opinion on whether the network is live"),
1615 ITEM(
"circuit-status", events,
"List of current circuits originating here."),
1616 ITEM(
"stream-status", events,
"List of current streams."),
1617 ITEM(
"orconn-status", events,
"A list of current OR connections."),
1618 ITEM(
"dormant", misc,
1619 "Is Tor dormant (not building circuits because it's idle)?"),
1620 PREFIX(
"address-mappings/", events, NULL),
1621 DOC(
"address-mappings/all",
"Current address mappings."),
1622 DOC(
"address-mappings/cache",
"Current cached DNS replies."),
1623 DOC(
"address-mappings/config",
1624 "Current address mappings from configuration."),
1625 DOC(
"address-mappings/control",
"Current address mappings from controller."),
1626 PREFIX(
"status/", events, NULL),
1627 DOC(
"status/circuit-established",
1628 "Whether we think client functionality is working."),
1629 DOC(
"status/enough-dir-info",
1630 "Whether we have enough up-to-date directory information to build "
1632 DOC(
"status/bootstrap-phase",
1633 "The last bootstrap phase status event that Tor sent."),
1634 DOC(
"status/clients-seen",
1635 "Breakdown of client countries seen by a bridge."),
1636 DOC(
"status/fresh-relay-descs",
1637 "A fresh relay/ei descriptor pair for Tor's current state. Not stored."),
1638 DOC(
"status/version/recommended",
"List of currently recommended versions."),
1639 DOC(
"status/version/current",
"Status of the current version."),
1640 ITEM(
"address", misc,
"IP address of this Tor host, if we can guess it."),
1641 ITEM(
"address/v4", misc,
1642 "IPv4 address of this Tor host, if we can guess it."),
1643 ITEM(
"address/v6", misc,
1644 "IPv6 address of this Tor host, if we can guess it."),
1645 ITEM(
"traffic/read", misc,
"Bytes read since the process was started."),
1646 ITEM(
"traffic/written", misc,
1647 "Bytes written since the process was started."),
1648 ITEM(
"uptime", misc,
"Uptime of the Tor daemon in seconds."),
1649 ITEM(
"process/pid", misc,
"Process id belonging to the main tor process."),
1650 ITEM(
"process/uid", misc,
"User id running the tor process."),
1651 ITEM(
"process/user", misc,
1652 "Username under which the tor process is running."),
1653 ITEM(
"process/descriptor-limit", misc,
"File descriptor limit."),
1654 ITEM(
"limits/max-mem-in-queues", misc,
"Actual limit on memory in queues"),
1655 PREFIX(
"desc-annotations/id/", dir,
"Router annotations by hexdigest."),
1656 PREFIX(
"dir/server/", dir,
"Router descriptors as retrieved from a DirPort."),
1657 PREFIX(
"dir/status/", dir,
1658 "v2 networkstatus docs as retrieved from a DirPort."),
1659 ITEM(
"dir/status-vote/current/consensus", dir,
1660 "v3 Networkstatus consensus as retrieved from a DirPort."),
1661 ITEM(
"dir/status-vote/current/consensus-microdesc", dir,
1662 "v3 Microdescriptor consensus as retrieved from a DirPort."),
1663 ITEM(
"exit-policy/default", policies,
1664 "The default value appended to the configured exit policy."),
1665 ITEM(
"exit-policy/reject-private/default", policies,
1666 "The default rules appended to the configured exit policy by"
1667 " ExitPolicyRejectPrivate."),
1668 ITEM(
"exit-policy/reject-private/relay", policies,
1669 "The relay-specific rules appended to the configured exit policy by"
1670 " ExitPolicyRejectPrivate and/or ExitPolicyRejectLocalInterfaces."),
1671 ITEM(
"exit-policy/full", policies,
"The entire exit policy of onion router"),
1672 ITEM(
"exit-policy/ipv4", policies,
"IPv4 parts of exit policy"),
1673 ITEM(
"exit-policy/ipv6", policies,
"IPv6 parts of exit policy"),
1674 PREFIX(
"ip-to-country/", geoip,
"Perform a GEOIP lookup"),
1675 ITEM(
"onions/current", onions,
1676 "Onion services owned by the current control connection."),
1677 ITEM(
"onions/detached", onions,
1678 "Onion services detached from the control connection."),
1679 ITEM(
"sr/current", sr,
"Get current shared random value."),
1680 ITEM(
"sr/previous", sr,
"Get previous shared random value."),
1681 PREFIX(
"stats/ntor/", rephist,
"NTor circuit handshake stats."),
1682 ITEM(
"stats/ntor/assigned", rephist,
1683 "Assigned NTor circuit handshake stats."),
1684 ITEM(
"stats/ntor/requested", rephist,
1685 "Requested NTor circuit handshake stats."),
1686 PREFIX(
"stats/tap/", rephist,
"TAP circuit handshake stats."),
1687 ITEM(
"stats/tap/assigned", rephist,
1688 "Assigned TAP circuit handshake stats."),
1689 ITEM(
"stats/tap/requested", rephist,
1690 "Requested TAP circuit handshake stats."),
1691 { NULL, NULL, NULL, 0 }
1714 smartlist_free(lines);
1725 const char *question,
char **answer,
1726 const char **err_out)
1762 const char *errmsg = NULL;
1766 errmsg =
"Internal error";
1777 "Unrecognized key \"%s\"", q);
1783 } SMARTLIST_FOREACH_END(q);
1787 if (smartlist_len(unrecognized)) {
char * tor_addr_to_str_dup(const tor_addr_t *addr)
char * tor_sockaddr_to_str(const struct sockaddr *sa)
void addressmap_get_mappings(smartlist_t *sl, time_t min_expires, time_t max_expires, int want_expiry)
download_status_t * download_status_for_authority_id_and_sk(const char *id_digest, const char *sk_digest)
download_status_t * id_only_download_status_for_authority_id(const char *digest)
smartlist_t * list_authority_ids_with_downloads(void)
smartlist_t * list_sk_digests_for_authority_id(const char *digest)
Header file for authcert.c.
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
smartlist_t * list_bridge_identities(void)
download_status_t * get_bridge_dl_status_by_id(const char *digest)
Header file for circuitbuild.c.
Cached large directory object structure.
circuit_t * circuit_get_by_edge_conn(edge_connection_t *conn)
smartlist_t * circuit_get_global_list(void)
origin_circuit_t * TO_ORIGIN_CIRCUIT(circuit_t *x)
Header file for circuitlist.c.
#define CIRCUIT_STATE_OPEN
#define CIRCUIT_IS_ORIGIN(c)
#define CIRCUIT_STATE_GUARD_WAIT
const or_options_t * get_options(void)
char * options_dump(const or_options_t *options, int how_to_dump)
const char * get_torrc_fname(int defaults_fname)
Header file for config.c.
Header file for connection.c.
#define CONN_TYPE_AP_HTTP_CONNECT_LISTENER
#define CONN_TYPE_DIR_LISTENER
#define CONN_TYPE_OR_LISTENER
#define CONN_TYPE_METRICS_LISTENER
#define CONN_TYPE_CONTROL_LISTENER
#define CONN_TYPE_EXT_OR_LISTENER
#define CONN_TYPE_AP_NATD_LISTENER
#define CONN_TYPE_AP_LISTENER
#define CONN_TYPE_AP_DNS_LISTENER
#define CONN_TYPE_AP_TRANS_LISTENER
entry_connection_t * TO_ENTRY_CONN(connection_t *c)
Header file for connection_edge.c.
#define AP_CONN_STATE_CONTROLLER_WAIT
#define AP_CONN_STATE_SOCKS_WAIT
#define AP_CONN_STATE_CONNECT_WAIT
#define AP_CONN_STATE_OPEN
#define AP_CONN_STATE_RESOLVE_WAIT
#define AP_CONN_STATE_CIRCUIT_WAIT
#define AP_CONN_STATE_NATD_WAIT
#define AP_CONN_STATE_RENDDESC_WAIT
or_connection_t * TO_OR_CONN(connection_t *c)
Header file for connection_or.c.
Header file for control.c.
char * control_event_boot_last_msg(void)
smartlist_t * get_detached_onion_services(void)
Header file for control_cmd.c.
Definition for control_cmd_args_t.
Controller connection structure.
const struct control_event_t control_event_table[]
Header file for control_events.c.
char * circuit_describe_status_for_controller(origin_circuit_t *circ)
void orconn_target_get_name(char *name, size_t len, or_connection_t *conn)
int write_stream_target_to_buf(entry_connection_t *conn, char *buf, size_t len)
Header file for control_fmt.c.
static int getinfo_helper_misc(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
STATIC int getinfo_helper_rephist(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
STATIC void getinfo_helper_downloads_desc(const char *desc_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg)
static const getinfo_item_t getinfo_items[]
static int getinfo_helper_listeners(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
static int getinfo_helper_liveness(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
static char * digest_list_to_string(const smartlist_t *sl)
static int getinfo_helper_sr(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
STATIC int getinfo_helper_downloads(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
int handle_control_getinfo(control_connection_t *conn, const control_cmd_args_t *args)
static int getinfo_helper_events(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
static char * munge_extrainfo_into_routerinfo(const char *ri_body, const signed_descriptor_t *ri, const signed_descriptor_t *ei)
STATIC int getinfo_helper_current_time(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
STATIC void getinfo_helper_downloads_networkstatus(const char *flavor, download_status_t **dl_to_emit, const char **errmsg)
STATIC int getinfo_helper_dir(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
static int controller_get_routerdescs(smartlist_t *descs_out, const char *key, const char **msg)
static int handle_getinfo_helper(control_connection_t *control_conn, const char *question, char **answer, const char **err_out)
static char * download_status_to_string(const download_status_t *dl)
STATIC void getinfo_helper_downloads_bridge(const char *bridge_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg)
int(* getinfo_helper_t)(control_connection_t *, const char *q, char **a, const char **error_out)
STATIC int getinfo_helper_onions(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
STATIC int getinfo_helper_current_consensus(consensus_flavor_t flavor, char **answer, const char **errmsg)
static char * list_getinfo_options(void)
STATIC void getinfo_helper_downloads_cert(const char *fp_sk_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg)
void control_write_endreply(control_connection_t *conn, int code, const char *s)
Header file for control_proto.c.
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
int directories_have_accepted_server_descriptor(void)
Header file for dirclient.c.
int dir_split_resource_into_fingerprints(const char *resource, smartlist_t *fp_out, int *compressed_out, int flags)
Header file for directory.c.
cached_dir_t * dirserv_get_consensus(const char *flavor_name)
Header file for dirserv.c.
time_t download_status_get_next_attempt_at(const download_status_t *dls)
Header file for dlstatus.c.
Entry connection structure.
#define ENTRY_TO_EDGE_CONN(c)
Header file for circuitbuild.c.
char * esc_for_log(const char *s)
Header file for geoip_stats.c.
char * geoip_get_bridge_stats_controller(time_t)
Header for getinfo_geoip.c.
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)
Header file for hibernate.c.
const char * hs_cache_lookup_encoded_as_client(const ed25519_public_key_t *key)
Header file for hs_cache.c.
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)
char * hs_service_lookup_current_desc(const ed25519_public_key_t *pk)
int have_completed_a_circuit(void)
uint64_t get_bytes_read(void)
smartlist_t * get_connection_array(void)
uint64_t get_bytes_written(void)
Header file for mainloop.c.
int we_fetch_router_descriptors(const or_options_t *options)
int we_fetch_microdescriptors(const or_options_t *options)
Header file for microdesc.c.
Microdescriptor structure.
download_status_t * networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
smartlist_t * router_get_descriptor_digests(void)
const char * networkstatus_get_flavor_name(consensus_flavor_t flav)
int we_want_to_fetch_flavor(const or_options_t *options, int flavor)
download_status_t * networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
networkstatus_t * networkstatus_get_latest_consensus(void)
download_status_t * router_get_dl_status_by_descriptor_digest(const char *d)
download_status_t * networkstatus_get_dl_status_by_flavor_running(consensus_flavor_t flavor)
tor_mmap_t * networkstatus_map_cached_consensus(const char *flavorname)
Header file for networkstatus.c.
Networkstatus consensus/vote structure.
Node information structure.
const smartlist_t * nodelist_get_list(void)
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)
int router_have_minimum_dir_info(void)
Header file for nodelist.c.
Master header file for Tor-specific functionality.
#define ROUTER_MAX_AGE_TO_PUBLISH
#define OR_CONN_STATE_OPEN
Origin circuit structure.
Header file for policies.c.
int rep_hist_circbuilding_dormant(time_t now)
Header file for predict_ports.c.
int tor_asprintf(char **strp, const char *fmt,...)
bool relay_find_addr_to_publish(const or_options_t *options, int family, int flags, tor_addr_t *addr_out)
Header file for relay_find_addr.c.
int rep_hist_get_circuit_handshake_assigned(uint16_t type)
int rep_hist_get_circuit_handshake_requested(uint16_t type)
Header file for rephist.c.
extrainfo_t * router_get_my_extrainfo(void)
const routerinfo_t * router_get_my_routerinfo(void)
int router_extrainfo_digest_is_me(const char *digest)
int router_digest_is_me(const char *digest)
int router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e)
Header file for router.c.
Header file for routerinfo.c.
Router descriptor structure.
static routerlist_t * routerlist
routerlist_t * router_get_routerlist(void)
const routerinfo_t * router_get_by_id_digest(const char *digest)
const char * signed_descriptor_get_annotations(const signed_descriptor_t *desc)
signed_descriptor_t * router_get_by_descriptor_digest(const char *digest)
signed_descriptor_t * extrainfo_get_by_descriptor_digest(const char *digest)
const char * signed_descriptor_get_body(const signed_descriptor_t *desc)
Header file for routerlist.c.
Router descriptor list structure.
int server_mode(const or_options_t *options)
Header file for routermode.c.
int router_dirport_seems_reachable(const or_options_t *options)
Header file for selftest.c.
char * sr_get_previous_for_control(void)
char * sr_get_current_for_control(void)
Header file for shared_random_client.c.
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
void smartlist_sort_strings(smartlist_t *sl)
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
smartlist_t * smartlist_new(void)
void smartlist_add(smartlist_t *sl, void *element)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
int get_max_sockets(void)
Client request structure.
struct smartlist_t * args
smartlist_t * ephemeral_onion_services
download_want_authority_bitfield_t want_authority
download_schedule_increment_bitfield_t increment_on
uint8_t last_backoff_position
uint8_t n_download_attempts
uint8_t n_download_failures
download_schedule_bitfield_t schedule
socks_request_t * socks_request
uint32_t global_identifier
size_t signed_descriptor_len
void format_iso_time_nospace(char *buf, time_t t)
void format_iso_time(char *buf, time_t t)
void format_local_iso_time_nospace(char *buf, time_t t)
void tor_gettimeofday(struct timeval *timeval)
const char * get_version(void)
const struct passwd * tor_getpwuid(uid_t uid)
#define tor_fragile_assert()
int strcmpstart(const char *s1, const char *s2)
version_status_t tor_version_is_obsolete(const char *myversion, const char *versionlist)
Header file for versions.c.