Tor
0.4.7.0-alpha-dev
|
Invocation module. Initializes subsystems and runs the main loop. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/config/statefile.h"
#include "app/config/quiet_level.h"
#include "app/main/main.h"
#include "app/main/ntmain.h"
#include "app/main/risky_options.h"
#include "app/main/shutdown.h"
#include "app/main/subsysmgr.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/cpuworker.h"
#include "core/mainloop/mainloop.h"
#include "core/mainloop/mainloop_pubsub.h"
#include "core/mainloop/netstatus.h"
#include "core/or/channel.h"
#include "core/or/channelpadding.h"
#include "core/or/circuitpadding.h"
#include "core/or/circuitlist.h"
#include "core/or/command.h"
#include "core/or/connection_or.h"
#include "core/or/relay.h"
#include "core/or/status.h"
#include "feature/api/tor_api.h"
#include "feature/api/tor_api_internal.h"
#include "feature/client/addressmap.h"
#include "feature/control/control.h"
#include "feature/control/control_auth.h"
#include "feature/control/control_events.h"
#include "feature/dirauth/keypin.h"
#include "feature/dirauth/process_descs.h"
#include "feature/dircache/consdiffmgr.h"
#include "feature/dirparse/routerparse.h"
#include "feature/hibernate/hibernate.h"
#include "feature/hs/hs_dos.h"
#include "feature/hs/hs_service.h"
#include "feature/nodelist/authcert.h"
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/routerlist.h"
#include "feature/relay/dns.h"
#include "feature/relay/ext_orport.h"
#include "feature/relay/routerkeys.h"
#include "feature/relay/routermode.h"
#include "feature/stats/predict_ports.h"
#include "feature/stats/bwhist.h"
#include "feature/stats/rephist.h"
#include "lib/compress/compress.h"
#include "lib/buf/buffers.h"
#include "lib/crypt_ops/crypto_format.h"
#include "lib/crypt_ops/crypto_rand.h"
#include "lib/crypt_ops/crypto_s2k.h"
#include "lib/net/resolve.h"
#include "lib/trace/trace.h"
#include "lib/process/waitpid.h"
#include "lib/pubsub/pubsub_build.h"
#include "lib/meminfo/meminfo.h"
#include "lib/osinfo/uname.h"
#include "lib/osinfo/libc.h"
#include "lib/sandbox/sandbox.h"
#include "lib/fs/lockfile.h"
#include "lib/tls/tortls.h"
#include "lib/evloop/compat_libevent.h"
#include "lib/encoding/confline.h"
#include "lib/evloop/timers.h"
#include "lib/crypt_ops/crypto_init.h"
#include "lib/version/torversion.h"
#include <event2/event.h>
#include "feature/dirauth/authmode.h"
#include "feature/dirauth/shared_random.h"
#include "core/or/or_connection_st.h"
#include "core/or/port_cfg_st.h"
Go to the source code of this file.
Macros | |
#define | UNIX_ONLY 1 |
#define | OPEN(name) sandbox_cfg_allow_open_filename(&cfg, tor_strdup(name)) |
#define | OPENDIR(dir) sandbox_cfg_allow_opendir_dirname(&cfg, tor_strdup(dir)) |
#define | OPEN_DATADIR(name) sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname(name)) |
#define | OPEN_DATADIR2(name, name2) sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname2((name), (name2))) |
#define | OPEN_DATADIR_SUFFIX(name, suffix) |
#define | OPEN_DATADIR2_SUFFIX(name, name2, suffix) |
#define | OPEN_KEY_DIRECTORY() OPEN(options->KeyDirectory) |
#define | OPEN_CACHEDIR(name) sandbox_cfg_allow_open_filename(&cfg, get_cachedir_fname(name)) |
#define | OPEN_CACHEDIR_SUFFIX(name, suffix) |
#define | OPEN_KEYDIR(name) sandbox_cfg_allow_open_filename(&cfg, get_keydir_fname(name)) |
#define | OPEN_KEYDIR_SUFFIX(name, suffix) |
#define | RENAME_SUFFIX(name, suffix) |
#define | RENAME_SUFFIX2(prefix, name, suffix) |
#define | RENAME_CACHEDIR_SUFFIX(name, suffix) |
#define | RENAME_KEYDIR_SUFFIX(name, suffix) |
#define | STAT_DATADIR(name) sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname(name)) |
#define | STAT_CACHEDIR(name) sandbox_cfg_allow_stat_filename(&cfg, get_cachedir_fname(name)) |
#define | STAT_DATADIR2(name, name2) sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname2((name), (name2))) |
#define | STAT_KEY_DIRECTORY() sandbox_cfg_allow_stat_filename(&cfg, tor_strdup(options->KeyDirectory)) |
Functions | |
static void | dumpmemusage (int severity) |
static void | dumpstats (int severity) |
static void | process_signal (int sig) |
static int | do_hup (void) |
static void | signal_callback (evutil_socket_t fd, short events, void *arg) |
void | handle_signals (void) |
void | activate_signal (int signal_num) |
int | tor_init (int argc, char *argv[]) |
int | try_locking (const or_options_t *options, int err_if_locked) |
int | have_lockfile (void) |
void | release_lockfile (void) |
void | tor_remove_file (const char *filename) |
static int | do_list_fingerprint (void) |
static void | do_hash_password (void) |
static int | do_dump_config (void) |
static void | init_addrinfo (void) |
static sandbox_cfg_t * | sandbox_init_filter (void) |
int | run_tor_main_loop (void) |
void | pubsub_install (void) |
void | pubsub_connect (void) |
int | tor_run_main (const tor_main_configuration_t *tor_cfg) |
Variables | |
struct { | |
int signal_value | |
int try_to_register | |
struct event * signal_event | |
} | signal_handlers [] |
static tor_lockfile_t * | lockfile = NULL |
Invocation module. Initializes subsystems and runs the main loop.
Definition in file main.c.
#define OPEN_CACHEDIR_SUFFIX | ( | name, | |
suffix | |||
) |
#define OPEN_DATADIR2_SUFFIX | ( | name, | |
name2, | |||
suffix | |||
) |
#define OPEN_DATADIR_SUFFIX | ( | name, | |
suffix | |||
) |
#define OPEN_KEYDIR_SUFFIX | ( | name, | |
suffix | |||
) |
#define RENAME_CACHEDIR_SUFFIX | ( | name, | |
suffix | |||
) |
#define RENAME_KEYDIR_SUFFIX | ( | name, | |
suffix | |||
) |
#define RENAME_SUFFIX | ( | name, | |
suffix | |||
) |
#define RENAME_SUFFIX2 | ( | prefix, | |
name, | |||
suffix | |||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
void handle_signals | ( | void | ) |
int have_lockfile | ( | void | ) |
|
static |
Do the work of acting on a signal received in sig
Definition at line 219 of file main.c.
Referenced by signal_callback().
void pubsub_connect | ( | void | ) |
void pubsub_install | ( | void | ) |
void release_lockfile | ( | void | ) |
|
static |
int tor_init | ( | int | argc, |
char * | argv[] | ||
) |
void tor_remove_file | ( | const char * | filename | ) |
Remove the specified file, and log a warning if the operation fails for any reason other than the file not existing. Ignores NULL filenames.
Definition at line 723 of file main.c.
Referenced by tor_cleanup().
int tor_run_main | ( | const tor_main_configuration_t * | tor_cfg | ) |
Run the tor process, as if from the command line.
The command line arguments from tor_main_configuration_set_command_line() are taken as if they had been passed to main().
This function will not return until Tor is done running. It returns zero on success, and nonzero on failure.
If you want to control when Tor exits, make sure to configure a control socket. The OwningControllerFD option may be helpful there.
BUG 23847: Sometimes, if you call tor_main a second time (after it has returned), Tor may crash or behave strangely. We have fixed all issues of this type that we could find, but more may remain.
LIMITATION: You cannot run more than one instance of Tor in the same process at the same time. Concurrent calls will cause undefined behavior. We do not currently have plans to change this.
LIMITATION: While we will try to fix any problems found here, you should be aware that Tor was originally written to run as its own process, and that the functionality of this file was added later. If you find any bugs or strange behavior, please report them, and we'll try to straighten them out.
int try_locking | ( | const or_options_t * | options, |
int | err_if_locked | ||
) |
Try to grab the lock file described in options, if we do not already have it. If err_if_locked is true, warn if somebody else is holding the lock, and exit if we can't get it after waiting. Otherwise, return -1 if we can't get the lockfile. Return 0 on success.
|
static |
A lockfile structure, used to prevent two Tors from messing with the data directory at once. If this variable is non-NULL, we're holding the lockfile.
Definition at line 659 of file main.c.
Referenced by have_lockfile(), release_lockfile(), tor_lockfile_unlock(), and try_locking().
struct event* signal_event |
int signal_value |