28#include "core/or/channelpadding.h"
83#include <event2/event.h>
96# if defined(__COVERITY__) && !defined(__INCLUDE_LEVEL__)
100# define __INCLUDE_LEVEL__ 2
102#include <systemd/sd-daemon.h>
118 log_notice(
LD_GENERAL,
"Received reload signal (hup). Reloading config and "
119 "resetting internal state.");
130 log_err(
LD_CONFIG,
"Reading config failed--see warnings above. "
131 "For usage, try -h.");
133 }
else if (BUG(init_rv > 0)) {
148 log_notice(
LD_GENERAL,
"Not reloading config file: the controller told "
153 msg = tor_strdup(
"Unknown error");
154 log_warn(
LD_GENERAL,
"Unable to re-set previous options: %s", msg);
162 log_info(
LD_GENERAL,
"Error reloading fingerprints. "
163 "Continuing with old list.");
186 if (new_signing_key < 0 ||
188 log_warn(
LD_OR,
"Problem reloading Ed25519 keys; still using old keys.");
192 log_warn(
LD_OR,
"Problem reloading family ID keys; "
193 "still using old keys.");
209 const int *sigptr = arg;
210 const int sig = *sigptr;
225 log_notice(
LD_GENERAL,
"Catching signal TERM, exiting cleanly.");
230 log_notice(
LD_GENERAL,
"Interrupt: exiting cleanly.");
235 sd_notify(0,
"STOPPING=1");
241 log_debug(
LD_GENERAL,
"Caught SIGPIPE. Ignoring.");
251 log_debug(
LD_GENERAL,
"Caught USR2, going to loglevel debug. "
252 "Send HUP to change back.");
257 sd_notify(0,
"RELOADING=1");
260 log_warn(
LD_CONFIG,
"Restart failed (config error?). Exiting.");
265 sd_notify(0,
"READY=1");
278 case SIGCLEARDNSCACHE:
293 log_notice(
LD_GENERAL,
"Going dormant because of controller request.");
305process_win32_console_ctrl(DWORD ctrl_type)
310 activate_signal(SIGINT);
334 time_t now = time(NULL);
336 size_t rbuf_cap, wbuf_cap, rbuf_len, wbuf_len;
343 "Conn %d (socket %d) is a %s, created %d secs ago",
346 (
int)(now - conn->timestamp_created));
349 "Conn %d: %d bytes waiting on inbuf (len %d, last read %d secs ago)",
351 (
int)connection_get_inbuf_len(conn),
353 (
int)(now - conn->timestamp_last_read_allowed));
355 "Conn %d: %d bytes waiting on outbuf "
356 "(len %d, last written %d secs ago)",i,
357 (
int)connection_get_outbuf_len(conn),
359 (
int)(now - conn->timestamp_last_write_allowed));
364 &wbuf_cap, &wbuf_len) == 0) {
366 "Conn %d: %d/%d bytes used on OpenSSL read buffer; "
367 "%d/%d bytes used on write buffer.",
368 i, (
int)rbuf_len, (
int)rbuf_cap, (
int)wbuf_len, (
int)wbuf_cap);
375 } SMARTLIST_FOREACH_END(conn);
382 "Cells processed: %"PRIu64
" padding\n"
383 " %"PRIu64
" create\n"
384 " %"PRIu64
" created\n"
386 " (%"PRIu64
" relayed)\n"
387 " (%"PRIu64
" delivered)\n"
388 " %"PRIu64
" destroy",
397 tor_log(severity,
LD_NET,
"Average packaged cell fullness: %2.3f%%",
401 tor_log(severity,
LD_NET,
"Average delivered cell fullness: %2.3f%%",
415 "Average bandwidth: %"PRIu64
"/%d = %d bytes/sec reading",
420 "Average bandwidth: %"PRIu64
"/%d = %d bytes/sec writing",
426 tor_log(severity,
LD_NET,
"--------------- Dumping memory information:");
448} signal_handlers[] = {
450 { SIGINT, UNIX_ONLY, NULL },
453 { SIGTERM, UNIX_ONLY, NULL },
456 { SIGPIPE, UNIX_ONLY, NULL },
459 { SIGUSR1, UNIX_ONLY, NULL },
462 { SIGUSR2, UNIX_ONLY, NULL },
465 { SIGHUP, UNIX_ONLY, NULL },
468 { SIGXFSZ, UNIX_ONLY, NULL },
471 { SIGCHLD, UNIX_ONLY, NULL },
474 { SIGNEWNYM, 0, NULL },
475 { SIGCLEARDNSCACHE, 0, NULL },
476 { SIGHEARTBEAT, 0, NULL },
477 { SIGACTIVE, 0, NULL },
478 { SIGDORMANT, 0, NULL },
490 for (i = 0; signal_handlers[i].signal_value >= 0; ++i) {
497 signal_handlers[i].signal_event =
503 log_warn(
LD_BUG,
"Error from libevent when adding "
504 "event for signal %d",
507 signal_handlers[i].signal_event =
518 if (enabled) SetConsoleCtrlHandler(process_win32_console_ctrl, TRUE);
524activate_signal(
int signal_num)
527 for (i = 0; signal_handlers[i].signal_value >= 0; ++i) {
529 event_active(signal_handlers[i].
signal_event, EV_SIGNAL, 1);
543 bool running_tor =
false;
570 parsed_cmdline_free(cmdline);
580 log_notice(
LD_GENERAL,
"Tor %s running on %s with Libevent %s, "
581 "%s %s, Zlib %s, Liblzma %s, Libzstd %s and %s %s as libc.",
597 log_notice(
LD_GENERAL,
"Tor can't help you if you use it wrong! "
598 "Learn how to be safe at "
599 "https://support.torproject.org/faq/staying-anonymous/");
601 if (strstr(version,
"alpha") || strstr(version,
"beta"))
602 log_notice(
LD_GENERAL,
"This version is not a stable Tor release. "
603 "Expect more bugs than usual.");
606 log_warn(
LD_GENERAL,
"This build of Tor has been compiled with one "
607 "or more options that might make it less reliable or secure! "
615 tracing_log_warning();
619 log_err(
LD_CONFIG,
"Reading config failed--see warnings above.");
621 }
else if (init_rv > 0) {
642 predicted_ports_init();
646 log_warn(
LD_GENERAL,
"You are running Tor as root. You don't need to, "
647 "and you probably shouldn't.");
672 char *fname = options_get_datadir_fname(options,
"lock");
673 int already_locked = 0;
677 if (err_if_locked && already_locked) {
679 log_warn(
LD_GENERAL,
"It looks like another Tor process is running "
680 "with the same data directory. Waiting 5 seconds to see "
689 log_err(
LD_GENERAL,
"No, it's still there. Exiting.");
725 if (filename &&
tor_unlink(filename) != 0 && errno != ENOENT) {
726 log_warn(
LD_FS,
"Couldn't unlink %s: %s",
727 filename, strerror(errno));
740 const char *nickname = options->
Nickname;
741 sandbox_disable_getaddrinfo_cache();
743 bool show_rsa = !strcmp(arg,
"") || !strcmp(arg,
"rsa");
744 bool show_ed25519 = !strcmp(arg,
"ed25519");
745 if (!show_rsa && !show_ed25519) {
747 "If you give a key type, you must specify 'rsa' or 'ed25519'. Exiting.");
753 "Clients don't have long-term identity keys. Exiting.");
758 log_err(
LD_GENERAL,
"Error initializing keys; exiting.");
761 if (!(k = get_server_identity_key())) {
762 log_err(
LD_GENERAL,
"Error: missing RSA identity key.");
766 log_err(
LD_BUG,
"Error computing RSA fingerprint");
769 if (!(edkey = get_master_identity_key())) {
770 log_err(
LD_GENERAL,
"Error: missing ed25519 identity key.");
774 printf(
"%s %s\n", nickname, rsa);
779 printf(
"%s %s\n", nickname, ed25519);
799 printf(
"16:%s\n",output);
812 if (!strcmp(arg,
"short")) {
813 how = OPTIONS_DUMP_MINIMAL;
814 }
else if (!strcmp(arg,
"non-builtin")) {
816 fprintf(stderr,
"'non-builtin' is deprecated; use 'short' instead.\n");
817 how = OPTIONS_DUMP_MINIMAL;
818 }
else if (!strcmp(arg,
"full")) {
819 how = OPTIONS_DUMP_ALL;
821 fprintf(stderr,
"No valid argument to --dump-config found!\n");
822 fprintf(stderr,
"Please select 'short' or 'full'.\n");
840 char *fname_key = NULL, *fname_id = NULL, *id_contents = NULL;
843 if (BUG(!fname_base))
846 tor_asprintf(&fname_key,
"%s.secret_family_key", fname_base);
847 tor_asprintf(&fname_id,
"%s.public_family_id", fname_base);
855 printf(
"# Generated %s\n", fname_key);
879 gethostname(hname,
sizeof(hname));
880 tor_add_addrinfo(hname);
884sandbox_init_filter(
void)
890 get_cachedir_fname(
"cached-status"));
893 sandbox_cfg_allow_open_filename(&cfg, tor_strdup(name))
895#define OPENDIR(dir) \
896 sandbox_cfg_allow_opendir_dirname(&cfg, tor_strdup(dir))
898#define OPEN_DATADIR(name) \
899 sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname(name))
901#define OPEN_DATADIR2(name, name2) \
902 sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname2((name), (name2)))
904#define OPEN_DATADIR_SUFFIX(name, suffix) do { \
905 OPEN_DATADIR(name); \
906 OPEN_DATADIR(name suffix); \
909#define OPEN_DATADIR2_SUFFIX(name, name2, suffix) do { \
910 OPEN_DATADIR2(name, name2); \
911 OPEN_DATADIR2(name, name2 suffix); \
916#define OPEN_KEY_DIRECTORY() \
917 OPEN(options->KeyDirectory)
918#define OPEN_CACHEDIR(name) \
919 sandbox_cfg_allow_open_filename(&cfg, get_cachedir_fname(name))
920#define OPEN_CACHEDIR_SUFFIX(name, suffix) do { \
921 OPEN_CACHEDIR(name); \
922 OPEN_CACHEDIR(name suffix); \
924#define OPEN_KEYDIR(name) \
925 sandbox_cfg_allow_open_filename(&cfg, get_keydir_fname(name))
926#define OPEN_KEYDIR_SUFFIX(name, suffix) do { \
928 OPEN_KEYDIR(name suffix); \
934 OPEN_KEY_DIRECTORY();
936 OPEN_CACHEDIR_SUFFIX(
"cached-certs",
".tmp");
937 OPEN_CACHEDIR_SUFFIX(
"cached-consensus",
".tmp");
938 OPEN_CACHEDIR_SUFFIX(
"unverified-consensus",
".tmp");
939 OPEN_CACHEDIR_SUFFIX(
"unverified-microdesc-consensus",
".tmp");
940 OPEN_CACHEDIR_SUFFIX(
"cached-microdesc-consensus",
".tmp");
941 OPEN_CACHEDIR_SUFFIX(
"cached-microdescs",
".tmp");
942 OPEN_CACHEDIR_SUFFIX(
"cached-microdescs.new",
".tmp");
943 OPEN_CACHEDIR_SUFFIX(
"cached-descriptors",
".tmp");
944 OPEN_CACHEDIR_SUFFIX(
"cached-descriptors.new",
".tmp");
945 OPEN_CACHEDIR(
"cached-descriptors.tmp.tmp");
946 OPEN_CACHEDIR_SUFFIX(
"cached-extrainfo",
".tmp");
947 OPEN_CACHEDIR_SUFFIX(
"cached-extrainfo.new",
".tmp");
948 OPEN_CACHEDIR(
"cached-extrainfo.tmp.tmp");
950 OPEN_DATADIR_SUFFIX(
"state",
".tmp");
951 OPEN_DATADIR_SUFFIX(
"sr-state",
".tmp");
952 OPEN_DATADIR_SUFFIX(
"unparseable-desc",
".tmp");
953 OPEN_DATADIR_SUFFIX(
"v3-status-votes",
".tmp");
954 OPEN_DATADIR(
"key-pinning-journal");
955 OPEN(
"/dev/srandom");
956 OPEN(
"/dev/urandom");
959 OPEN(
"/proc/meminfo");
961#ifdef HAVE_MODULE_RELAY
970 smartlist_free(family_id_files);
975 OPEN_DATADIR_SUFFIX(
"networkstatus-bridges",
".tmp");
978 OPEN_DATADIR(
"approved-routers");
979 OPEN_DATADIR_SUFFIX(
"my-consensus-microdesc",
".tmp");
980 OPEN_DATADIR_SUFFIX(
"my-consensus-ns",
".tmp");
982 log_notice(
LD_GENERAL,
"Adding V3BandwidthsFile %s to sandboxing set.",
1002 char *torrc_bck = NULL;
1004 sandbox_cfg_allow_rename(&cfg, tor_strdup(
torrc_fname), torrc_bck);
1005 char *torrc_tmp = NULL;
1007 sandbox_cfg_allow_rename(&cfg, torrc_tmp, tor_strdup(
torrc_fname));
1014 if (file_status(f) == FN_DIR) {
1021#define RENAME_SUFFIX(name, suffix) \
1022 sandbox_cfg_allow_rename(&cfg, \
1023 get_datadir_fname(name suffix), \
1024 get_datadir_fname(name))
1026#define RENAME_SUFFIX2(prefix, name, suffix) \
1027 sandbox_cfg_allow_rename(&cfg, \
1028 get_datadir_fname2(prefix, name suffix), \
1029 get_datadir_fname2(prefix, name))
1031#define RENAME_CACHEDIR_SUFFIX(name, suffix) \
1032 sandbox_cfg_allow_rename(&cfg, \
1033 get_cachedir_fname(name suffix), \
1034 get_cachedir_fname(name))
1036#define RENAME_KEYDIR_SUFFIX(name, suffix) \
1037 sandbox_cfg_allow_rename(&cfg, \
1038 get_keydir_fname(name suffix), \
1039 get_keydir_fname(name))
1041 RENAME_CACHEDIR_SUFFIX(
"cached-certs",
".tmp");
1042 RENAME_CACHEDIR_SUFFIX(
"cached-consensus",
".tmp");
1043 RENAME_CACHEDIR_SUFFIX(
"unverified-consensus",
".tmp");
1044 RENAME_CACHEDIR_SUFFIX(
"unverified-microdesc-consensus",
".tmp");
1045 RENAME_CACHEDIR_SUFFIX(
"cached-microdesc-consensus",
".tmp");
1046 RENAME_CACHEDIR_SUFFIX(
"cached-microdescs",
".tmp");
1047 RENAME_CACHEDIR_SUFFIX(
"cached-microdescs",
".new");
1048 RENAME_CACHEDIR_SUFFIX(
"cached-microdescs.new",
".tmp");
1049 RENAME_CACHEDIR_SUFFIX(
"cached-descriptors",
".tmp");
1050 RENAME_CACHEDIR_SUFFIX(
"cached-descriptors",
".new");
1051 RENAME_CACHEDIR_SUFFIX(
"cached-descriptors.new",
".tmp");
1052 RENAME_CACHEDIR_SUFFIX(
"cached-extrainfo",
".tmp");
1053 RENAME_CACHEDIR_SUFFIX(
"cached-extrainfo",
".new");
1054 RENAME_CACHEDIR_SUFFIX(
"cached-extrainfo.new",
".tmp");
1056 RENAME_SUFFIX(
"state",
".tmp");
1057 RENAME_SUFFIX(
"sr-state",
".tmp");
1058 RENAME_SUFFIX(
"unparseable-desc",
".tmp");
1059 RENAME_SUFFIX(
"v3-status-votes",
".tmp");
1062 RENAME_SUFFIX(
"networkstatus-bridges",
".tmp");
1065 RENAME_SUFFIX(
"my-consensus-microdesc",
".tmp");
1066 RENAME_SUFFIX(
"my-consensus-ns",
".tmp");
1069#define STAT_DATADIR(name) \
1070 sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname(name))
1072#define STAT_CACHEDIR(name) \
1073 sandbox_cfg_allow_stat_filename(&cfg, get_cachedir_fname(name))
1075#define STAT_DATADIR2(name, name2) \
1076 sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname2((name), (name2)))
1078#define STAT_KEY_DIRECTORY() \
1079 sandbox_cfg_allow_stat_filename(&cfg, tor_strdup(options->KeyDirectory))
1082 STAT_DATADIR(
"lock");
1083 STAT_DATADIR(
"state");
1084 STAT_DATADIR(
"router-stability");
1086 STAT_CACHEDIR(
"cached-extrainfo.new");
1095 smartlist_free(files);
1103 char *tmp_name = NULL;
1105 sandbox_cfg_allow_rename(&cfg,
1106 tor_strdup(tmp_name), tor_strdup(file_name));
1115 smartlist_free(files);
1116 smartlist_free(dirs);
1130 if (!port->is_unix_addr)
1134 char *dirname = tor_strdup(port->unix_addr);
1139 sandbox_cfg_allow_chmod_filename(&cfg, tor_strdup(port->unix_addr));
1140 sandbox_cfg_allow_chown_filename(&cfg, tor_strdup(port->unix_addr));
1141 } SMARTLIST_FOREACH_END(port);
1151 OPEN_KEYDIR_SUFFIX(
"secret_id_key",
".tmp");
1152 OPEN_KEYDIR_SUFFIX(
"secret_onion_key",
".tmp");
1153 OPEN_KEYDIR_SUFFIX(
"secret_onion_key_ntor",
".tmp");
1154 OPEN_KEYDIR(
"secret_id_key.old");
1155 OPEN_KEYDIR(
"secret_onion_key.old");
1156 OPEN_KEYDIR(
"secret_onion_key_ntor.old");
1158 OPEN_KEYDIR_SUFFIX(
"ed25519_master_id_secret_key",
".tmp");
1159 OPEN_KEYDIR_SUFFIX(
"ed25519_master_id_secret_key_encrypted",
".tmp");
1160 OPEN_KEYDIR_SUFFIX(
"ed25519_master_id_public_key",
".tmp");
1161 OPEN_KEYDIR_SUFFIX(
"ed25519_signing_secret_key",
".tmp");
1162 OPEN_KEYDIR_SUFFIX(
"ed25519_signing_secret_key_encrypted",
".tmp");
1163 OPEN_KEYDIR_SUFFIX(
"ed25519_signing_public_key",
".tmp");
1164 OPEN_KEYDIR_SUFFIX(
"ed25519_signing_cert",
".tmp");
1166 OPEN_DATADIR2_SUFFIX(
"stats",
"bridge-stats",
".tmp");
1167 OPEN_DATADIR2_SUFFIX(
"stats",
"dirreq-stats",
".tmp");
1169 OPEN_DATADIR2_SUFFIX(
"stats",
"entry-stats",
".tmp");
1170 OPEN_DATADIR2_SUFFIX(
"stats",
"exit-stats",
".tmp");
1171 OPEN_DATADIR2_SUFFIX(
"stats",
"buffer-stats",
".tmp");
1172 OPEN_DATADIR2_SUFFIX(
"stats",
"conn-stats",
".tmp");
1173 OPEN_DATADIR2_SUFFIX(
"stats",
"hidserv-stats",
".tmp");
1174 OPEN_DATADIR2_SUFFIX(
"stats",
"hidserv-v3-stats",
".tmp");
1176 OPEN_DATADIR(
"approved-routers");
1177 OPEN_DATADIR_SUFFIX(
"fingerprint",
".tmp");
1178 OPEN_DATADIR_SUFFIX(
"fingerprint-ed25519",
".tmp");
1179 OPEN_DATADIR_SUFFIX(
"hashed-fingerprint",
".tmp");
1180 OPEN_DATADIR_SUFFIX(
"router-stability",
".tmp");
1182 OPEN(
"/etc/resolv.conf");
1184 RENAME_SUFFIX(
"fingerprint",
".tmp");
1185 RENAME_SUFFIX(
"fingerprint-ed25519",
".tmp");
1186 RENAME_KEYDIR_SUFFIX(
"secret_onion_key_ntor",
".tmp");
1188 RENAME_KEYDIR_SUFFIX(
"secret_id_key",
".tmp");
1189 RENAME_KEYDIR_SUFFIX(
"secret_id_key.old",
".tmp");
1190 RENAME_KEYDIR_SUFFIX(
"secret_onion_key",
".tmp");
1191 RENAME_KEYDIR_SUFFIX(
"secret_onion_key.old",
".tmp");
1193 RENAME_SUFFIX2(
"stats",
"bridge-stats",
".tmp");
1194 RENAME_SUFFIX2(
"stats",
"dirreq-stats",
".tmp");
1195 RENAME_SUFFIX2(
"stats",
"entry-stats",
".tmp");
1196 RENAME_SUFFIX2(
"stats",
"exit-stats",
".tmp");
1197 RENAME_SUFFIX2(
"stats",
"buffer-stats",
".tmp");
1198 RENAME_SUFFIX2(
"stats",
"conn-stats",
".tmp");
1199 RENAME_SUFFIX2(
"stats",
"hidserv-stats",
".tmp");
1200 RENAME_SUFFIX2(
"stats",
"hidserv-v3-stats",
".tmp");
1201 RENAME_SUFFIX(
"hashed-fingerprint",
".tmp");
1202 RENAME_SUFFIX(
"router-stability",
".tmp");
1204 RENAME_KEYDIR_SUFFIX(
"ed25519_master_id_secret_key",
".tmp");
1205 RENAME_KEYDIR_SUFFIX(
"ed25519_master_id_secret_key_encrypted",
".tmp");
1206 RENAME_KEYDIR_SUFFIX(
"ed25519_master_id_public_key",
".tmp");
1207 RENAME_KEYDIR_SUFFIX(
"ed25519_signing_secret_key",
".tmp");
1208 RENAME_KEYDIR_SUFFIX(
"ed25519_signing_cert",
".tmp");
1210 sandbox_cfg_allow_rename(&cfg,
1211 get_keydir_fname(
"secret_onion_key"),
1212 get_keydir_fname(
"secret_onion_key.old"));
1213 sandbox_cfg_allow_rename(&cfg,
1214 get_keydir_fname(
"secret_onion_key_ntor"),
1215 get_keydir_fname(
"secret_onion_key_ntor.old"));
1217 STAT_KEY_DIRECTORY();
1218 OPEN_DATADIR(
"stats");
1219 STAT_DATADIR(
"stats");
1220 STAT_DATADIR2(
"stats",
"dirreq-stats");
1231run_tor_main_loop(
void)
1241 log_err(
LD_OR,
"Error initializing keys; exiting");
1254 char *fname = get_datadir_fname(
"key-pinning-journal");
1257 log_err(
LD_DIR,
"Error loading key-pinning journal: %s",strerror(errno));
1261 log_err(
LD_DIR,
"Error opening key-pinning journal: %s",strerror(errno));
1275 char *fname = get_datadir_fname(
"key-pinning-entries");
1282 "Couldn't load all cached v3 certificates. Starting anyway.");
1294 const time_t now = time(NULL);
1314 log_warn(
LD_GENERAL,
"Couldn't set up any working nameservers. "
1315 "Network not up yet? Will try again soon.");
1317 log_err(
LD_GENERAL,
"Error initializing dns subsystem; exiting. To "
1318 "retry instead, set the ServerDNSAllowBrokenResolvConf option.");
1324 const int r = sd_notify(0,
"READY=1");
1326 log_warn(
LD_GENERAL,
"Unable to send readiness to systemd: %s",
1329 log_notice(
LD_GENERAL,
"Signaled readiness to systemd");
1331 log_info(
LD_GENERAL,
"Systemd NOTIFY_SOCKET not present.");
1372#ifdef EVENT_SET_MEM_FUNCTIONS_IMPLEMENTED
1381 char **argv = tor_calloc(argc,
sizeof(
char*));
1382 memcpy(argv, tor_cfg->
argv, tor_cfg->
argc*
sizeof(
char*));
1388 result = nt_service_parse_options(argc, argv, &done);
1395 int init_rv =
tor_init(argc, argv);
1398 result = (init_rv < 0) ? -1 : 0;
1406#ifdef ENABLE_FRAGILE_HARDENING
1407 log_warn(
LD_CONFIG,
"Sandbox is enabled but this Tor was built using "
1408 "fragile compiler hardening. The sandbox may be unable to filter "
1409 "requests to open files and directories and its overall "
1410 "effectiveness will be reduced.");
1417 log_err(
LD_BUG,
"Failed to create syscall sandbox filter");
1421 tor_make_getaddrinfo_cache_active();
1424#ifdef HAVE_EVUTIL_SECURE_RNG_SET_URANDOM_DEVICE_FILE
1425 evutil_secure_rng_set_urandom_device_file(
1432 nt_service_set_state(SERVICE_RUNNING);
1433 result = run_tor_main_loop();
1454 printf(
"Configuration was valid\n");
1463 log_warn(
LD_BUG,
"Illegal command number %d: internal error.",
void addressmap_init(void)
void addressmap_clear_transient(void)
int trusted_dirs_reload_certs(void)
Header file for authcert.c.
int authdir_mode(const or_options_t *options)
Header file for directory authority mode.
void base16_encode(char *dest, size_t destlen, const char *src, size_t srclen)
size_t buf_allocation(const buf_t *buf)
Header file for buffers.c.
Header for feature/stats/bwhist.c.
void channel_dumpstats(int severity)
void channel_listener_dumpstats(int severity)
Header file for channel.c.
void channelpadding_new_consensus_params(const networkstatus_t *ns)
uint64_t stats_n_padding_cells_processed
void circuit_mark_all_dirty_circs_as_unusable(void)
void circuit_dump_by_conn(connection_t *conn, int severity)
Header file for circuitlist.c.
void circpad_machines_init(void)
void circpad_new_consensus_params(const networkstatus_t *ns)
Header file for circuitpadding.c.
uint64_t stats_n_created_cells_processed
uint64_t stats_n_destroy_cells_processed
uint64_t stats_n_relay_cells_processed
uint64_t stats_n_create_cells_processed
Header file for command.c.
const char * tor_libevent_get_version_str(void)
struct event_base * tor_libevent_get_base(void)
Header for compat_libevent.c.
const char * tor_compress_version_str(compress_method_t method)
int tor_compress_supports_method(compress_method_t method)
void tor_compress_log_init_warnings(void)
const char * get_torrc_fname(int defaults_fname)
const smartlist_t * get_configured_ports(void)
int options_init_from_torrc(int argc, char **argv)
static char * torrc_defaults_fname
void init_protocol_warning_severity_level(void)
char * options_dump(const or_options_t *options, int how_to_dump)
static char * torrc_fname
const or_options_t * get_options(void)
int set_options(or_options_t *new_val, char **msg)
tor_cmdline_mode_t command
parsed_cmdline_t * config_parse_commandline(int argc, char **argv, int ignore_errors)
Header file for config.c.
#define CONFIG_BACKUP_PATTERN
void congestion_control_new_consensus_params(const networkstatus_t *ns)
Public APIs for congestion control.
void flow_control_new_consensus_params(const networkstatus_t *ns)
APIs for stream flow control on congestion controlled circuits.
int connection_is_listener(connection_t *conn)
void connection_dump_buffer_mem_stats(int severity)
void connection_bucket_init(void)
const char * connection_describe(const connection_t *conn)
Header file for connection.c.
or_connection_t * TO_OR_CONN(connection_t *c)
Header file for connection_or.c.
void consdiffmgr_enable_background_compression(void)
int consdiffmgr_register_with_sandbox(struct sandbox_cfg_elem_t **cfg)
Header for consdiffmgr.c.
Header file for control.c.
char * get_controller_cookie_file_name(void)
Header file for control_auth.c.
void control_event_bootstrap(bootstrap_status_t status, int progress)
int control_event_signal(uintptr_t signal_num)
Header file for control_events.c.
void cpuworker_log_onionskin_overhead(int severity, int onionskin_type, const char *onionskin_type_name)
void cpuworkers_rotate_keyinfo(void)
Header file for cpuworker.c.
const char * crypto_get_library_version_string(void)
const char * crypto_get_library_name(void)
Headers for crypto_init.c.
void crypto_rand(char *to, size_t n)
Common functions for using (pseudo-)random number generators.
int crypto_pk_get_fingerprint(crypto_pk_t *pk, char *fp_out, int add_space)
void secret_to_key_rfc2440(char *key_out, size_t key_out_len, const char *secret, size_t secret_len, const char *s2k_specifier)
#define S2K_RFC2440_SPECIFIER_LEN
void router_reset_status_download_failures(void)
void dump_dns_mem_usage(int severity)
char * get_ext_or_auth_cookie_file_name(void)
int write_str_to_file(const char *fname, const char *str, int bin)
int tor_unlink(const char *pathname)
int accounting_record_bandwidth_usage(time_t now, or_state_t *state)
int accounting_is_enabled(const or_options_t *options)
void hibernate_begin_shutdown(void)
Header file for hibernate.c.
Header file containing denial of service defenses for the HS subsystem for all versions.
void hs_service_lists_fnames_for_sandbox(smartlist_t *file_list, smartlist_t *dir_list)
void hs_service_dump_stats(int severity)
Header file containing service data for the HS subsystem.
int keypin_load_journal(const char *fname)
int keypin_open_journal(const char *fname)
const char * tor_libc_get_version_str(void)
const char * tor_libc_get_name(void)
Header for lib/osinfo/libc.c.
tor_lockfile_t * tor_lockfile_lock(const char *filename, int blocking, int *locked_out)
void tor_lockfile_unlock(tor_lockfile_t *lockfile)
void tor_log(int severity, log_domain_mask_t domain, const char *format,...)
void switch_logs_debug(void)
int get_min_log_level(void)
void log_set_application_name(const char *name)
void tor_log_get_logfile_names(smartlist_t *out)
static tor_lockfile_t * lockfile
int tor_run_main(const tor_main_configuration_t *tor_cfg)
static int do_dump_config(void)
static int do_list_fingerprint(void)
struct event * signal_event
void release_lockfile(void)
static void do_hash_password(void)
int tor_init(int argc, char *argv[])
int try_locking(const or_options_t *options, int err_if_locked)
static int do_keygen_family(const char *fname_base)
static void process_signal(int sig)
static void dumpstats(int severity)
static void dumpmemusage(int severity)
static void signal_callback(evutil_socket_t fd, short events, void *arg)
void tor_remove_file(const char *filename)
void handle_signals(void)
void pubsub_install(void)
void pubsub_connect(void)
uint64_t get_bytes_read(void)
void update_current_time(time_t now)
void do_signewnym(time_t now)
void initialize_mainloop_events(void)
void schedule_rescan_periodic_events(void)
smartlist_t * get_connection_array(void)
void tor_shutdown_event_loop_and_exit(int exitcode)
void tor_init_connection_lists(void)
void directory_info_has_arrived(time_t now, int from_cache, int suppress_logs)
uint64_t get_bytes_written(void)
time_t time_of_process_start
Header file for mainloop.c.
int tor_mainloop_connect_pubsub(struct pubsub_builder_t *builder)
void tor_mainloop_connect_pubsub_events(void)
int tor_mainloop_set_delivery_strategy(const char *msg_channel_name, deliv_strategy_t strategy)
Header for mainloop_pubsub.c.
void tor_free_(void *mem)
void * tor_malloc_(size_t size)
void * tor_realloc_(void *ptr, size_t size)
int net_is_disabled(void)
void set_network_participation(bool participation)
void reset_user_activity(time_t now)
void note_user_activity(time_t now)
void update_networkstatus_downloads(time_t now)
networkstatus_t * networkstatus_get_latest_consensus(void)
int router_reload_consensus_networkstatus(void)
Header file for networkstatus.c.
Header file for ntmain.c.
Master header file for Tor-specific functionality.
#define RELAY_PAYLOAD_SIZE_MAX
int get_parent_directory(char *fname)
Listener port configuration structure.
Header file for predict_ports.c.
int tor_asprintf(char **strp, const char *fmt,...)
int tor_snprintf(char *str, size_t size, const char *format,...)
int dirserv_load_fingerprint_file(void)
Header file for process_descs.c.
pubsub_builder_t * pubsub_builder_new(void)
Header used for constructing the OO publish-subscribe facility.
struct pubsub_builder_t pubsub_builder_t
quiet_level_t quiet_level
void add_default_log_for_quiet_level(quiet_level_t quiet)
Declare the quiet_level enumeration and global.
uint64_t stats_n_data_cells_received
void dump_cell_pool_usage(int severity)
uint64_t stats_n_relay_cells_relayed
uint64_t stats_n_data_cells_packaged
uint64_t stats_n_data_bytes_received
uint64_t stats_n_relay_cells_delivered
uint64_t stats_n_data_bytes_packaged
uint64_t rephist_total_alloc
void rep_hist_dump_stats(time_t now, int severity)
uint32_t rephist_total_num
Header file for rephist.c.
const char risky_option_list[]
Header for risky_options.c.
void router_reset_warnings(void)
int client_identity_key_is_set(void)
int load_ed_keys(const or_options_t *options, time_t now)
smartlist_t * list_family_key_files(const or_options_t *options, const char *keydir)
int create_family_id_key(const char *fname, ed25519_public_key_t *pk_out)
int log_cert_expiration(void)
int generate_ed_link_cert(const or_options_t *options, time_t now, int force)
int load_family_id_keys(const or_options_t *options, const networkstatus_t *ns)
void dump_routerlist_mem_usage(int severity)
int router_reload_router_list(void)
void routerlist_reset_warnings(void)
void router_reset_descriptor_download_failures(void)
Header file for routerlist.c.
int server_mode(const or_options_t *options)
Header file for routermode.c.
void routerparse_init(void)
Header file for routerparse.c.
int sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file)
int sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file)
sandbox_cfg_t * sandbox_cfg_new(void)
int sandbox_init(sandbox_cfg_t *cfg)
int sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file)
Header file for sandbox.c.
struct sandbox_cfg_elem_t sandbox_cfg_t
#define sandbox_intern_string(s)
int sr_init(int save_to_disk)
This file contains ABI/API of the shared random protocol defined in proposal #250....
void tor_free_all(int postfork)
Header file for shutdown.c.
smartlist_t * smartlist_new(void)
#define SMARTLIST_FOREACH_BEGIN(sl, type, var)
#define SMARTLIST_FOREACH(sl, type, var, cmd)
or_state_t * get_or_state(void)
int log_heartbeat(time_t now)
int DisableSignalHandlers
char * ServerDNSResolvConfFile
char * FamilyKeyDirectory
struct smartlist_t * FilesOpenedByIncludes
int BridgeAuthoritativeDir
quiet_level_t quiet_level
tor_cmdline_mode_t command
int subsystems_add_pubsub(pubsub_builder_t *builder)
int subsystems_init(void)
void timers_initialize(void)
Public C API for the Tor network service.
Internal declarations for in-process Tor API.
int tor_tls_get_buffer_sizes(tor_tls_t *tls, size_t *rbuf_capacity, size_t *rbuf_bytes, size_t *wbuf_capacity, size_t *wbuf_bytes)
const char * get_version(void)
const char * get_uname(void)
void notify_pending_waitpid_callbacks(void)
#define ED25519_BASE64_LEN