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