Tor  0.4.5.0-alpha-dev
control_getinfo.c
Go to the documentation of this file.
1 /* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
2  * Copyright (c) 2007-2020, The Tor Project, Inc. */
3 /* See LICENSE for licensing information */
4 
5 /**
6  * \file control_getinfo.c
7  * \brief Implementation for miscellaneous controller getinfo commands.
8  */
9 
10 #define CONTROL_EVENTS_PRIVATE
11 #define CONTROL_MODULE_PRIVATE
12 #define CONTROL_GETINFO_PRIVATE
13 
14 #include "core/or/or.h"
15 #include "app/config/config.h"
17 #include "core/mainloop/mainloop.h"
18 #include "core/or/circuitlist.h"
20 #include "core/or/connection_or.h"
21 #include "core/or/policies.h"
22 #include "core/or/versions.h"
24 #include "feature/client/bridges.h"
30 #include "feature/control/control_getinfo.h"
39 #include "feature/hs/hs_cache.h"
48 #include "feature/relay/router.h"
50 #include "feature/relay/selftest.h"
51 #include "feature/rend/rendcache.h"
54 #include "feature/stats/rephist.h"
55 #include "lib/version/torversion.h"
56 #include "lib/encoding/kvline.h"
57 
71 
72 #ifdef HAVE_UNISTD_H
73 #include <unistd.h>
74 #endif
75 
76 #ifndef _WIN32
77 #include <pwd.h>
78 #endif
79 
80 static char *list_getinfo_options(void);
81 static char *download_status_to_string(const download_status_t *dl);
82 
83 /** Implementation helper for GETINFO: knows the answers for various
84  * trivial-to-implement questions. */
85 static int
86 getinfo_helper_misc(control_connection_t *conn, const char *question,
87  char **answer, const char **errmsg)
88 {
89  (void) conn;
90  if (!strcmp(question, "version")) {
91  *answer = tor_strdup(get_version());
92  } else if (!strcmp(question, "bw-event-cache")) {
93  *answer = get_bw_samples();
94  } else if (!strcmp(question, "config-file")) {
95  const char *a = get_torrc_fname(0);
96  if (a)
97  *answer = tor_strdup(a);
98  } else if (!strcmp(question, "config-defaults-file")) {
99  const char *a = get_torrc_fname(1);
100  if (a)
101  *answer = tor_strdup(a);
102  } else if (!strcmp(question, "config-text")) {
103  *answer = options_dump(get_options(), OPTIONS_DUMP_MINIMAL);
104  } else if (!strcmp(question, "config-can-saveconf")) {
105  *answer = tor_strdup(get_options()->IncludeUsed ? "0" : "1");
106  } else if (!strcmp(question, "info/names")) {
107  *answer = list_getinfo_options();
108  } else if (!strcmp(question, "dormant")) {
109  int dormant = rep_hist_circbuilding_dormant(time(NULL));
110  *answer = tor_strdup(dormant ? "1" : "0");
111  } else if (!strcmp(question, "events/names")) {
112  int i;
113  smartlist_t *event_names = smartlist_new();
114 
115  for (i = 0; control_event_table[i].event_name != NULL; ++i) {
116  smartlist_add(event_names, (char *)control_event_table[i].event_name);
117  }
118 
119  *answer = smartlist_join_strings(event_names, " ", 0, NULL);
120 
121  smartlist_free(event_names);
122  } else if (!strcmp(question, "signal/names")) {
123  smartlist_t *signal_names = smartlist_new();
124  int j;
125  for (j = 0; signal_table[j].signal_name != NULL; ++j) {
126  smartlist_add(signal_names, (char*)signal_table[j].signal_name);
127  }
128 
129  *answer = smartlist_join_strings(signal_names, " ", 0, NULL);
130 
131  smartlist_free(signal_names);
132  } else if (!strcmp(question, "features/names")) {
133  *answer = tor_strdup("VERBOSE_NAMES EXTENDED_EVENTS");
134  } else if (!strcmp(question, "address") || !strcmp(question, "address/v4")) {
135  tor_addr_t addr;
136  if (!relay_find_addr_to_publish(get_options(), AF_INET,
137  RELAY_FIND_ADDR_CACHE_ONLY, &addr)) {
138  *errmsg = "Address unknown";
139  return -1;
140  }
141  *answer = tor_addr_to_str_dup(&addr);
142  tor_assert_nonfatal(*answer);
143  } else if (!strcmp(question, "address/v6")) {
144  tor_addr_t addr;
145  if (!relay_find_addr_to_publish(get_options(), AF_INET6,
146  RELAY_FIND_ADDR_CACHE_ONLY, &addr)) {
147  *errmsg = "Address unknown";
148  return -1;
149  }
150  *answer = tor_addr_to_str_dup(&addr);
151  tor_assert_nonfatal(*answer);
152  } else if (!strcmp(question, "traffic/read")) {
153  tor_asprintf(answer, "%"PRIu64, (get_bytes_read()));
154  } else if (!strcmp(question, "traffic/written")) {
155  tor_asprintf(answer, "%"PRIu64, (get_bytes_written()));
156  } else if (!strcmp(question, "uptime")) {
157  long uptime_secs = get_uptime();
158  tor_asprintf(answer, "%ld", uptime_secs);
159  } else if (!strcmp(question, "process/pid")) {
160  int myPid = -1;
161 
162 #ifdef _WIN32
163  myPid = _getpid();
164 #else
165  myPid = getpid();
166 #endif
167 
168  tor_asprintf(answer, "%d", myPid);
169  } else if (!strcmp(question, "process/uid")) {
170 #ifdef _WIN32
171  *answer = tor_strdup("-1");
172 #else
173  int myUid = geteuid();
174  tor_asprintf(answer, "%d", myUid);
175 #endif /* defined(_WIN32) */
176  } else if (!strcmp(question, "process/user")) {
177 #ifdef _WIN32
178  *answer = tor_strdup("");
179 #else
180  int myUid = geteuid();
181  const struct passwd *myPwEntry = tor_getpwuid(myUid);
182 
183  if (myPwEntry) {
184  *answer = tor_strdup(myPwEntry->pw_name);
185  } else {
186  *answer = tor_strdup("");
187  }
188 #endif /* defined(_WIN32) */
189  } else if (!strcmp(question, "process/descriptor-limit")) {
190  int max_fds = get_max_sockets();
191  tor_asprintf(answer, "%d", max_fds);
192  } else if (!strcmp(question, "limits/max-mem-in-queues")) {
193  tor_asprintf(answer, "%"PRIu64,
194  (get_options()->MaxMemInQueues));
195  } else if (!strcmp(question, "fingerprint")) {
196  crypto_pk_t *server_key;
197  if (!server_mode(get_options())) {
198  *errmsg = "Not running in server mode";
199  return -1;
200  }
201  server_key = get_server_identity_key();
202  *answer = tor_malloc(HEX_DIGEST_LEN+1);
203  crypto_pk_get_fingerprint(server_key, *answer, 0);
204  }
205  return 0;
206 }
207 
208 /** Awful hack: return a newly allocated string based on a routerinfo and
209  * (possibly) an extrainfo, sticking the read-history and write-history from
210  * <b>ei</b> into the resulting string. The thing you get back won't
211  * necessarily have a valid signature.
212  *
213  * New code should never use this; it's for backward compatibility.
214  *
215  * NOTE: <b>ri_body</b> is as returned by signed_descriptor_get_body: it might
216  * not be NUL-terminated. */
217 static char *
219  const signed_descriptor_t *ri,
220  const signed_descriptor_t *ei)
221 {
222  char *out = NULL, *outp;
223  int i;
224  const char *router_sig;
225  const char *ei_body = signed_descriptor_get_body(ei);
226  size_t ri_len = ri->signed_descriptor_len;
227  size_t ei_len = ei->signed_descriptor_len;
228  if (!ei_body)
229  goto bail;
230 
231  outp = out = tor_malloc(ri_len+ei_len+1);
232  if (!(router_sig = tor_memstr(ri_body, ri_len, "\nrouter-signature")))
233  goto bail;
234  ++router_sig;
235  memcpy(out, ri_body, router_sig-ri_body);
236  outp += router_sig-ri_body;
237 
238  for (i=0; i < 2; ++i) {
239  const char *kwd = i ? "\nwrite-history " : "\nread-history ";
240  const char *cp, *eol;
241  if (!(cp = tor_memstr(ei_body, ei_len, kwd)))
242  continue;
243  ++cp;
244  if (!(eol = memchr(cp, '\n', ei_len - (cp-ei_body))))
245  continue;
246  memcpy(outp, cp, eol-cp+1);
247  outp += eol-cp+1;
248  }
249  memcpy(outp, router_sig, ri_len - (router_sig-ri_body));
250  *outp++ = '\0';
251  tor_assert(outp-out < (int)(ri_len+ei_len+1));
252 
253  return out;
254  bail:
255  tor_free(out);
256  return tor_strndup(ri_body, ri->signed_descriptor_len);
257 }
258 
259 /** Implementation helper for GETINFO: answers requests for information about
260  * which ports are bound. */
261 static int
263  const char *question,
264  char **answer, const char **errmsg)
265 {
266  int type;
267  smartlist_t *res;
268 
269  (void)control_conn;
270  (void)errmsg;
271 
272  if (!strcmp(question, "net/listeners/or"))
273  type = CONN_TYPE_OR_LISTENER;
274  else if (!strcmp(question, "net/listeners/extor"))
276  else if (!strcmp(question, "net/listeners/dir"))
277  type = CONN_TYPE_DIR_LISTENER;
278  else if (!strcmp(question, "net/listeners/socks"))
279  type = CONN_TYPE_AP_LISTENER;
280  else if (!strcmp(question, "net/listeners/trans"))
282  else if (!strcmp(question, "net/listeners/natd"))
284  else if (!strcmp(question, "net/listeners/httptunnel"))
286  else if (!strcmp(question, "net/listeners/dns"))
288  else if (!strcmp(question, "net/listeners/control"))
290  else
291  return 0; /* unknown key */
292 
293  res = smartlist_new();
295  struct sockaddr_storage ss;
296  socklen_t ss_len = sizeof(ss);
297 
298  if (conn->type != type || conn->marked_for_close || !SOCKET_OK(conn->s))
299  continue;
300 
301  if (getsockname(conn->s, (struct sockaddr *)&ss, &ss_len) < 0) {
302  smartlist_add_asprintf(res, "%s:%d", conn->address, (int)conn->port);
303  } else {
304  char *tmp = tor_sockaddr_to_str((struct sockaddr *)&ss);
305  smartlist_add(res, esc_for_log(tmp));
306  tor_free(tmp);
307  }
308 
309  } SMARTLIST_FOREACH_END(conn);
310 
311  *answer = smartlist_join_strings(res, " ", 0, NULL);
312 
313  SMARTLIST_FOREACH(res, char *, cp, tor_free(cp));
314  smartlist_free(res);
315  return 0;
316 }
317 
318 /** Implementation helper for GETINFO: answers requests for information about
319  * the current time in both local and UTC forms. */
320 STATIC int
322  const char *question,
323  char **answer, const char **errmsg)
324 {
325  (void)control_conn;
326  (void)errmsg;
327 
328  struct timeval now;
329  tor_gettimeofday(&now);
330  char timebuf[ISO_TIME_LEN+1];
331 
332  if (!strcmp(question, "current-time/local"))
333  format_local_iso_time_nospace(timebuf, (time_t)now.tv_sec);
334  else if (!strcmp(question, "current-time/utc"))
335  format_iso_time_nospace(timebuf, (time_t)now.tv_sec);
336  else
337  return 0;
338 
339  *answer = tor_strdup(timebuf);
340  return 0;
341 }
342 
343 /** GETINFO helper for dumping different consensus flavors
344  * returns: 0 on success -1 on error. */
345 STATIC int
347  char** answer,
348  const char** errmsg)
349 {
350  const char *flavor_name = networkstatus_get_flavor_name(flavor);
351  if (BUG(!strcmp(flavor_name, "??"))) {
352  *errmsg = "Internal error: unrecognized flavor name.";
353  return -1;
354  }
355  if (we_want_to_fetch_flavor(get_options(), flavor)) {
356  /** Check from the cache */
357  const cached_dir_t *consensus = dirserv_get_consensus(flavor_name);
358  if (consensus) {
359  *answer = tor_strdup(consensus->dir);
360  }
361  }
362  if (!*answer) { /* try loading it from disk */
363 
364  tor_mmap_t *mapped = networkstatus_map_cached_consensus(flavor_name);
365  if (mapped) {
366  *answer = tor_memdup_nulterm(mapped->data, mapped->size);
367  tor_munmap_file(mapped);
368  }
369  if (!*answer) { /* generate an error */
370  *errmsg = "Could not open cached consensus. "
371  "Make sure FetchUselessDescriptors is set to 1.";
372  return -1;
373  }
374  }
375  return 0;
376 }
377 
378 /** Helper for getinfo_helper_dir.
379  *
380  * Add a signed_descriptor_t to <b>descs_out</b> for each router matching
381  * <b>key</b>. The key should be either
382  * - "/tor/server/authority" for our own routerinfo;
383  * - "/tor/server/all" for all the routerinfos we have, concatenated;
384  * - "/tor/server/fp/FP" where FP is a plus-separated sequence of
385  * hex identity digests; or
386  * - "/tor/server/d/D" where D is a plus-separated sequence
387  * of server descriptor digests, in hex.
388  *
389  * Return 0 if we found some matching descriptors, or -1 if we do not
390  * have any descriptors, no matching descriptors, or if we did not
391  * recognize the key (URL).
392  * If -1 is returned *<b>msg</b> will be set to an appropriate error
393  * message.
394  */
395 static int
396 controller_get_routerdescs(smartlist_t *descs_out, const char *key,
397  const char **msg)
398 {
399  *msg = NULL;
400 
401  if (!strcmp(key, "/tor/server/all")) {
404  smartlist_add(descs_out, &(r->cache_info)));
405  } else if (!strcmp(key, "/tor/server/authority")) {
407  if (ri)
408  smartlist_add(descs_out, (void*) &(ri->cache_info));
409  } else if (!strcmpstart(key, "/tor/server/d/")) {
410  smartlist_t *digests = smartlist_new();
411  key += strlen("/tor/server/d/");
412  dir_split_resource_into_fingerprints(key, digests, NULL,
413  DSR_HEX|DSR_SORT_UNIQ);
414  SMARTLIST_FOREACH(digests, const char *, d,
415  {
417  if (sd)
418  smartlist_add(descs_out,sd);
419  });
420  SMARTLIST_FOREACH(digests, char *, d, tor_free(d));
421  smartlist_free(digests);
422  } else if (!strcmpstart(key, "/tor/server/fp/")) {
423  smartlist_t *digests = smartlist_new();
424  time_t cutoff = time(NULL) - ROUTER_MAX_AGE_TO_PUBLISH;
425  key += strlen("/tor/server/fp/");
426  dir_split_resource_into_fingerprints(key, digests, NULL,
427  DSR_HEX|DSR_SORT_UNIQ);
428  SMARTLIST_FOREACH_BEGIN(digests, const char *, d) {
429  if (router_digest_is_me(d)) {
430  /* calling router_get_my_routerinfo() to make sure it exists */
432  if (ri)
433  smartlist_add(descs_out, (void*) &(ri->cache_info));
434  } else {
435  const routerinfo_t *ri = router_get_by_id_digest(d);
436  /* Don't actually serve a descriptor that everyone will think is
437  * expired. This is an (ugly) workaround to keep buggy 0.1.1.10
438  * Tors from downloading descriptors that they will throw away.
439  */
440  if (ri && ri->cache_info.published_on > cutoff)
441  smartlist_add(descs_out, (void*) &(ri->cache_info));
442  }
443  } SMARTLIST_FOREACH_END(d);
444  SMARTLIST_FOREACH(digests, char *, d, tor_free(d));
445  smartlist_free(digests);
446  } else {
447  *msg = "Key not recognized";
448  return -1;
449  }
450 
451  if (!smartlist_len(descs_out)) {
452  *msg = "Servers unavailable";
453  return -1;
454  }
455  return 0;
456 }
457 
458 /** Implementation helper for GETINFO: knows the answers for questions about
459  * directory information. */
460 STATIC int
462  const char *question, char **answer,
463  const char **errmsg)
464 {
465  (void) control_conn;
466  if (!strcmpstart(question, "desc/id/")) {
467  const routerinfo_t *ri = NULL;
468  const node_t *node = node_get_by_hex_id(question+strlen("desc/id/"), 0);
469  if (node)
470  ri = node->ri;
471  if (ri) {
472  const char *body = signed_descriptor_get_body(&ri->cache_info);
473  if (body)
474  *answer = tor_strndup(body, ri->cache_info.signed_descriptor_len);
475  } else if (! we_fetch_router_descriptors(get_options())) {
476  /* Descriptors won't be available, provide proper error */
477  *errmsg = "We fetch microdescriptors, not router "
478  "descriptors. You'll need to use md/id/* "
479  "instead of desc/id/*.";
480  return 0;
481  }
482  } else if (!strcmpstart(question, "desc/name/")) {
483  const routerinfo_t *ri = NULL;
484  /* XXX Setting 'warn_if_unnamed' here is a bit silly -- the
485  * warning goes to the user, not to the controller. */
486  const node_t *node =
487  node_get_by_nickname(question+strlen("desc/name/"), 0);
488  if (node)
489  ri = node->ri;
490  if (ri) {
491  const char *body = signed_descriptor_get_body(&ri->cache_info);
492  if (body)
493  *answer = tor_strndup(body, ri->cache_info.signed_descriptor_len);
494  } else if (! we_fetch_router_descriptors(get_options())) {
495  /* Descriptors won't be available, provide proper error */
496  *errmsg = "We fetch microdescriptors, not router "
497  "descriptors. You'll need to use md/name/* "
498  "instead of desc/name/*.";
499  return 0;
500  }
501  } else if (!strcmp(question, "desc/download-enabled")) {
503  tor_asprintf(answer, "%d", !!r);
504  } else if (!strcmp(question, "desc/all-recent")) {
506  smartlist_t *sl = smartlist_new();
507  if (routerlist && routerlist->routers) {
509  {
510  const char *body = signed_descriptor_get_body(&ri->cache_info);
511  if (body)
512  smartlist_add(sl,
513  tor_strndup(body, ri->cache_info.signed_descriptor_len));
514  });
515  }
516  *answer = smartlist_join_strings(sl, "", 0, NULL);
517  SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
518  smartlist_free(sl);
519  } else if (!strcmp(question, "desc/all-recent-extrainfo-hack")) {
520  /* XXXX Remove this once Torstat asks for extrainfos. */
522  smartlist_t *sl = smartlist_new();
523  if (routerlist && routerlist->routers) {
525  const char *body = signed_descriptor_get_body(&ri->cache_info);
527  ri->cache_info.extra_info_digest);
528  if (ei && body) {
530  &ri->cache_info, ei));
531  } else if (body) {
532  smartlist_add(sl,
533  tor_strndup(body, ri->cache_info.signed_descriptor_len));
534  }
535  } SMARTLIST_FOREACH_END(ri);
536  }
537  *answer = smartlist_join_strings(sl, "", 0, NULL);
538  SMARTLIST_FOREACH(sl, char *, c, tor_free(c));
539  smartlist_free(sl);
540  } else if (!strcmpstart(question, "hs/client/desc/id/")) {
541  hostname_type_t addr_type;
542 
543  question += strlen("hs/client/desc/id/");
544  if (rend_valid_v2_service_id(question)) {
545  addr_type = ONION_V2_HOSTNAME;
546  } else if (hs_address_is_valid(question)) {
547  addr_type = ONION_V3_HOSTNAME;
548  } else {
549  *errmsg = "Invalid address";
550  return -1;
551  }
552 
553  if (addr_type == ONION_V2_HOSTNAME) {
554  rend_cache_entry_t *e = NULL;
555  if (!rend_cache_lookup_entry(question, -1, &e)) {
556  /* Descriptor found in cache */
557  *answer = tor_strdup(e->desc);
558  } else {
559  *errmsg = "Not found in cache";
560  return -1;
561  }
562  } else {
563  ed25519_public_key_t service_pk;
564  const char *desc;
565 
566  /* The check before this if/else makes sure of this. */
567  tor_assert(addr_type == ONION_V3_HOSTNAME);
568 
569  if (hs_parse_address(question, &service_pk, NULL, NULL) < 0) {
570  *errmsg = "Invalid v3 address";
571  return -1;
572  }
573 
574  desc = hs_cache_lookup_encoded_as_client(&service_pk);
575  if (desc) {
576  *answer = tor_strdup(desc);
577  } else {
578  *errmsg = "Not found in cache";
579  return -1;
580  }
581  }
582  } else if (!strcmpstart(question, "hs/service/desc/id/")) {
583  hostname_type_t addr_type;
584 
585  question += strlen("hs/service/desc/id/");
586  if (rend_valid_v2_service_id(question)) {
587  addr_type = ONION_V2_HOSTNAME;
588  } else if (hs_address_is_valid(question)) {
589  addr_type = ONION_V3_HOSTNAME;
590  } else {
591  *errmsg = "Invalid address";
592  return -1;
593  }
594  rend_cache_entry_t *e = NULL;
595 
596  if (addr_type == ONION_V2_HOSTNAME) {
597  if (!rend_cache_lookup_v2_desc_as_service(question, &e)) {
598  /* Descriptor found in cache */
599  *answer = tor_strdup(e->desc);
600  } else {
601  *errmsg = "Not found in cache";
602  return -1;
603  }
604  } else {
605  ed25519_public_key_t service_pk;
606  char *desc;
607 
608  /* The check before this if/else makes sure of this. */
609  tor_assert(addr_type == ONION_V3_HOSTNAME);
610 
611  if (hs_parse_address(question, &service_pk, NULL, NULL) < 0) {
612  *errmsg = "Invalid v3 address";
613  return -1;
614  }
615 
616  desc = hs_service_lookup_current_desc(&service_pk);
617  if (desc) {
618  /* Newly allocated string, we have ownership. */
619  *answer = desc;
620  } else {
621  *errmsg = "Not found in cache";
622  return -1;
623  }
624  }
625  } else if (!strcmp(question, "md/all")) {
626  const smartlist_t *nodes = nodelist_get_list();
627  tor_assert(nodes);
628 
629  if (smartlist_len(nodes) == 0) {
630  *answer = tor_strdup("");
631  return 0;
632  }
633 
634  smartlist_t *microdescs = smartlist_new();
635 
636  SMARTLIST_FOREACH_BEGIN(nodes, node_t *, n) {
637  if (n->md && n->md->body) {
638  char *copy = tor_strndup(n->md->body, n->md->bodylen);
639  smartlist_add(microdescs, copy);
640  }
641  } SMARTLIST_FOREACH_END(n);
642 
643  *answer = smartlist_join_strings(microdescs, "", 0, NULL);
644  SMARTLIST_FOREACH(microdescs, char *, md, tor_free(md));
645  smartlist_free(microdescs);
646  } else if (!strcmpstart(question, "md/id/")) {
647  const node_t *node = node_get_by_hex_id(question+strlen("md/id/"), 0);
648  const microdesc_t *md = NULL;
649  if (node) md = node->md;
650  if (md && md->body) {
651  *answer = tor_strndup(md->body, md->bodylen);
652  }
653  } else if (!strcmpstart(question, "md/name/")) {
654  /* XXX Setting 'warn_if_unnamed' here is a bit silly -- the
655  * warning goes to the user, not to the controller. */
656  const node_t *node = node_get_by_nickname(question+strlen("md/name/"), 0);
657  /* XXXX duplicated code */
658  const microdesc_t *md = NULL;
659  if (node) md = node->md;
660  if (md && md->body) {
661  *answer = tor_strndup(md->body, md->bodylen);
662  }
663  } else if (!strcmp(question, "md/download-enabled")) {
665  tor_asprintf(answer, "%d", !!r);
666  } else if (!strcmpstart(question, "desc-annotations/id/")) {
667  const routerinfo_t *ri = NULL;
668  const node_t *node =
669  node_get_by_hex_id(question+strlen("desc-annotations/id/"), 0);
670  if (node)
671  ri = node->ri;
672  if (ri) {
673  const char *annotations =
674  signed_descriptor_get_annotations(&ri->cache_info);
675  if (annotations)
676  *answer = tor_strndup(annotations,
677  ri->cache_info.annotations_len);
678  }
679  } else if (!strcmpstart(question, "dir/server/")) {
680  size_t answer_len = 0;
681  char *url = NULL;
682  smartlist_t *descs = smartlist_new();
683  const char *msg;
684  int res;
685  char *cp;
686  tor_asprintf(&url, "/tor/%s", question+4);
687  res = controller_get_routerdescs(descs, url, &msg);
688  if (res) {
689  log_warn(LD_CONTROL, "getinfo '%s': %s", question, msg);
690  smartlist_free(descs);
691  tor_free(url);
692  *errmsg = msg;
693  return -1;
694  }
696  answer_len += sd->signed_descriptor_len);
697  cp = *answer = tor_malloc(answer_len+1);
699  {
700  memcpy(cp, signed_descriptor_get_body(sd),
701  sd->signed_descriptor_len);
702  cp += sd->signed_descriptor_len;
703  });
704  *cp = '\0';
705  tor_free(url);
706  smartlist_free(descs);
707  } else if (!strcmpstart(question, "dir/status/")) {
708  *answer = tor_strdup("");
709  } else if (!strcmp(question, "dir/status-vote/current/consensus")) {
710  int consensus_result = getinfo_helper_current_consensus(FLAV_NS,
711  answer, errmsg);
712  if (consensus_result < 0) {
713  return -1;
714  }
715  } else if (!strcmp(question,
716  "dir/status-vote/current/consensus-microdesc")) {
717  int consensus_result = getinfo_helper_current_consensus(FLAV_MICRODESC,
718  answer, errmsg);
719  if (consensus_result < 0) {
720  return -1;
721  }
722  } else if (!strcmp(question, "network-status")) { /* v1 */
723  static int network_status_warned = 0;
724  if (!network_status_warned) {
725  log_warn(LD_CONTROL, "GETINFO network-status is deprecated; it will "
726  "go away in a future version of Tor.");
727  network_status_warned = 1;
728  }
730  if (!routerlist || !routerlist->routers ||
731  list_server_status_v1(routerlist->routers, answer, 1) < 0) {
732  return -1;
733  }
734  } else if (!strcmpstart(question, "extra-info/digest/")) {
735  question += strlen("extra-info/digest/");
736  if (strlen(question) == HEX_DIGEST_LEN) {
737  char d[DIGEST_LEN];
738  signed_descriptor_t *sd = NULL;
739  if (base16_decode(d, sizeof(d), question, strlen(question))
740  == sizeof(d)) {
741  /* XXXX this test should move into extrainfo_get_by_descriptor_digest,
742  * but I don't want to risk affecting other parts of the code,
743  * especially since the rules for using our own extrainfo (including
744  * when it might be freed) are different from those for using one
745  * we have downloaded. */
747  sd = &(router_get_my_extrainfo()->cache_info);
748  else
750  }
751  if (sd) {
752  const char *body = signed_descriptor_get_body(sd);
753  if (body)
754  *answer = tor_strndup(body, sd->signed_descriptor_len);
755  }
756  }
757  }
758 
759  return 0;
760 }
761 
762 /** Given a smartlist of 20-byte digests, return a newly allocated string
763  * containing each of those digests in order, formatted in HEX, and terminated
764  * with a newline. */
765 static char *
767 {
768  int len;
769  char *result, *s;
770 
771  /* Allow for newlines, and a \0 at the end */
772  len = smartlist_len(sl) * (HEX_DIGEST_LEN + 1) + 1;
773  result = tor_malloc_zero(len);
774 
775  s = result;
776  SMARTLIST_FOREACH_BEGIN(sl, const char *, digest) {
777  base16_encode(s, HEX_DIGEST_LEN + 1, digest, DIGEST_LEN);
778  s[HEX_DIGEST_LEN] = '\n';
779  s += HEX_DIGEST_LEN + 1;
780  } SMARTLIST_FOREACH_END(digest);
781  *s = '\0';
782 
783  return result;
784 }
785 
786 /** Turn a download_status_t into a human-readable description in a newly
787  * allocated string. The format is specified in control-spec.txt, under
788  * the documentation for "GETINFO download/..." . */
789 static char *
791 {
792  char *rv = NULL;
793  char tbuf[ISO_TIME_LEN+1];
794  const char *schedule_str, *want_authority_str;
795  const char *increment_on_str, *backoff_str;
796 
797  if (dl) {
798  /* Get some substrings of the eventual output ready */
800 
801  switch (dl->schedule) {
802  case DL_SCHED_GENERIC:
803  schedule_str = "DL_SCHED_GENERIC";
804  break;
805  case DL_SCHED_CONSENSUS:
806  schedule_str = "DL_SCHED_CONSENSUS";
807  break;
808  case DL_SCHED_BRIDGE:
809  schedule_str = "DL_SCHED_BRIDGE";
810  break;
811  default:
812  schedule_str = "unknown";
813  break;
814  }
815 
816  switch (dl->want_authority) {
817  case DL_WANT_ANY_DIRSERVER:
818  want_authority_str = "DL_WANT_ANY_DIRSERVER";
819  break;
820  case DL_WANT_AUTHORITY:
821  want_authority_str = "DL_WANT_AUTHORITY";
822  break;
823  default:
824  want_authority_str = "unknown";
825  break;
826  }
827 
828  switch (dl->increment_on) {
829  case DL_SCHED_INCREMENT_FAILURE:
830  increment_on_str = "DL_SCHED_INCREMENT_FAILURE";
831  break;
832  case DL_SCHED_INCREMENT_ATTEMPT:
833  increment_on_str = "DL_SCHED_INCREMENT_ATTEMPT";
834  break;
835  default:
836  increment_on_str = "unknown";
837  break;
838  }
839 
840  backoff_str = "DL_SCHED_RANDOM_EXPONENTIAL";
841 
842  /* Now assemble them */
843  tor_asprintf(&rv,
844  "next-attempt-at %s\n"
845  "n-download-failures %u\n"
846  "n-download-attempts %u\n"
847  "schedule %s\n"
848  "want-authority %s\n"
849  "increment-on %s\n"
850  "backoff %s\n"
851  "last-backoff-position %u\n"
852  "last-delay-used %d\n",
853  tbuf,
856  schedule_str,
857  want_authority_str,
858  increment_on_str,
859  backoff_str,
861  dl->last_delay_used);
862  }
863 
864  return rv;
865 }
866 
867 /** Handle the consensus download cases for getinfo_helper_downloads() */
868 STATIC void
870  download_status_t **dl_to_emit,
871  const char **errmsg)
872 {
873  /*
874  * We get the one for the current bootstrapped status by default, or
875  * take an extra /bootstrap or /running suffix
876  */
877  if (strcmp(flavor, "ns") == 0) {
878  *dl_to_emit = networkstatus_get_dl_status_by_flavor(FLAV_NS);
879  } else if (strcmp(flavor, "ns/bootstrap") == 0) {
881  } else if (strcmp(flavor, "ns/running") == 0 ) {
882  *dl_to_emit = networkstatus_get_dl_status_by_flavor_running(FLAV_NS);
883  } else if (strcmp(flavor, "microdesc") == 0) {
884  *dl_to_emit = networkstatus_get_dl_status_by_flavor(FLAV_MICRODESC);
885  } else if (strcmp(flavor, "microdesc/bootstrap") == 0) {
886  *dl_to_emit =
888  } else if (strcmp(flavor, "microdesc/running") == 0) {
889  *dl_to_emit =
891  } else {
892  *errmsg = "Unknown flavor";
893  }
894 }
895 
896 /** Handle the cert download cases for getinfo_helper_downloads() */
897 STATIC void
898 getinfo_helper_downloads_cert(const char *fp_sk_req,
899  download_status_t **dl_to_emit,
900  smartlist_t **digest_list,
901  const char **errmsg)
902 {
903  const char *sk_req;
904  char id_digest[DIGEST_LEN];
905  char sk_digest[DIGEST_LEN];
906 
907  /*
908  * We have to handle four cases; fp_sk_req is the request with
909  * a prefix of "downloads/cert/" snipped off.
910  *
911  * Case 1: fp_sk_req = "fps"
912  * - We should emit a digest_list with a list of all the identity
913  * fingerprints that can be queried for certificate download status;
914  * get it by calling list_authority_ids_with_downloads().
915  *
916  * Case 2: fp_sk_req = "fp/<fp>" for some fingerprint fp
917  * - We want the default certificate for this identity fingerprint's
918  * download status; this is the download we get from URLs starting
919  * in /fp/ on the directory server. We can get it with
920  * id_only_download_status_for_authority_id().
921  *
922  * Case 3: fp_sk_req = "fp/<fp>/sks" for some fingerprint fp
923  * - We want a list of all signing key digests for this identity
924  * fingerprint which can be queried for certificate download status.
925  * Get it with list_sk_digests_for_authority_id().
926  *
927  * Case 4: fp_sk_req = "fp/<fp>/<sk>" for some fingerprint fp and
928  * signing key digest sk
929  * - We want the download status for the certificate for this specific
930  * signing key and fingerprint. These correspond to the ones we get
931  * from URLs starting in /fp-sk/ on the directory server. Get it with
932  * list_sk_digests_for_authority_id().
933  */
934 
935  if (strcmp(fp_sk_req, "fps") == 0) {
936  *digest_list = list_authority_ids_with_downloads();
937  if (!(*digest_list)) {
938  *errmsg = "Failed to get list of authority identity digests (!)";
939  }
940  } else if (!strcmpstart(fp_sk_req, "fp/")) {
941  fp_sk_req += strlen("fp/");
942  /* Okay, look for another / to tell the fp from fp-sk cases */
943  sk_req = strchr(fp_sk_req, '/');
944  if (sk_req) {
945  /* okay, split it here and try to parse <fp> */
946  if (base16_decode(id_digest, DIGEST_LEN,
947  fp_sk_req, sk_req - fp_sk_req) == DIGEST_LEN) {
948  /* Skip past the '/' */
949  ++sk_req;
950  if (strcmp(sk_req, "sks") == 0) {
951  /* We're asking for the list of signing key fingerprints */
952  *digest_list = list_sk_digests_for_authority_id(id_digest);
953  if (!(*digest_list)) {
954  *errmsg = "Failed to get list of signing key digests for this "
955  "authority identity digest";
956  }
957  } else {
958  /* We've got a signing key digest */
959  if (base16_decode(sk_digest, DIGEST_LEN,
960  sk_req, strlen(sk_req)) == DIGEST_LEN) {
961  *dl_to_emit =
962  download_status_for_authority_id_and_sk(id_digest, sk_digest);
963  if (!(*dl_to_emit)) {
964  *errmsg = "Failed to get download status for this identity/"
965  "signing key digest pair";
966  }
967  } else {
968  *errmsg = "That didn't look like a signing key digest";
969  }
970  }
971  } else {
972  *errmsg = "That didn't look like an identity digest";
973  }
974  } else {
975  /* We're either in downloads/certs/fp/<fp>, or we can't parse <fp> */
976  if (strlen(fp_sk_req) == HEX_DIGEST_LEN) {
977  if (base16_decode(id_digest, DIGEST_LEN,
978  fp_sk_req, strlen(fp_sk_req)) == DIGEST_LEN) {
979  *dl_to_emit = id_only_download_status_for_authority_id(id_digest);
980  if (!(*dl_to_emit)) {
981  *errmsg = "Failed to get download status for this authority "
982  "identity digest";
983  }
984  } else {
985  *errmsg = "That didn't look like a digest";
986  }
987  } else {
988  *errmsg = "That didn't look like a digest";
989  }
990  }
991  } else {
992  *errmsg = "Unknown certificate download status query";
993  }
994 }
995 
996 /** Handle the routerdesc download cases for getinfo_helper_downloads() */
997 STATIC void
998 getinfo_helper_downloads_desc(const char *desc_req,
999  download_status_t **dl_to_emit,
1000  smartlist_t **digest_list,
1001  const char **errmsg)
1002 {
1003  char desc_digest[DIGEST_LEN];
1004  /*
1005  * Two cases to handle here:
1006  *
1007  * Case 1: desc_req = "descs"
1008  * - Emit a list of all router descriptor digests, which we get by
1009  * calling router_get_descriptor_digests(); this can return NULL
1010  * if we have no current ns-flavor consensus.
1011  *
1012  * Case 2: desc_req = <fp>
1013  * - Check on the specified fingerprint and emit its download_status_t
1014  * using router_get_dl_status_by_descriptor_digest().
1015  */
1016 
1017  if (strcmp(desc_req, "descs") == 0) {
1018  *digest_list = router_get_descriptor_digests();
1019  if (!(*digest_list)) {
1020  *errmsg = "We don't seem to have a networkstatus-flavored consensus";
1021  }
1022  /*
1023  * Microdescs don't use the download_status_t mechanism, so we don't
1024  * answer queries about their downloads here; see microdesc.c.
1025  */
1026  } else if (strlen(desc_req) == HEX_DIGEST_LEN) {
1027  if (base16_decode(desc_digest, DIGEST_LEN,
1028  desc_req, strlen(desc_req)) == DIGEST_LEN) {
1029  /* Okay we got a digest-shaped thing; try asking for it */
1030  *dl_to_emit = router_get_dl_status_by_descriptor_digest(desc_digest);
1031  if (!(*dl_to_emit)) {
1032  *errmsg = "No such descriptor digest found";
1033  }
1034  } else {
1035  *errmsg = "That didn't look like a digest";
1036  }
1037  } else {
1038  *errmsg = "Unknown router descriptor download status query";
1039  }
1040 }
1041 
1042 /** Handle the bridge download cases for getinfo_helper_downloads() */
1043 STATIC void
1044 getinfo_helper_downloads_bridge(const char *bridge_req,
1045  download_status_t **dl_to_emit,
1046  smartlist_t **digest_list,
1047  const char **errmsg)
1048 {
1049  char bridge_digest[DIGEST_LEN];
1050  /*
1051  * Two cases to handle here:
1052  *
1053  * Case 1: bridge_req = "bridges"
1054  * - Emit a list of all bridge identity digests, which we get by
1055  * calling list_bridge_identities(); this can return NULL if we are
1056  * not using bridges.
1057  *
1058  * Case 2: bridge_req = <fp>
1059  * - Check on the specified fingerprint and emit its download_status_t
1060  * using get_bridge_dl_status_by_id().
1061  */
1062 
1063  if (strcmp(bridge_req, "bridges") == 0) {
1064  *digest_list = list_bridge_identities();
1065  if (!(*digest_list)) {
1066  *errmsg = "We don't seem to be using bridges";
1067  }
1068  } else if (strlen(bridge_req) == HEX_DIGEST_LEN) {
1069  if (base16_decode(bridge_digest, DIGEST_LEN,
1070  bridge_req, strlen(bridge_req)) == DIGEST_LEN) {
1071  /* Okay we got a digest-shaped thing; try asking for it */
1072  *dl_to_emit = get_bridge_dl_status_by_id(bridge_digest);
1073  if (!(*dl_to_emit)) {
1074  *errmsg = "No such bridge identity digest found";
1075  }
1076  } else {
1077  *errmsg = "That didn't look like a digest";
1078  }
1079  } else {
1080  *errmsg = "Unknown bridge descriptor download status query";
1081  }
1082 }
1083 
1084 /** Implementation helper for GETINFO: knows the answers for questions about
1085  * download status information. */
1086 STATIC int
1088  const char *question, char **answer,
1089  const char **errmsg)
1090 {
1091  download_status_t *dl_to_emit = NULL;
1092  smartlist_t *digest_list = NULL;
1093 
1094  /* Assert args are sane */
1095  tor_assert(control_conn != NULL);
1096  tor_assert(question != NULL);
1097  tor_assert(answer != NULL);
1098  tor_assert(errmsg != NULL);
1099 
1100  /* We check for this later to see if we should supply a default */
1101  *errmsg = NULL;
1102 
1103  /* Are we after networkstatus downloads? */
1104  if (!strcmpstart(question, "downloads/networkstatus/")) {
1106  question + strlen("downloads/networkstatus/"),
1107  &dl_to_emit, errmsg);
1108  /* Certificates? */
1109  } else if (!strcmpstart(question, "downloads/cert/")) {
1111  question + strlen("downloads/cert/"),
1112  &dl_to_emit, &digest_list, errmsg);
1113  /* Router descriptors? */
1114  } else if (!strcmpstart(question, "downloads/desc/")) {
1116  question + strlen("downloads/desc/"),
1117  &dl_to_emit, &digest_list, errmsg);
1118  /* Bridge descriptors? */
1119  } else if (!strcmpstart(question, "downloads/bridge/")) {
1121  question + strlen("downloads/bridge/"),
1122  &dl_to_emit, &digest_list, errmsg);
1123  } else {
1124  *errmsg = "Unknown download status query";
1125  }
1126 
1127  if (dl_to_emit) {
1128  *answer = download_status_to_string(dl_to_emit);
1129 
1130  return 0;
1131  } else if (digest_list) {
1132  *answer = digest_list_to_string(digest_list);
1133  SMARTLIST_FOREACH(digest_list, void *, s, tor_free(s));
1134  smartlist_free(digest_list);
1135 
1136  return 0;
1137  } else {
1138  if (!(*errmsg)) {
1139  *errmsg = "Unknown error";
1140  }
1141 
1142  return -1;
1143  }
1144 }
1145 
1146 /** Implementation helper for GETINFO: knows how to generate summaries of the
1147  * current states of things we send events about. */
1148 static int
1150  const char *question, char **answer,
1151  const char **errmsg)
1152 {
1153  const or_options_t *options = get_options();
1154  (void) control_conn;
1155  if (!strcmp(question, "circuit-status")) {
1156  smartlist_t *status = smartlist_new();
1158  origin_circuit_t *circ;
1159  char *circdesc;
1160  const char *state;
1161  if (! CIRCUIT_IS_ORIGIN(circ_) || circ_->marked_for_close)
1162  continue;
1163  circ = TO_ORIGIN_CIRCUIT(circ_);
1164 
1165  if (circ->base_.state == CIRCUIT_STATE_OPEN)
1166  state = "BUILT";
1167  else if (circ->base_.state == CIRCUIT_STATE_GUARD_WAIT)
1168  state = "GUARD_WAIT";
1169  else if (circ->cpath)
1170  state = "EXTENDED";
1171  else
1172  state = "LAUNCHED";
1173 
1174  circdesc = circuit_describe_status_for_controller(circ);
1175 
1176  smartlist_add_asprintf(status, "%lu %s%s%s",
1177  (unsigned long)circ->global_identifier,
1178  state, *circdesc ? " " : "", circdesc);
1179  tor_free(circdesc);
1180  }
1181  SMARTLIST_FOREACH_END(circ_);
1182  *answer = smartlist_join_strings(status, "\r\n", 0, NULL);
1183  SMARTLIST_FOREACH(status, char *, cp, tor_free(cp));
1184  smartlist_free(status);
1185  } else if (!strcmp(question, "stream-status")) {
1186  smartlist_t *conns = get_connection_array();
1187  smartlist_t *status = smartlist_new();
1188  char buf[256];
1189  SMARTLIST_FOREACH_BEGIN(conns, connection_t *, base_conn) {
1190  const char *state;
1191  entry_connection_t *conn;
1192  circuit_t *circ;
1193  origin_circuit_t *origin_circ = NULL;
1194  if (base_conn->type != CONN_TYPE_AP ||
1195  base_conn->marked_for_close ||
1196  base_conn->state == AP_CONN_STATE_SOCKS_WAIT ||
1197  base_conn->state == AP_CONN_STATE_NATD_WAIT)
1198  continue;
1199  conn = TO_ENTRY_CONN(base_conn);
1200  switch (base_conn->state)
1201  {
1204  if (conn->socks_request &&
1205  SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command))
1206  state = "NEWRESOLVE";
1207  else
1208  state = "NEW";
1209  break;
1212  state = "SENTCONNECT"; break;
1214  state = "SENTRESOLVE"; break;
1215  case AP_CONN_STATE_OPEN:
1216  state = "SUCCEEDED"; break;
1217  default:
1218  log_warn(LD_BUG, "Asked for stream in unknown state %d",
1219  base_conn->state);
1220  continue;
1221  }
1223  if (circ && CIRCUIT_IS_ORIGIN(circ))
1224  origin_circ = TO_ORIGIN_CIRCUIT(circ);
1225  write_stream_target_to_buf(conn, buf, sizeof(buf));
1226  smartlist_add_asprintf(status, "%lu %s %lu %s",
1227  (unsigned long) base_conn->global_identifier,state,
1228  origin_circ?
1229  (unsigned long)origin_circ->global_identifier : 0ul,
1230  buf);
1231  } SMARTLIST_FOREACH_END(base_conn);
1232  *answer = smartlist_join_strings(status, "\r\n", 0, NULL);
1233  SMARTLIST_FOREACH(status, char *, cp, tor_free(cp));
1234  smartlist_free(status);
1235  } else if (!strcmp(question, "orconn-status")) {
1236  smartlist_t *conns = get_connection_array();
1237  smartlist_t *status = smartlist_new();
1238  SMARTLIST_FOREACH_BEGIN(conns, connection_t *, base_conn) {
1239  const char *state;
1240  char name[128];
1241  or_connection_t *conn;
1242  if (base_conn->type != CONN_TYPE_OR || base_conn->marked_for_close)
1243  continue;
1244  conn = TO_OR_CONN(base_conn);
1245  if (conn->base_.state == OR_CONN_STATE_OPEN)
1246  state = "CONNECTED";
1247  else if (conn->nickname)
1248  state = "LAUNCHED";
1249  else
1250  state = "NEW";
1251  orconn_target_get_name(name, sizeof(name), conn);
1252  smartlist_add_asprintf(status, "%s %s", name, state);
1253  } SMARTLIST_FOREACH_END(base_conn);
1254  *answer = smartlist_join_strings(status, "\r\n", 0, NULL);
1255  SMARTLIST_FOREACH(status, char *, cp, tor_free(cp));
1256  smartlist_free(status);
1257  } else if (!strcmpstart(question, "address-mappings/")) {
1258  time_t min_e, max_e;
1259  smartlist_t *mappings;
1260  question += strlen("address-mappings/");
1261  if (!strcmp(question, "all")) {
1262  min_e = 0; max_e = TIME_MAX;
1263  } else if (!strcmp(question, "cache")) {
1264  min_e = 2; max_e = TIME_MAX;
1265  } else if (!strcmp(question, "config")) {
1266  min_e = 0; max_e = 0;
1267  } else if (!strcmp(question, "control")) {
1268  min_e = 1; max_e = 1;
1269  } else {
1270  return 0;
1271  }
1272  mappings = smartlist_new();
1273  addressmap_get_mappings(mappings, min_e, max_e, 1);
1274  *answer = smartlist_join_strings(mappings, "\r\n", 0, NULL);
1275  SMARTLIST_FOREACH(mappings, char *, cp, tor_free(cp));
1276  smartlist_free(mappings);
1277  } else if (!strcmpstart(question, "status/")) {
1278  /* Note that status/ is not a catch-all for events; there's only supposed
1279  * to be a status GETINFO if there's a corresponding STATUS event. */
1280  if (!strcmp(question, "status/circuit-established")) {
1281  *answer = tor_strdup(have_completed_a_circuit() ? "1" : "0");
1282  } else if (!strcmp(question, "status/enough-dir-info")) {
1283  *answer = tor_strdup(router_have_minimum_dir_info() ? "1" : "0");
1284  } else if (!strcmp(question, "status/good-server-descriptor") ||
1285  !strcmp(question, "status/accepted-server-descriptor")) {
1286  /* They're equivalent for now, until we can figure out how to make
1287  * good-server-descriptor be what we want. See comment in
1288  * control-spec.txt. */
1289  *answer = tor_strdup(directories_have_accepted_server_descriptor()
1290  ? "1" : "0");
1291  } else if (!strcmp(question, "status/reachability-succeeded/or")) {
1292  *answer = tor_strdup(
1293  router_all_orports_seem_reachable(options) ?
1294  "1" : "0");
1295  } else if (!strcmp(question, "status/reachability-succeeded/dir")) {
1296  *answer = tor_strdup(
1298  "1" : "0");
1299  } else if (!strcmp(question, "status/reachability-succeeded")) {
1300  tor_asprintf(
1301  answer, "OR=%d DIR=%d",
1302  router_all_orports_seem_reachable(options) ? 1 : 0,
1303  router_dirport_seems_reachable(options) ? 1 : 0);
1304  } else if (!strcmp(question, "status/bootstrap-phase")) {
1305  *answer = control_event_boot_last_msg();
1306  } else if (!strcmpstart(question, "status/version/")) {
1307  int is_server = server_mode(options);
1309  version_status_t status;
1310  const char *recommended;
1311  if (c) {
1312  recommended = is_server ? c->server_versions : c->client_versions;
1313  status = tor_version_is_obsolete(VERSION, recommended);
1314  } else {
1315  recommended = "?";
1316  status = VS_UNKNOWN;
1317  }
1318 
1319  if (!strcmp(question, "status/version/recommended")) {
1320  *answer = tor_strdup(recommended);
1321  return 0;
1322  }
1323  if (!strcmp(question, "status/version/current")) {
1324  switch (status)
1325  {
1326  case VS_RECOMMENDED: *answer = tor_strdup("recommended"); break;
1327  case VS_OLD: *answer = tor_strdup("obsolete"); break;
1328  case VS_NEW: *answer = tor_strdup("new"); break;
1329  case VS_NEW_IN_SERIES: *answer = tor_strdup("new in series"); break;
1330  case VS_UNRECOMMENDED: *answer = tor_strdup("unrecommended"); break;
1331  case VS_EMPTY: *answer = tor_strdup("none recommended"); break;
1332  case VS_UNKNOWN: *answer = tor_strdup("unknown"); break;
1333  default: tor_fragile_assert();
1334  }
1335  }
1336  } else if (!strcmp(question, "status/clients-seen")) {
1337  char *bridge_stats = geoip_get_bridge_stats_controller(time(NULL));
1338  if (!bridge_stats) {
1339  *errmsg = "No bridge-client stats available";
1340  return -1;
1341  }
1342  *answer = bridge_stats;
1343  } else if (!strcmp(question, "status/fresh-relay-descs")) {
1344  if (!server_mode(options)) {
1345  *errmsg = "Only relays have descriptors";
1346  return -1;
1347  }
1348  routerinfo_t *r;
1349  extrainfo_t *e;
1350  int result;
1351  if ((result = router_build_fresh_descriptor(&r, &e)) < 0) {
1352  switch (result) {
1353  case TOR_ROUTERINFO_ERROR_NO_EXT_ADDR:
1354  *errmsg = "Cannot get relay address while generating descriptor";
1355  break;
1356  case TOR_ROUTERINFO_ERROR_DIGEST_FAILED:
1357  *errmsg = "Key digest failed";
1358  break;
1359  case TOR_ROUTERINFO_ERROR_CANNOT_GENERATE:
1360  *errmsg = "Cannot generate router descriptor";
1361  break;
1362  default:
1363  *errmsg = "Error generating descriptor";
1364  break;
1365  }
1366  return -1;
1367  }
1368  size_t size = r->cache_info.signed_descriptor_len + 1;
1369  if (e) {
1370  size += e->cache_info.signed_descriptor_len + 1;
1371  }
1372  tor_assert(r->cache_info.signed_descriptor_len);
1373  char *descs = tor_malloc(size);
1374  char *cp = descs;
1375  memcpy(cp, signed_descriptor_get_body(&r->cache_info),
1376  r->cache_info.signed_descriptor_len);
1377  cp += r->cache_info.signed_descriptor_len - 1;
1378  if (e) {
1379  if (cp[0] == '\0') {
1380  cp[0] = '\n';
1381  } else if (cp[0] != '\n') {
1382  cp[1] = '\n';
1383  cp++;
1384  }
1385  memcpy(cp, signed_descriptor_get_body(&e->cache_info),
1386  e->cache_info.signed_descriptor_len);
1387  cp += e->cache_info.signed_descriptor_len - 1;
1388  }
1389  if (cp[0] == '\n') {
1390  cp[0] = '\0';
1391  } else if (cp[0] != '\0') {
1392  cp[1] = '\0';
1393  }
1394  *answer = descs;
1395  routerinfo_free(r);
1396  extrainfo_free(e);
1397  } else {
1398  return 0;
1399  }
1400  }
1401  return 0;
1402 }
1403 
1404 /** Implementation helper for GETINFO: knows how to enumerate hidden services
1405  * created via the control port. */
1406 STATIC int
1408  const char *question, char **answer,
1409  const char **errmsg)
1410 {
1411  smartlist_t *onion_list = NULL;
1412  (void) errmsg; /* no errors from this method */
1413 
1414  if (control_conn && !strcmp(question, "onions/current")) {
1415  onion_list = control_conn->ephemeral_onion_services;
1416  } else if (!strcmp(question, "onions/detached")) {
1417  onion_list = get_detached_onion_services();
1418  } else {
1419  return 0;
1420  }
1421  if (!onion_list || smartlist_len(onion_list) == 0) {
1422  if (answer) {
1423  *answer = tor_strdup("");
1424  }
1425  } else {
1426  if (answer) {
1427  *answer = smartlist_join_strings(onion_list, "\r\n", 0, NULL);
1428  }
1429  }
1430 
1431  return 0;
1432 }
1433 
1434 /** Implementation helper for GETINFO: answers queries about network
1435  * liveness. */
1436 static int
1438  const char *question, char **answer,
1439  const char **errmsg)
1440 {
1441  (void)control_conn;
1442  (void)errmsg;
1443  if (strcmp(question, "network-liveness") == 0) {
1444  if (get_cached_network_liveness()) {
1445  *answer = tor_strdup("up");
1446  } else {
1447  *answer = tor_strdup("down");
1448  }
1449  }
1450 
1451  return 0;
1452 }
1453 
1454 /** Implementation helper for GETINFO: answers queries about circuit onion
1455  * handshake rephist values */
1456 STATIC int
1458  const char *question, char **answer,
1459  const char **errmsg)
1460 {
1461  (void) control_conn;
1462  (void) errmsg;
1463  int result;
1464 
1465  if (!strcmp(question, "stats/ntor/assigned")) {
1466  result =
1467  rep_hist_get_circuit_handshake_assigned(ONION_HANDSHAKE_TYPE_NTOR);
1468  } else if (!strcmp(question, "stats/ntor/requested")) {
1469  result =
1470  rep_hist_get_circuit_handshake_requested(ONION_HANDSHAKE_TYPE_NTOR);
1471  } else if (!strcmp(question, "stats/tap/assigned")) {
1472  result =
1473  rep_hist_get_circuit_handshake_assigned(ONION_HANDSHAKE_TYPE_TAP);
1474  } else if (!strcmp(question, "stats/tap/requested")) {
1475  result =
1476  rep_hist_get_circuit_handshake_requested(ONION_HANDSHAKE_TYPE_TAP);
1477  } else {
1478  *errmsg = "Unrecognized handshake type";
1479  return -1;
1480  }
1481 
1482  tor_asprintf(answer, "%d", result);
1483 
1484  return 0;
1485 }
1486 
1487 /** Implementation helper for GETINFO: answers queries about shared random
1488  * value. */
1489 static int
1491  const char *question, char **answer,
1492  const char **errmsg)
1493 {
1494  (void) control_conn;
1495  (void) errmsg;
1496 
1497  if (!strcmp(question, "sr/current")) {
1498  *answer = sr_get_current_for_control();
1499  } else if (!strcmp(question, "sr/previous")) {
1500  *answer = sr_get_previous_for_control();
1501  }
1502  /* Else statement here is unrecognized key so do nothing. */
1503 
1504  return 0;
1505 }
1506 
1507 /** Callback function for GETINFO: on a given control connection, try to
1508  * answer the question <b>q</b> and store the newly-allocated answer in
1509  * *<b>a</b>. If an internal error occurs, return -1 and optionally set
1510  * *<b>error_out</b> to point to an error message to be delivered to the
1511  * controller. On success, _or if the key is not recognized_, return 0. Do not
1512  * set <b>a</b> if the key is not recognized but you may set <b>error_out</b>
1513  * to improve the error message.
1514  */
1516  const char *q, char **a,
1517  const char **error_out);
1518 
1519 /** A single item for the GETINFO question-to-answer-function table. */
1520 typedef struct getinfo_item_t {
1521  const char *varname; /**< The value (or prefix) of the question. */
1522  getinfo_helper_t fn; /**< The function that knows the answer: NULL if
1523  * this entry is documentation-only. */
1524  const char *desc; /**< Description of the variable. */
1525  int is_prefix; /** Must varname match exactly, or must it be a prefix? */
1526 } getinfo_item_t;
1527 
1528 #define ITEM(name, fn, desc) { name, getinfo_helper_##fn, desc, 0 }
1529 #define PREFIX(name, fn, desc) { name, getinfo_helper_##fn, desc, 1 }
1530 #define DOC(name, desc) { name, NULL, desc, 0 }
1531 
1532 /** Table mapping questions accepted by GETINFO to the functions that know how
1533  * to answer them. */
1534 static const getinfo_item_t getinfo_items[] = {
1535  ITEM("version", misc, "The current version of Tor."),
1536  ITEM("bw-event-cache", misc, "Cached BW events for a short interval."),
1537  ITEM("config-file", misc, "Current location of the \"torrc\" file."),
1538  ITEM("config-defaults-file", misc, "Current location of the defaults file."),
1539  ITEM("config-text", misc,
1540  "Return the string that would be written by a saveconf command."),
1541  ITEM("config-can-saveconf", misc,
1542  "Is it possible to save the configuration to the \"torrc\" file?"),
1543  ITEM("accounting/bytes", accounting,
1544  "Number of bytes read/written so far in the accounting interval."),
1545  ITEM("accounting/bytes-left", accounting,
1546  "Number of bytes left to write/read so far in the accounting interval."),
1547  ITEM("accounting/enabled", accounting, "Is accounting currently enabled?"),
1548  ITEM("accounting/hibernating", accounting, "Are we hibernating or awake?"),
1549  ITEM("accounting/interval-start", accounting,
1550  "Time when the accounting period starts."),
1551  ITEM("accounting/interval-end", accounting,
1552  "Time when the accounting period ends."),
1553  ITEM("accounting/interval-wake", accounting,
1554  "Time to wake up in this accounting period."),
1555  ITEM("helper-nodes", entry_guards, NULL), /* deprecated */
1556  ITEM("entry-guards", entry_guards,
1557  "Which nodes are we using as entry guards?"),
1558  ITEM("fingerprint", misc, NULL),
1559  PREFIX("config/", config, "Current configuration values."),
1560  DOC("config/names",
1561  "List of configuration options, types, and documentation."),
1562  DOC("config/defaults",
1563  "List of default values for configuration options. "
1564  "See also config/names"),
1565  PREFIX("current-time/", current_time, "Current time."),
1566  DOC("current-time/local", "Current time on the local system."),
1567  DOC("current-time/utc", "Current UTC time."),
1568  PREFIX("downloads/networkstatus/", downloads,
1569  "Download statuses for networkstatus objects"),
1570  DOC("downloads/networkstatus/ns",
1571  "Download status for current-mode networkstatus download"),
1572  DOC("downloads/networkstatus/ns/bootstrap",
1573  "Download status for bootstrap-time networkstatus download"),
1574  DOC("downloads/networkstatus/ns/running",
1575  "Download status for run-time networkstatus download"),
1576  DOC("downloads/networkstatus/microdesc",
1577  "Download status for current-mode microdesc download"),
1578  DOC("downloads/networkstatus/microdesc/bootstrap",
1579  "Download status for bootstrap-time microdesc download"),
1580  DOC("downloads/networkstatus/microdesc/running",
1581  "Download status for run-time microdesc download"),
1582  PREFIX("downloads/cert/", downloads,
1583  "Download statuses for certificates, by id fingerprint and "
1584  "signing key"),
1585  DOC("downloads/cert/fps",
1586  "List of authority fingerprints for which any download statuses "
1587  "exist"),
1588  DOC("downloads/cert/fp/<fp>",
1589  "Download status for <fp> with the default signing key; corresponds "
1590  "to /fp/ URLs on directory server."),
1591  DOC("downloads/cert/fp/<fp>/sks",
1592  "List of signing keys for which specific download statuses are "
1593  "available for this id fingerprint"),
1594  DOC("downloads/cert/fp/<fp>/<sk>",
1595  "Download status for <fp> with signing key <sk>; corresponds "
1596  "to /fp-sk/ URLs on directory server."),
1597  PREFIX("downloads/desc/", downloads,
1598  "Download statuses for router descriptors, by descriptor digest"),
1599  DOC("downloads/desc/descs",
1600  "Return a list of known router descriptor digests"),
1601  DOC("downloads/desc/<desc>",
1602  "Return a download status for a given descriptor digest"),
1603  PREFIX("downloads/bridge/", downloads,
1604  "Download statuses for bridge descriptors, by bridge identity "
1605  "digest"),
1606  DOC("downloads/bridge/bridges",
1607  "Return a list of configured bridge identity digests with download "
1608  "statuses"),
1609  DOC("downloads/bridge/<desc>",
1610  "Return a download status for a given bridge identity digest"),
1611  ITEM("info/names", misc,
1612  "List of GETINFO options, types, and documentation."),
1613  ITEM("events/names", misc,
1614  "Events that the controller can ask for with SETEVENTS."),
1615  ITEM("signal/names", misc, "Signal names recognized by the SIGNAL command"),
1616  ITEM("features/names", misc, "What arguments can USEFEATURE take?"),
1617  PREFIX("desc/id/", dir, "Router descriptors by ID."),
1618  PREFIX("desc/name/", dir, "Router descriptors by nickname."),
1619  ITEM("desc/all-recent", dir,
1620  "All non-expired, non-superseded router descriptors."),
1621  ITEM("desc/download-enabled", dir,
1622  "Do we try to download router descriptors?"),
1623  ITEM("desc/all-recent-extrainfo-hack", dir, NULL), /* Hack. */
1624  ITEM("md/all", dir, "All known microdescriptors."),
1625  PREFIX("md/id/", dir, "Microdescriptors by ID"),
1626  PREFIX("md/name/", dir, "Microdescriptors by name"),
1627  ITEM("md/download-enabled", dir,
1628  "Do we try to download microdescriptors?"),
1629  PREFIX("extra-info/digest/", dir, "Extra-info documents by digest."),
1630  PREFIX("hs/client/desc/id", dir,
1631  "Hidden Service descriptor in client's cache by onion."),
1632  PREFIX("hs/service/desc/id/", dir,
1633  "Hidden Service descriptor in services's cache by onion."),
1634  PREFIX("net/listeners/", listeners, "Bound addresses by type"),
1635  ITEM("ns/all", networkstatus,
1636  "Brief summary of router status (v2 directory format)"),
1637  PREFIX("ns/id/", networkstatus,
1638  "Brief summary of router status by ID (v2 directory format)."),
1639  PREFIX("ns/name/", networkstatus,
1640  "Brief summary of router status by nickname (v2 directory format)."),
1641  PREFIX("ns/purpose/", networkstatus,
1642  "Brief summary of router status by purpose (v2 directory format)."),
1643  PREFIX("consensus/", networkstatus,
1644  "Information about and from the ns consensus."),
1645  ITEM("network-status", dir,
1646  "Brief summary of router status (v1 directory format)"),
1647  ITEM("network-liveness", liveness,
1648  "Current opinion on whether the network is live"),
1649  ITEM("circuit-status", events, "List of current circuits originating here."),
1650  ITEM("stream-status", events,"List of current streams."),
1651  ITEM("orconn-status", events, "A list of current OR connections."),
1652  ITEM("dormant", misc,
1653  "Is Tor dormant (not building circuits because it's idle)?"),
1654  PREFIX("address-mappings/", events, NULL),
1655  DOC("address-mappings/all", "Current address mappings."),
1656  DOC("address-mappings/cache", "Current cached DNS replies."),
1657  DOC("address-mappings/config",
1658  "Current address mappings from configuration."),
1659  DOC("address-mappings/control", "Current address mappings from controller."),
1660  PREFIX("status/", events, NULL),
1661  DOC("status/circuit-established",
1662  "Whether we think client functionality is working."),
1663  DOC("status/enough-dir-info",
1664  "Whether we have enough up-to-date directory information to build "
1665  "circuits."),
1666  DOC("status/bootstrap-phase",
1667  "The last bootstrap phase status event that Tor sent."),
1668  DOC("status/clients-seen",
1669  "Breakdown of client countries seen by a bridge."),
1670  DOC("status/fresh-relay-descs",
1671  "A fresh relay/ei descriptor pair for Tor's current state. Not stored."),
1672  DOC("status/version/recommended", "List of currently recommended versions."),
1673  DOC("status/version/current", "Status of the current version."),
1674  ITEM("address", misc, "IP address of this Tor host, if we can guess it."),
1675  ITEM("address/v4", misc,
1676  "IPv4 address of this Tor host, if we can guess it."),
1677  ITEM("address/v6", misc,
1678  "IPv6 address of this Tor host, if we can guess it."),
1679  ITEM("traffic/read", misc,"Bytes read since the process was started."),
1680  ITEM("traffic/written", misc,
1681  "Bytes written since the process was started."),
1682  ITEM("uptime", misc, "Uptime of the Tor daemon in seconds."),
1683  ITEM("process/pid", misc, "Process id belonging to the main tor process."),
1684  ITEM("process/uid", misc, "User id running the tor process."),
1685  ITEM("process/user", misc,
1686  "Username under which the tor process is running."),
1687  ITEM("process/descriptor-limit", misc, "File descriptor limit."),
1688  ITEM("limits/max-mem-in-queues", misc, "Actual limit on memory in queues"),
1689  PREFIX("desc-annotations/id/", dir, "Router annotations by hexdigest."),
1690  PREFIX("dir/server/", dir,"Router descriptors as retrieved from a DirPort."),
1691  PREFIX("dir/status/", dir,
1692  "v2 networkstatus docs as retrieved from a DirPort."),
1693  ITEM("dir/status-vote/current/consensus", dir,
1694  "v3 Networkstatus consensus as retrieved from a DirPort."),
1695  ITEM("dir/status-vote/current/consensus-microdesc", dir,
1696  "v3 Microdescriptor consensus as retrieved from a DirPort."),
1697  ITEM("exit-policy/default", policies,
1698  "The default value appended to the configured exit policy."),
1699  ITEM("exit-policy/reject-private/default", policies,
1700  "The default rules appended to the configured exit policy by"
1701  " ExitPolicyRejectPrivate."),
1702  ITEM("exit-policy/reject-private/relay", policies,
1703  "The relay-specific rules appended to the configured exit policy by"
1704  " ExitPolicyRejectPrivate and/or ExitPolicyRejectLocalInterfaces."),
1705  ITEM("exit-policy/full", policies, "The entire exit policy of onion router"),
1706  ITEM("exit-policy/ipv4", policies, "IPv4 parts of exit policy"),
1707  ITEM("exit-policy/ipv6", policies, "IPv6 parts of exit policy"),
1708  PREFIX("ip-to-country/", geoip, "Perform a GEOIP lookup"),
1709  ITEM("onions/current", onions,
1710  "Onion services owned by the current control connection."),
1711  ITEM("onions/detached", onions,
1712  "Onion services detached from the control connection."),
1713  ITEM("sr/current", sr, "Get current shared random value."),
1714  ITEM("sr/previous", sr, "Get previous shared random value."),
1715  PREFIX("stats/ntor/", rephist, "NTor circuit handshake stats."),
1716  ITEM("stats/ntor/assigned", rephist,
1717  "Assigned NTor circuit handshake stats."),
1718  ITEM("stats/ntor/requested", rephist,
1719  "Requested NTor circuit handshake stats."),
1720  PREFIX("stats/tap/", rephist, "TAP circuit handshake stats."),
1721  ITEM("stats/tap/assigned", rephist,
1722  "Assigned TAP circuit handshake stats."),
1723  ITEM("stats/tap/requested", rephist,
1724  "Requested TAP circuit handshake stats."),
1725  { NULL, NULL, NULL, 0 }
1726 };
1727 
1728 /** Allocate and return a list of recognized GETINFO options. */
1729 static char *
1731 {
1732  int i;
1733  smartlist_t *lines = smartlist_new();
1734  char *ans;
1735  for (i = 0; getinfo_items[i].varname; ++i) {
1736  if (!getinfo_items[i].desc)
1737  continue;
1738 
1739  smartlist_add_asprintf(lines, "%s%s -- %s\n",
1740  getinfo_items[i].varname,
1741  getinfo_items[i].is_prefix ? "*" : "",
1742  getinfo_items[i].desc);
1743  }
1744  smartlist_sort_strings(lines);
1745 
1746  ans = smartlist_join_strings(lines, "", 0, NULL);
1747  SMARTLIST_FOREACH(lines, char *, cp, tor_free(cp));
1748  smartlist_free(lines);
1749 
1750  return ans;
1751 }
1752 
1753 /** Lookup the 'getinfo' entry <b>question</b>, and return
1754  * the answer in <b>*answer</b> (or NULL if key not recognized).
1755  * Return 0 if success or unrecognized, or -1 if recognized but
1756  * internal error. */
1757 static int
1759  const char *question, char **answer,
1760  const char **err_out)
1761 {
1762  int i;
1763  *answer = NULL; /* unrecognized key by default */
1764 
1765  for (i = 0; getinfo_items[i].varname; ++i) {
1766  int match;
1767  if (getinfo_items[i].is_prefix)
1768  match = !strcmpstart(question, getinfo_items[i].varname);
1769  else
1770  match = !strcmp(question, getinfo_items[i].varname);
1771  if (match) {
1772  tor_assert(getinfo_items[i].fn);
1773  return getinfo_items[i].fn(control_conn, question, answer, err_out);
1774  }
1775  }
1776 
1777  return 0; /* unrecognized */
1778 }
1779 
1780 const control_cmd_syntax_t getinfo_syntax = {
1781  .max_args = UINT_MAX,
1782 };
1783 
1784 /** Called when we receive a GETINFO command. Try to fetch all requested
1785  * information, and reply with information or error message. */
1786 int
1788  const control_cmd_args_t *args)
1789 {
1790  const smartlist_t *questions = args->args;
1791  smartlist_t *answers = smartlist_new();
1792  smartlist_t *unrecognized = smartlist_new();
1793  char *ans = NULL;
1794 
1795  SMARTLIST_FOREACH_BEGIN(questions, const char *, q) {
1796  const char *errmsg = NULL;
1797 
1798  if (handle_getinfo_helper(conn, q, &ans, &errmsg) < 0) {
1799  if (!errmsg)
1800  errmsg = "Internal error";
1801  control_write_endreply(conn, 551, errmsg);
1802  goto done;
1803  }
1804  if (!ans) {
1805  if (errmsg) {
1806  /* use provided error message */
1807  control_reply_add_str(unrecognized, 552, errmsg);
1808  } else {
1809  /* use default error message */
1810  control_reply_add_printf(unrecognized, 552,
1811  "Unrecognized key \"%s\"", q);
1812  }
1813  } else {
1814  control_reply_add_one_kv(answers, 250, KV_RAW, q, ans);
1815  tor_free(ans);
1816  }
1817  } SMARTLIST_FOREACH_END(q);
1818 
1819  control_reply_add_done(answers);
1820 
1821  if (smartlist_len(unrecognized)) {
1822  control_write_reply_lines(conn, unrecognized);
1823  /* If there were any unrecognized queries, don't write real answers */
1824  goto done;
1825  }
1826 
1827  control_write_reply_lines(conn, answers);
1828 
1829  done:
1830  control_reply_free(answers);
1831  control_reply_free(unrecognized);
1832 
1833  return 0;
1834 }
microdesc_t
Definition: microdesc_st.h:27
networkstatus_get_flavor_name
const char * networkstatus_get_flavor_name(consensus_flavor_t flav)
Definition: networkstatus.c:2577
selftest.h
Header file for selftest.c.
routermode.h
Header file for routermode.c.
control_reply_add_one_kv
void control_reply_add_one_kv(smartlist_t *reply, int code, int flags, const char *key, const char *val)
Definition: control_proto.c:338
tor_free
#define tor_free(p)
Definition: malloc.h:52
routerinfo_t
Definition: routerinfo_st.h:20
connection_edge.h
Header file for connection_edge.c.
versions.h
Header file for versions.c.
getinfo_item_t
Definition: control_getinfo.c:1520
CIRCUIT_STATE_OPEN
#define CIRCUIT_STATE_OPEN
Definition: circuitlist.h:32
routerinfo.h
Header file for routerinfo.c.
name
const char * name
Definition: config.c:2444
rend_cache_entry_t
Definition: rendcache.h:29
circuit_describe_status_for_controller
char * circuit_describe_status_for_controller(origin_circuit_t *circ)
Definition: control_fmt.c:73
control_cmd_args_t
Definition: control_cmd_args_st.h:24
entry_connection_st.h
Entry connection structure.
options_dump
char * options_dump(const or_options_t *options, int how_to_dump)
Definition: config.c:2905
we_want_to_fetch_flavor
int we_want_to_fetch_flavor(const or_options_t *options, int flavor)
Definition: networkstatus.c:862
tor_addr_t
Definition: address.h:69
control_connection_t::ephemeral_onion_services
smartlist_t * ephemeral_onion_services
Definition: control_connection_st.h:33
VS_NEW
@ VS_NEW
Definition: versions.h:20
extrainfo_t
Definition: extrainfo_st.h:18
circuit_get_global_list
smartlist_t * circuit_get_global_list(void)
Definition: circuitlist.c:696
tor_version_is_obsolete
version_status_t tor_version_is_obsolete(const char *myversion, const char *versionlist)
Definition: versions.c:53
get_bytes_read
uint64_t get_bytes_read(void)
Definition: mainloop.c:465
format_iso_time_nospace
void format_iso_time_nospace(char *buf, time_t t)
Definition: time_fmt.c:313
getinfo_helper_downloads
STATIC int getinfo_helper_downloads(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:1087
AP_CONN_STATE_CIRCUIT_WAIT
#define AP_CONN_STATE_CIRCUIT_WAIT
Definition: connection_edge.h:49
tor_assert
#define tor_assert(expr)
Definition: util_bug.h:102
control.h
Header file for control.c.
relay_find_addr.h
Header file for relay_find_addr.c.
microdesc.h
Header file for microdesc.c.
LD_BUG
#define LD_BUG
Definition: log.h:86
handle_getinfo_helper
static int handle_getinfo_helper(control_connection_t *control_conn, const char *question, char **answer, const char **err_out)
Definition: control_getinfo.c:1758
router.h
Header file for router.c.
getinfo_helper_dir
STATIC int getinfo_helper_dir(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:461
authcert.h
Header file for authcert.c.
format_iso_time
void format_iso_time(char *buf, time_t t)
Definition: time_fmt.c:295
router_digest_is_me
int router_digest_is_me(const char *digest)
Definition: router.c:1698
CONN_TYPE_AP_TRANS_LISTENER
#define CONN_TYPE_AP_TRANS_LISTENER
Definition: connection.h:63
AP_CONN_STATE_NATD_WAIT
#define AP_CONN_STATE_NATD_WAIT
Definition: connection_edge.h:58
router_get_descriptor_digests
smartlist_t * router_get_descriptor_digests(void)
Definition: networkstatus.c:801
base16_encode
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:478
tor_fragile_assert
#define tor_fragile_assert()
Definition: util_bug.h:259
router_get_my_routerinfo
const routerinfo_t * router_get_my_routerinfo(void)
Definition: router.c:1760
getinfo_helper_t
int(* getinfo_helper_t)(control_connection_t *, const char *q, char **a, const char **error_out)
Definition: control_getinfo.c:1515
control_proto.h
Header file for control_proto.c.
extrainfo_get_by_descriptor_digest
signed_descriptor_t * extrainfo_get_by_descriptor_digest(const char *digest)
Definition: routerlist.c:809
signed_descriptor_t::annotations_len
size_t annotations_len
Definition: signed_descriptor_st.h:24
node_get_by_nickname
const node_t * node_get_by_nickname(const char *nickname, unsigned flags)
Definition: nodelist.c:1004
smartlist_add
void smartlist_add(smartlist_t *sl, void *element)
Definition: smartlist_core.c:117
we_fetch_microdescriptors
int we_fetch_microdescriptors(const or_options_t *options)
Definition: microdesc.c:1063
CONN_TYPE_AP_DNS_LISTENER
#define CONN_TYPE_AP_DNS_LISTENER
Definition: connection.h:68
list_sk_digests_for_authority_id
smartlist_t * list_sk_digests_for_authority_id(const char *digest)
Definition: authcert.c:247
routerlist_t::routers
smartlist_t * routers
Definition: routerlist_st.h:32
VS_EMPTY
@ VS_EMPTY
Definition: versions.h:25
tor_mmap_t::data
const char * data
Definition: mmap.h:26
addressmap_get_mappings
void addressmap_get_mappings(smartlist_t *sl, time_t min_expires, time_t max_expires, int want_expiry)
Definition: addressmap.c:1114
relay_find_addr_to_publish
bool relay_find_addr_to_publish(const or_options_t *options, int family, int flags, tor_addr_t *addr_out)
Definition: relay_find_addr.c:101
get_torrc_fname
const char * get_torrc_fname(int defaults_fname)
Definition: config.c:4706
getinfo_helper_sr
static int getinfo_helper_sr(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:1490
version_status_t
version_status_t
Definition: versions.h:17
control_cmd_syntax_t::max_args
unsigned int max_args
Definition: control_cmd.h:46
get_detached_onion_services
smartlist_t * get_detached_onion_services(void)
Definition: control_cmd.c:1690
hostname_type_t
hostname_type_t
Definition: connection_edge.h:79
smartlist_new
smartlist_t * smartlist_new(void)
Definition: smartlist_core.c:26
control_event_boot_last_msg
char * control_event_boot_last_msg(void)
Definition: control_bootstrap.c:372
socks_request_st.h
Client request structure.
or_connection_t
Definition: or_connection_st.h:22
CIRCUIT_IS_ORIGIN
#define CIRCUIT_IS_ORIGIN(c)
Definition: circuitlist.h:146
get_version
const char * get_version(void)
Definition: version.c:38
hs_address_is_valid
int hs_address_is_valid(const char *address)
Definition: hs_common.c:974
microdesc_t::body
char * body
Definition: microdesc_st.h:58
SMARTLIST_FOREACH
#define SMARTLIST_FOREACH(sl, type, var, cmd)
Definition: smartlist_foreach.h:112
tor_mmap_t::size
size_t size
Definition: mmap.h:27
router_extrainfo_digest_is_me
int router_extrainfo_digest_is_me(const char *digest)
Definition: router.c:1714
getinfo_helper_liveness
static int getinfo_helper_liveness(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:1437
dir_split_resource_into_fingerprints
int dir_split_resource_into_fingerprints(const char *resource, smartlist_t *fp_out, int *compressed_out, int flags)
Definition: directory.c:644
CONN_TYPE_EXT_OR_LISTENER
#define CONN_TYPE_EXT_OR_LISTENER
Definition: connection.h:73
list_authority_ids_with_downloads
smartlist_t * list_authority_ids_with_downloads(void)
Definition: authcert.c:196
download_status_t::schedule
download_schedule_bitfield_t schedule
Definition: download_status_st.h:49
networkstatus.h
Header file for networkstatus.c.
origin_circuit_t::global_identifier
uint32_t global_identifier
Definition: origin_circuit_st.h:240
download_status_t::last_backoff_position
uint8_t last_backoff_position
Definition: download_status_st.h:61
CONN_TYPE_OR_LISTENER
#define CONN_TYPE_OR_LISTENER
Definition: connection.h:41
geoip_stats.h
Header file for geoip_stats.c.
router_get_by_id_digest
const routerinfo_t * router_get_by_id_digest(const char *digest)
Definition: routerlist.c:775
rend_cache_lookup_entry
int rend_cache_lookup_entry(const char *query, int version, rend_cache_entry_t **e)
Definition: rendcache.c:523
getinfo_helper_downloads_desc
STATIC void getinfo_helper_downloads_desc(const char *desc_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg)
Definition: control_getinfo.c:998
router_build_fresh_descriptor
int router_build_fresh_descriptor(routerinfo_t **r, extrainfo_t **e)
Definition: router.c:2353
consensus_flavor_t
consensus_flavor_t
Definition: or.h:881
control_cmd_args_t::args
struct smartlist_t * args
Definition: control_cmd_args_st.h:33
hs_cache.h
Header file for hs_cache.c.
get_bytes_written
uint64_t get_bytes_written(void)
Definition: mainloop.c:475
base16_decode
int base16_decode(char *dest, size_t destlen, const char *src, size_t srclen)
Definition: binascii.c:506
hibernate.h
Header file for hibernate.c.
ENTRY_TO_EDGE_CONN
#define ENTRY_TO_EDGE_CONN(c)
Definition: entry_connection_st.h:102
get_bridge_dl_status_by_id
download_status_t * get_bridge_dl_status_by_id(const char *digest)
Definition: bridges.c:987
circuitlist.h
Header file for circuitlist.c.
mainloop.h
Header file for mainloop.c.
DIGEST_LEN
#define DIGEST_LEN
Definition: digest_sizes.h:20
geoip_get_bridge_stats_controller
char * geoip_get_bridge_stats_controller(time_t)
Definition: geoip_stats.c:1309
CONN_TYPE_AP
#define CONN_TYPE_AP
Definition: connection.h:51
AP_CONN_STATE_RESOLVE_WAIT
#define AP_CONN_STATE_RESOLVE_WAIT
Definition: connection_edge.h:53
OR_CONN_STATE_OPEN
#define OR_CONN_STATE_OPEN
Definition: orconn_event.h:53
CONN_TYPE_CONTROL_LISTENER
#define CONN_TYPE_CONTROL_LISTENER
Definition: connection.h:58
signed_descriptor_get_body
const char * signed_descriptor_get_body(const signed_descriptor_t *desc)
Definition: routerlist.c:879
download_status_t::want_authority
download_want_authority_bitfield_t want_authority
Definition: download_status_st.h:53
getinfo_helper_downloads_bridge
STATIC void getinfo_helper_downloads_bridge(const char *bridge_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg)
Definition: control_getinfo.c:1044
tor_sockaddr_to_str
char * tor_sockaddr_to_str(const struct sockaddr *sa)
Definition: address.c:198
bridges.h
Header file for circuitbuild.c.
routerlist_t
Definition: routerlist_st.h:18
TO_ENTRY_CONN
entry_connection_t * TO_ENTRY_CONN(connection_t *c)
Definition: connection_edge.c:202
control_reply_free
#define control_reply_free(r)
Free and null a smartlist of control_reply_line_t.
Definition: control_proto.h:116
getinfo_helper_current_consensus
STATIC int getinfo_helper_current_consensus(consensus_flavor_t flavor, char **answer, const char **errmsg)
Definition: control_getinfo.c:346
entrynodes.h
Header file for circuitbuild.c.
networkstatus_get_latest_consensus
networkstatus_t * networkstatus_get_latest_consensus(void)
Definition: networkstatus.c:1390
getinfo_helper_listeners
static int getinfo_helper_listeners(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:262
control_event_table
const struct control_event_t control_event_table[]
Definition: control_events.c:80
node_t
Definition: node_st.h:34
origin_circuit_t
Definition: origin_circuit_st.h:79
getinfo_geoip.h
Header for getinfo_geoip.c.
list_bridge_identities
smartlist_t * list_bridge_identities(void)
Definition: bridges.c:967
LD_CONTROL
#define LD_CONTROL
Definition: log.h:80
AP_CONN_STATE_CONNECT_WAIT
#define AP_CONN_STATE_CONNECT_WAIT
Definition: connection_edge.h:51
networkstatus_t::client_versions
char * client_versions
Definition: networkstatus_st.h:56
router_get_dl_status_by_descriptor_digest
download_status_t * router_get_dl_status_by_descriptor_digest(const char *d)
Definition: networkstatus.c:816
list_getinfo_options
static char * list_getinfo_options(void)
Definition: control_getinfo.c:1730
getinfo_item_t::fn
getinfo_helper_t fn
Definition: control_getinfo.c:1522
digest_list_to_string
static char * digest_list_to_string(const smartlist_t *sl)
Definition: control_getinfo.c:766
directory.h
Header file for directory.c.
CONN_TYPE_OR
#define CONN_TYPE_OR
Definition: connection.h:44
control_reply_add_done
void control_reply_add_done(smartlist_t *reply)
Definition: control_proto.c:401
cached_dir_st.h
Cached large directory object structure.
getinfo_item_t::varname
const char * varname
Definition: control_getinfo.c:1521
ed25519_public_key_t
Definition: crypto_ed25519.h:23
download_status_t::last_delay_used
int last_delay_used
Definition: download_status_st.h:65
tor_getpwuid
const struct passwd * tor_getpwuid(uid_t uid)
Definition: userdb.c:106
AP_CONN_STATE_SOCKS_WAIT
#define AP_CONN_STATE_SOCKS_WAIT
Definition: connection_edge.h:41
CONN_TYPE_AP_HTTP_CONNECT_LISTENER
#define CONN_TYPE_AP_HTTP_CONNECT_LISTENER
Definition: connection.h:75
controller_get_routerdescs
static int controller_get_routerdescs(smartlist_t *descs_out, const char *key, const char **msg)
Definition: control_getinfo.c:396
strcmpstart
int strcmpstart(const char *s1, const char *s2)
Definition: util_string.c:215
we_fetch_router_descriptors
int we_fetch_router_descriptors(const or_options_t *options)
Definition: microdesc.c:1074
control_cmd_syntax_t
Definition: control_cmd.h:36
microdesc_st.h
Microdescriptor structure.
download_status_t
Definition: download_status_st.h:41
routerlist_st.h
Router descriptor list structure.
get_connection_array
smartlist_t * get_connection_array(void)
Definition: mainloop.c:453
tor_mmap_t
Definition: mmap.h:25
AP_CONN_STATE_RENDDESC_WAIT
#define AP_CONN_STATE_RENDDESC_WAIT
Definition: connection_edge.h:44
circuit_t
Definition: circuit_st.h:61
nodelist.h
Header file for nodelist.c.
rend_valid_v2_service_id
int rend_valid_v2_service_id(const char *query)
Definition: rendcommon.c:725
routerlist.h
Header file for routerlist.c.
fmt_serverstatus.h
Header file for fmt_serverstatus.c.
have_completed_a_circuit
int have_completed_a_circuit(void)
Definition: mainloop.c:220
predict_ports.h
Header file for predict_ports.c.
rep_hist_get_circuit_handshake_assigned
int rep_hist_get_circuit_handshake_assigned(uint16_t type)
Definition: rephist.c:1686
dirserv_get_consensus
cached_dir_t * dirserv_get_consensus(const char *flavor_name)
Definition: dirserv.c:201
routerinfo_st.h
Router descriptor structure.
tor_gettimeofday
void tor_gettimeofday(struct timeval *timeval)
Definition: tor_gettimeofday.c:42
ROUTER_MAX_AGE_TO_PUBLISH
#define ROUTER_MAX_AGE_TO_PUBLISH
Definition: or.h:161
tor_addr_to_str_dup
char * tor_addr_to_str_dup(const tor_addr_t *addr)
Definition: address.c:1164
cached_dir_t
Definition: cached_dir_st.h:17
getinfo_items
static const getinfo_item_t getinfo_items[]
Definition: control_getinfo.c:1534
getinfo_helper_downloads_cert
STATIC void getinfo_helper_downloads_cert(const char *fp_sk_req, download_status_t **dl_to_emit, smartlist_t **digest_list, const char **errmsg)
Definition: control_getinfo.c:898
networkstatus_get_dl_status_by_flavor
download_status_t * networkstatus_get_dl_status_by_flavor(consensus_flavor_t flavor)
Definition: networkstatus.c:1345
connection_t
Definition: connection_st.h:45
rendcache.h
Header file for rendcache.c.
rep_hist_get_circuit_handshake_requested
int rep_hist_get_circuit_handshake_requested(uint16_t type)
Definition: rephist.c:1676
router_get_by_descriptor_digest
signed_descriptor_t * router_get_by_descriptor_digest(const char *digest)
Definition: routerlist.c:783
sr_get_previous_for_control
char * sr_get_previous_for_control(void)
Definition: shared_random_client.c:127
entry_connection_t::socks_request
socks_request_t * socks_request
Definition: entry_connection_st.h:27
routerlist
static routerlist_t * routerlist
Definition: routerlist.c:146
get_max_sockets
int get_max_sockets(void)
Definition: socket.c:98
control_events.h
Header file for control_events.c.
id_only_download_status_for_authority_id
download_status_t * id_only_download_status_for_authority_id(const char *digest)
Definition: authcert.c:227
get_options
const or_options_t * get_options(void)
Definition: config.c:929
AP_CONN_STATE_OPEN
#define AP_CONN_STATE_OPEN
Definition: connection_edge.h:55
getinfo_helper_onions
STATIC int getinfo_helper_onions(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:1407
download_status_t::increment_on
download_schedule_increment_bitfield_t increment_on
Definition: download_status_st.h:58
addressmap.h
Header for addressmap.c.
getinfo_helper_downloads_networkstatus
STATIC void getinfo_helper_downloads_networkstatus(const char *flavor, download_status_t **dl_to_emit, const char **errmsg)
Definition: control_getinfo.c:869
download_status_t::n_download_attempts
uint8_t n_download_attempts
Definition: download_status_st.h:46
smartlist_sort_strings
void smartlist_sort_strings(smartlist_t *sl)
Definition: smartlist.c:549
origin_circuit_t::cpath
crypt_path_t * cpath
Definition: origin_circuit_st.h:129
control_write_reply_lines
void control_write_reply_lines(control_connection_t *conn, smartlist_t *lines)
Definition: control_proto.c:317
nodelist_get_list
const smartlist_t * nodelist_get_list(void)
Definition: nodelist.c:966
TO_ORIGIN_CIRCUIT
origin_circuit_t * TO_ORIGIN_CIRCUIT(circuit_t *x)
Definition: circuitlist.c:168
connection.h
Header file for connection.c.
networkstatus_get_dl_status_by_flavor_bootstrap
download_status_t * networkstatus_get_dl_status_by_flavor_bootstrap(consensus_flavor_t flavor)
Definition: networkstatus.c:1362
control_cmd.h
Header file for control_cmd.c.
signed_descriptor_get_annotations
const char * signed_descriptor_get_annotations(const signed_descriptor_t *desc)
Definition: routerlist.c:887
extrainfo_st.h
A relay's extra-info structure.
control_reply_add_printf
void control_reply_add_printf(smartlist_t *reply, int code, const char *fmt,...)
Definition: control_proto.c:387
handle_control_getinfo
int handle_control_getinfo(control_connection_t *conn, const control_cmd_args_t *args)
Definition: control_getinfo.c:1787
list_server_status_v1
int list_server_status_v1(smartlist_t *routers, char **router_status_out, int for_controller)
Definition: fmt_serverstatus.c:66
networkstatus_get_dl_status_by_flavor_running
download_status_t * networkstatus_get_dl_status_by_flavor_running(consensus_flavor_t flavor)
Definition: networkstatus.c:1376
dirserv.h
Header file for dirserv.c.
server_mode
int server_mode(const or_options_t *options)
Definition: routermode.c:34
crypto_pk_get_fingerprint
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
Definition: crypto_rsa.c:229
timeval
Definition: compat_time.h:151
dirclient.h
Header file for dirclient.c.
tor_asprintf
int tor_asprintf(char **strp, const char *fmt,...)
Definition: printf.c:75
getinfo_helper_misc
static int getinfo_helper_misc(control_connection_t *conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:86
or_connection_st.h
OR connection structure.
kvline.h
Header for kvline.c.
download_status_get_next_attempt_at
time_t download_status_get_next_attempt_at(const download_status_t *dls)
Definition: dlstatus.c:418
SMARTLIST_FOREACH_BEGIN
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
Definition: smartlist_foreach.h:78
dlstatus.h
Header file for dlstatus.c.
sr_get_current_for_control
char * sr_get_current_for_control(void)
Definition: shared_random_client.c:111
crypto_pk_t
Definition: crypto_rsa_nss.c:37
VS_UNRECOMMENDED
@ VS_UNRECOMMENDED
Definition: versions.h:24
router_dirport_seems_reachable
int router_dirport_seems_reachable(const or_options_t *options)
Definition: selftest.c:148
router_get_routerlist
routerlist_t * router_get_routerlist(void)
Definition: routerlist.c:894
directories_have_accepted_server_descriptor
int directories_have_accepted_server_descriptor(void)
Definition: dirclient.c:206
HEX_DIGEST_LEN
#define HEX_DIGEST_LEN
Definition: crypto_digest.h:35
node_st.h
Node information structure.
router_get_my_extrainfo
extrainfo_t * router_get_my_extrainfo(void)
Definition: router.c:1813
control_connection_t
Definition: control_connection_st.h:19
VS_UNKNOWN
@ VS_UNKNOWN
Definition: versions.h:26
policies.h
Header file for policies.c.
VS_NEW_IN_SERIES
@ VS_NEW_IN_SERIES
Definition: versions.h:21
control_write_endreply
void control_write_endreply(control_connection_t *conn, int code, const char *s)
Definition: control_proto.c:214
hs_service_lookup_current_desc
char * hs_service_lookup_current_desc(const ed25519_public_key_t *pk)
Definition: hs_service.c:3776
getinfo_helper_events
static int getinfo_helper_events(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:1149
rend_cache_entry_t::desc
char * desc
Definition: rendcache.h:33
shared_random_client.h
Header file for shared_random_client.c.
getinfo_helper_rephist
STATIC int getinfo_helper_rephist(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:1457
config.h
Header file for config.c.
control_reply_add_str
void control_reply_add_str(smartlist_t *reply, int code, const char *s)
Definition: control_proto.c:375
smartlist_add_asprintf
void smartlist_add_asprintf(struct smartlist_t *sl, const char *pattern,...)
Definition: smartlist.c:36
munge_extrainfo_into_routerinfo
static char * munge_extrainfo_into_routerinfo(const char *ri_body, const signed_descriptor_t *ri, const signed_descriptor_t *ei)
Definition: control_getinfo.c:218
hs_parse_address
int hs_parse_address(const char *address, ed25519_public_key_t *key_out, uint8_t *checksum_out, uint8_t *version_out)
Definition: hs_common.c:958
esc_for_log
char * esc_for_log(const char *s)
Definition: escape.c:30
node_get_by_hex_id
const node_t * node_get_by_hex_id(const char *hex_id, unsigned flags)
Definition: nodelist.c:977
connection_t::state
uint8_t state
Definition: connection_st.h:49
signed_descriptor_t::published_on
time_t published_on
Definition: signed_descriptor_st.h:33
orconn_target_get_name
void orconn_target_get_name(char *name, size_t len, or_connection_t *conn)
Definition: control_fmt.c:54
CIRCUIT_STATE_GUARD_WAIT
#define CIRCUIT_STATE_GUARD_WAIT
Definition: circuitlist.h:30
socks_request_t::command
uint8_t command
Definition: socks_request_st.h:47
getinfo_helper_current_time
STATIC int getinfo_helper_current_time(control_connection_t *control_conn, const char *question, char **answer, const char **errmsg)
Definition: control_getinfo.c:321
networkstatus_map_cached_consensus
tor_mmap_t * networkstatus_map_cached_consensus(const char *flavorname)
Definition: networkstatus.c:262
signed_descriptor_t
Definition: signed_descriptor_st.h:18
or_options_t
Definition: or_options_st.h:64
get_uptime
long get_uptime(void)
Definition: mainloop.c:2522
download_status_to_string
static char * download_status_to_string(const download_status_t *dl)
Definition: control_getinfo.c:790
microdesc_t::bodylen
size_t bodylen
Definition: microdesc_st.h:60
STATIC
#define STATIC
Definition: testsupport.h:32
signed_descriptor_t::signed_descriptor_len
size_t signed_descriptor_len
Definition: signed_descriptor_st.h:26
AP_CONN_STATE_CONTROLLER_WAIT
#define AP_CONN_STATE_CONTROLLER_WAIT
Definition: connection_edge.h:47
router_have_minimum_dir_info
int router_have_minimum_dir_info(void)
Definition: nodelist.c:2346
CONN_TYPE_AP_LISTENER
#define CONN_TYPE_AP_LISTENER
Definition: connection.h:48
VS_RECOMMENDED
@ VS_RECOMMENDED
Definition: versions.h:18
write_stream_target_to_buf
int write_stream_target_to_buf(entry_connection_t *conn, char *buf, size_t len)
Definition: control_fmt.c:32
networkstatus_st.h
Networkstatus consensus/vote structure.
entry_connection_t
Definition: entry_connection_st.h:19
cached_dir_t::dir
char * dir
Definition: cached_dir_st.h:18
networkstatus_t
Definition: networkstatus_st.h:26
origin_circuit_st.h
Origin circuit structure.
VS_OLD
@ VS_OLD
Definition: versions.h:19
circuit_get_by_edge_conn
circuit_t * circuit_get_by_edge_conn(edge_connection_t *conn)
Definition: circuitlist.c:1588
download_status_for_authority_id_and_sk
download_status_t * download_status_for_authority_id_and_sk(const char *id_digest, const char *sk_digest)
Definition: authcert.c:282
smartlist_t
Definition: smartlist_core.h:26
getinfo_item_t::desc
const char * desc
Definition: control_getinfo.c:1524
smartlist_join_strings
char * smartlist_join_strings(smartlist_t *sl, const char *join, int terminate, size_t *len_out)
Definition: smartlist.c:279
TO_OR_CONN
or_connection_t * TO_OR_CONN(connection_t *c)
Definition: connection_or.c:108
torversion.h
Header for version.c.
control_cmd_args_st.h
Definition for control_cmd_args_t.
circuit_t::state
uint8_t state
Definition: circuit_st.h:110
download_status_t::n_download_failures
uint8_t n_download_failures
Definition: download_status_st.h:44
control_fmt.h
Header file for control_fmt.c.
format_local_iso_time_nospace
void format_local_iso_time_nospace(char *buf, time_t t)
Definition: time_fmt.c:304
CONN_TYPE_DIR_LISTENER
#define CONN_TYPE_DIR_LISTENER
Definition: connection.h:53
rephist.h
Header file for rephist.c.
CONN_TYPE_AP_NATD_LISTENER
#define CONN_TYPE_AP_NATD_LISTENER
Definition: connection.h:66
hs_cache_lookup_encoded_as_client
const char * hs_cache_lookup_encoded_as_client(const ed25519_public_key_t *key)
Definition: hs_cache.c:809
control_connection_st.h
Controller connection structure.
connection_or.h
Header file for connection_or.c.
or_connection_t::nickname
char * nickname
Definition: or_connection_st.h:42
SOCKET_OK
#define SOCKET_OK(s)
Definition: nettypes.h:39
or.h
Master header file for Tor-specific functionality.
rep_hist_circbuilding_dormant
int rep_hist_circbuilding_dormant(time_t now)
Definition: predict_ports.c:264