Tor
0.4.7.0-alpha-dev
|
Implementation for Tor's control-socket interface. More...
#include "core/or/or.h"
#include "app/config/config.h"
#include "app/main/main.h"
#include "core/mainloop/connection.h"
#include "core/mainloop/mainloop.h"
#include "core/or/connection_or.h"
#include "core/proto/proto_control0.h"
#include "core/proto/proto_http.h"
#include "feature/control/control.h"
#include "feature/control/control_auth.h"
#include "feature/control/control_cmd.h"
#include "feature/control/control_events.h"
#include "feature/control/control_proto.h"
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_service.h"
#include "lib/evloop/procmon.h"
#include "feature/control/control_connection_st.h"
Go to the source code of this file.
Macros | |
#define | CONTROL_MODULE_PRIVATE |
#define | CONTROL_PRIVATE |
#define | MAX_COMMAND_LINE_LENGTH (1024*1024) |
Variables | |
const struct signal_name_t | signal_table [] |
static const char | CONTROLPORT_IS_NOT_AN_HTTP_PROXY_MSG [] |
static int | network_is_live = 0 |
static char * | owning_controller_process_spec = NULL |
static tor_process_monitor_t * | owning_controller_process_monitor = NULL |
Implementation for Tor's control-socket interface.
A "controller" is an external program that monitors and controls a Tor instance via a text-based protocol. It connects to Tor via a connection to a local socket.
The protocol is line-driven. The controller sends commands terminated by a CRLF. Tor sends lines that are either replies to what the controller has said, or events that Tor sends to the controller asynchronously based on occurrences in the Tor network model.
See the control-spec.txt file in the torspec.git repository for full details on protocol.
This module generally has two kinds of entry points: those based on having received a command on a controller socket, which are handled in connection_control_process_inbuf(), and dispatched to individual functions with names like control_handle_COMMANDNAME(); and those based on events that occur elsewhere in Tor, which are handled by functions with names like control_event_EVENTTYPE().
Controller events are not sent immediately; rather, they are inserted into the queued_control_events array, and flushed later from flush_queued_events_cb(). Doing this simplifies our callgraph greatly, by limiting the number of places in Tor that can call back into the network stack.
Definition in file control.c.
#define MAX_COMMAND_LINE_LENGTH (1024*1024) |
void connection_control_closed | ( | control_connection_t * | conn | ) |
int connection_control_finished_flushing | ( | control_connection_t * | conn | ) |
Called when conn has no more bytes left on its outbuf.
Definition at line 201 of file control.c.
Referenced by connection_finished_flushing().
int connection_control_process_inbuf | ( | control_connection_t * | conn | ) |
Called when data has arrived on a v1 control connection: Try to fetch commands from conn->inbuf, and execute them.
Definition at line 418 of file control.c.
Referenced by connection_process_inbuf().
int connection_control_reached_eof | ( | control_connection_t * | conn | ) |
Called when conn has gotten its socket closed.
Definition at line 209 of file control.c.
Referenced by connection_reached_eof().
const control_connection_t* CONST_TO_CONTROL_CONN | ( | const connection_t * | c | ) |
Cast a const connection_t *
to a const control_connection_t *
.
Exit with an assertion failure if the input is not a control_connection_t
.
int control_connection_add_local_fd | ( | tor_socket_t | sock, |
unsigned | flags | ||
) |
void control_free_all | ( | void | ) |
void control_ports_write_to_file | ( | void | ) |
|
static |
|
static |
|
static |
Return an error on a control connection that tried to use the v0 protocol.
Definition at line 363 of file control.c.
Referenced by control_protocol_is_valid().
STATIC char* control_split_incoming_command | ( | char * | incoming_cmd, |
size_t * | data_len, | ||
char ** | current_cmd_out | ||
) |
|
static |
|
static |
Shut down this Tor instance in the same way that SIGINT would, but with a log message appropriate for the loss of an owning controller.
Definition at line 221 of file control.c.
Referenced by owning_controller_procmon_cb().
void monitor_owning_controller_process | ( | const char * | process_spec | ) |
|
static |
|
static |
Wrapper around peek_buf_has_control0 command: presents the same interface as that underlying functions, but takes a connection_t instead of a buf_t.
Definition at line 285 of file control.c.
Referenced by control_protocol_is_valid().
control_connection_t* TO_CONTROL_CONN | ( | connection_t * | c | ) |
Cast a connection_t *
to a control_connection_t *
.
Exit with an assertion failure if the input is not a control_connection_t
.
Definition at line 71 of file control.c.
Referenced by connection_finished_flushing(), connection_free_all(), connection_process_inbuf(), connection_reached_eof(), and CONST_TO_CONTROL_CONN().
|
static |
|
static |
|
static |
A process-termination monitor for Tor's owning controller, or NULL if this Tor instance is not currently owned by a process.
Definition at line 556 of file control.c.
Referenced by monitor_owning_controller_process().
|
static |
A copy of the process specifier of Tor's owning controller, or NULL if this Tor instance is not currently owned by a process.
Definition at line 552 of file control.c.
Referenced by monitor_owning_controller_process().
const struct signal_name_t signal_table[] |