tor  0.4.2.0-alpha-dev
Macros | Functions | Variables
transports.c File Reference
#include "core/or/or.h"
#include "feature/client/bridges.h"
#include "app/config/config.h"
#include "core/mainloop/connection.h"
#include "core/or/circuitbuild.h"
#include "feature/client/transports.h"
#include "feature/relay/router.h"
#include "app/config/statefile.h"
#include "core/or/connection_or.h"
#include "feature/relay/ext_orport.h"
#include "feature/control/control_events.h"
#include "lib/encoding/confline.h"
#include "lib/encoding/kvline.h"
#include "lib/process/process.h"
#include "lib/process/env.h"

Go to the source code of this file.

Macros

#define PT_PRIVATE
 
#define parse_server_method_error(l)   parse_method_error(l, 1)
 
#define parse_client_method_error(l)   parse_method_error(l, 0)
 
#define PROTO_ENV_ERROR   "ENV-ERROR"
 
#define PROTO_NEG_SUCCESS   "VERSION"
 
#define PROTO_NEG_FAIL   "VERSION-ERROR no-version"
 
#define PROTO_CMETHOD   "CMETHOD"
 
#define PROTO_SMETHOD   "SMETHOD"
 
#define PROTO_CMETHOD_ERROR   "CMETHOD-ERROR"
 
#define PROTO_SMETHOD_ERROR   "SMETHOD-ERROR"
 
#define PROTO_CMETHODS_DONE   "CMETHODS DONE"
 
#define PROTO_SMETHODS_DONE   "SMETHODS DONE"
 
#define PROTO_PROXY_DONE   "PROXY DONE"
 
#define PROTO_PROXY_ERROR   "PROXY-ERROR"
 
#define PROTO_LOG   "LOG"
 
#define PROTO_STATUS   "STATUS"
 
#define PROTO_VERSION_ONE   1
 

Functions

static smartlist_tcreate_managed_proxy_environment (const managed_proxy_t *mp)
 
static int proxy_configuration_finished (const managed_proxy_t *mp)
 
static void handle_finished_proxy (managed_proxy_t *mp)
 
static void parse_method_error (const char *line, int is_server_method)
 
STATIC transport_ttransport_new (const tor_addr_t *addr, uint16_t port, const char *name, int socks_ver, const char *extra_info_args)
 
void transport_free_ (transport_t *transport)
 
void mark_transport_list (void)
 
void sweep_transport_list (void)
 
static void clear_transport_list (void)
 
static transport_ttransport_copy (const transport_t *transport)
 
 MOCK_IMPL (transport_t *, transport_get_by_name,(const char *name))
 
static int transport_resolve_conflicts (const transport_t *t)
 
static int transport_add (transport_t *t)
 
 MOCK_IMPL (int, transport_add_from_config,(const tor_addr_t *addr, uint16_t port, const char *name, int socks_ver))
 
int pt_proxies_configuration_pending (void)
 
static void assert_unconfigured_count_ok (void)
 
static int managed_proxy_has_argv (const managed_proxy_t *mp, char **proxy_argv)
 
static managed_proxy_t * get_managed_proxy_by_argv_and_type (char **proxy_argv, int is_server)
 
static void add_transport_to_proxy (const char *transport, managed_proxy_t *mp)
 
static int proxy_needs_restart (const managed_proxy_t *mp)
 
static void proxy_prepare_for_restart (managed_proxy_t *mp)
 
static int launch_managed_proxy (managed_proxy_t *mp)
 
void pt_configure_remaining_proxies (void)
 
STATIC int configure_proxy (managed_proxy_t *mp)
 
static void register_server_proxy (const managed_proxy_t *mp)
 
static void register_client_proxy (const managed_proxy_t *mp)
 
static void register_proxy (const managed_proxy_t *mp)
 
STATIC void managed_proxy_destroy (managed_proxy_t *mp, int also_terminate_process)
 
STATIC char * get_pt_proxy_uri (void)
 
static void handle_methods_done (const managed_proxy_t *mp)
 
STATIC void handle_proxy_line (const char *line, managed_proxy_t *mp)
 
STATIC void parse_env_error (const char *line)
 
STATIC int parse_version (const char *line, managed_proxy_t *mp)
 
static int parse_method_line_helper (const char *line, managed_proxy_t *mp, int is_smethod)
 
STATIC int parse_smethod_line (const char *line, managed_proxy_t *mp)
 
STATIC int parse_cmethod_line (const char *line, managed_proxy_t *mp)
 
STATIC void parse_proxy_error (const char *line)
 
STATIC void parse_log_line (const char *line, managed_proxy_t *mp)
 
STATIC void parse_status_line (const char *line, managed_proxy_t *mp)
 
STATIC char * get_transport_options_for_server_proxy (const managed_proxy_t *mp)
 
static char * get_bindaddr_for_server_proxy (const managed_proxy_t *mp)
 
STATIC managed_proxy_t * managed_proxy_create (const smartlist_t *with_transport_list, char **proxy_argv, int is_server)
 
 MOCK_IMPL (void, pt_kickstart_proxy,(const smartlist_t *with_transport_list, char **proxy_argv, int is_server))
 
STATIC void free_execve_args (char **arg)
 
void pt_prepare_proxy_list_for_config_read (void)
 
smartlist_tget_transport_proxy_ports (void)
 
char * pt_get_extra_info_descriptor_string (void)
 
char * pt_stringify_socks_args (const smartlist_t *socks_args)
 
char * pt_get_socks_args_for_proxy_addrport (const tor_addr_t *addr, uint16_t port)
 
void sweep_proxy_list (void)
 
void pt_free_all (void)
 
char * tor_escape_str_for_pt_args (const char *string, const char *chars_to_escape)
 
STATIC void managed_proxy_stdout_callback (process_t *process, const char *line, size_t size)
 
STATIC void managed_proxy_stderr_callback (process_t *process, const char *line, size_t size)
 
STATIC bool managed_proxy_exit_callback (process_t *process, process_exit_code_t exit_code)
 
STATIC int managed_proxy_severity_parse (const char *severity)
 

Variables

static smartlist_ttransport_list = NULL
 
static smartlist_tmanaged_proxy_list = NULL
 
static int unconfigured_proxies_n = 0
 
static int check_if_restarts_needed = 0
 

Detailed Description

Pluggable Transports related code.

Each managed proxy is represented by a managed_proxy_t. Each managed proxy can support multiple transports. Each managed proxy gets configured through a multistep process.

managed_proxy_list contains all the managed proxies this tor instance is supporting. In the managed_proxy_list there are unconfigured_proxies_n managed proxies that are still unconfigured.

In every run_scheduled_event() tick, we attempt to launch and then configure the unconfiged managed proxies, using the configuration protocol defined in the 180_pluggable_transport.txt proposal. A managed proxy might need several ticks to get fully configured.

When a managed proxy is fully configured, we register all its transports to the circuitbuild.c subsystem. At that point the transports are owned by the circuitbuild.c subsystem.

When a managed proxy fails to follow the 180 configuration protocol, it gets marked as broken and gets destroyed.

In a little more detail:

While we are serially parsing torrc, we store all the transports that a proxy should spawn in its transports_to_launch element.

When we finish reading the torrc, we spawn the managed proxy and expect {S,C}METHOD lines from its output. We add transports described by METHOD lines to its transports element, as transport_t structs.

When the managed proxy stops spitting METHOD lines (signified by a '{S,C}METHODS DONE' message) we pass copies of its transports to the bridge subsystem. We keep copies of the 'transport_t's on the managed proxy to be able to associate the proxy with its transports, and we pass copies to the bridge subsystem so that transports can be associated with bridges. [ XXX We should try see whether the two copies are really needed and maybe cut it into a single copy of the 'transport_t' shared between the managed proxy and the bridge subsystem. Preliminary analysis shows that both copies are needed with the current code logic, because of race conditions that can cause dangling pointers. ]

In even more detail, this is what happens when a config read (like a SIGHUP or a SETCONF) occurs:

We immediately destroy all unconfigured proxies (We shouldn't have unconfigured proxies in the first place, except when the config read happens immediately after tor is launched.).

We mark all managed proxies and transports to signify that they must be removed if they don't contribute by the new torrc (we mark using the marked_for_removal element). We also mark all managed proxies to signify that they might need to be restarted so that they end up supporting all the transports the new torrc wants them to support (we mark using the was_around_before_config_read element). We also clear their transports_to_launch list so that we can put there the transports we need to launch according to the new torrc.

We then start parsing torrc again.

Everytime we encounter a transport line using a managed proxy that was around before the config read, we cleanse that proxy from the removal mark. We also toggle the check_if_restarts_needed flag, so that on the next pt_configure_remaining_proxies tick, we investigate whether we need to restart the proxy so that it also spawns the new transports. If the post-config-read transports_to_launch list is identical to the pre-config-read one, it means that no changes were introduced to this proxy during the config read and no restart has to take place.

During the post-config-read torrc parsing, we unmark all transports spawned by managed proxies that we find in our torrc. We do that so that if we don't need to restart a managed proxy, we can continue using its old transports normally. If we end up restarting the proxy, we destroy and unregister all old transports from the circuitbuild.c subsystem.

Definition in file transports.c.

Macro Definition Documentation

◆ PROTO_ENV_ERROR

#define PROTO_ENV_ERROR   "ENV-ERROR"

Managed proxy protocol strings

Definition at line 121 of file transports.c.

◆ PROTO_VERSION_ONE

#define PROTO_VERSION_ONE   1

The first and only supported - at the moment - configuration protocol version.

Definition at line 137 of file transports.c.

Function Documentation

◆ add_transport_to_proxy()

static void add_transport_to_proxy ( const char *  transport,
managed_proxy_t *  mp 
)
static

Add transport to managed proxy mp.

Definition at line 436 of file transports.c.

References smartlist_add_strdup(), smartlist_contains_string(), and tor_assert().

◆ assert_unconfigured_count_ok()

static void assert_unconfigured_count_ok ( void  )
static

Assert that the unconfigured_proxies_n value correctly matches the number of proxies in a state other than PT_PROTO_COMPLETE.

Definition at line 379 of file transports.c.

References managed_proxy_list, SMARTLIST_FOREACH, tor_assert(), and unconfigured_proxies_n.

Referenced by pt_prepare_proxy_list_for_config_read(), and sweep_proxy_list().

◆ clear_transport_list()

static void clear_transport_list ( void  )
static

Initialize the pluggable transports list to empty, creating it if needed.

Definition at line 203 of file transports.c.

References SMARTLIST_FOREACH, and transport_list.

Referenced by pt_free_all().

◆ configure_proxy()

STATIC int configure_proxy ( managed_proxy_t *  mp)

Attempt to continue configuring managed proxy mp. Return 1 if the transport configuration finished, and return 0 otherwise (if we still have more configuring to do for this proxy).

Definition at line 621 of file transports.c.

References handle_finished_proxy(), launch_managed_proxy(), and tor_assert().

◆ create_managed_proxy_environment()

static smartlist_t * create_managed_proxy_environment ( const managed_proxy_t *  mp)
static

Return a newly allocated process_environment_t * for mp's process.

Definition at line 1341 of file transports.c.

References get_current_process_environment_variables().

Referenced by launch_managed_proxy().

◆ free_execve_args()

STATIC void free_execve_args ( char **  arg)

Frees the array of pointers in arg used as arguments to execve(2).

Definition at line 1541 of file transports.c.

References tor_free, and tor_free_().

◆ get_bindaddr_for_server_proxy()

static char* get_bindaddr_for_server_proxy ( const managed_proxy_t *  mp)
static

Return the string that tor should place in TOR_PT_SERVER_BINDADDR while configuring the server managed proxy in mp. The string is stored in the heap, and it's the responsibility of the caller to deallocate it after its use.

Definition at line 1314 of file transports.c.

References get_stored_bindaddr_for_server_transport(), smartlist_add_asprintf(), SMARTLIST_FOREACH_BEGIN, tor_assert(), and tor_free.

◆ get_managed_proxy_by_argv_and_type()

static managed_proxy_t* get_managed_proxy_by_argv_and_type ( char **  proxy_argv,
int  is_server 
)
static

Return a managed proxy with the same argv as proxy_argv. If no such managed proxy exists, return NULL.

Definition at line 420 of file transports.c.

References managed_proxy_has_argv(), managed_proxy_list, and SMARTLIST_FOREACH_BEGIN.

Referenced by MOCK_IMPL().

◆ get_pt_proxy_uri()

STATIC char* get_pt_proxy_uri ( void  )

◆ get_transport_options_for_server_proxy()

STATIC char* get_transport_options_for_server_proxy ( const managed_proxy_t *  mp)

Return a newly allocated string that tor should place in TOR_PT_SERVER_TRANSPORT_OPTIONS while configuring the server manged proxy in mp. Return NULL if no such options are found.

Loop over the transports of the proxy. If we have options for any of them, format them appropriately and place them in our smartlist. Finally, join our smartlist to get the final string.

Loop over the options of this transport, escape them, and place them in the smartlist.

Definition at line 1269 of file transports.c.

References get_options_for_server_transport(), smartlist_add_asprintf(), SMARTLIST_FOREACH_BEGIN, tor_assert(), tor_escape_str_for_pt_args(), and tor_free.

◆ get_transport_proxy_ports()

smartlist_t* get_transport_proxy_ports ( void  )

Return a smartlist containing the ports where our pluggable transports are listening.

XXX assume that external proxy ports have been forwarded manually

Definition at line 1589 of file transports.c.

References managed_proxy_list, smartlist_add_asprintf(), SMARTLIST_FOREACH, SMARTLIST_FOREACH_BEGIN, and tor_assert().

Referenced by get_list_of_ports_to_forward().

◆ handle_finished_proxy()

static void handle_finished_proxy ( managed_proxy_t *  mp)
static

Handle a configured or broken managed proxy mp.

Definition at line 768 of file transports.c.

References managed_proxy_destroy().

Referenced by configure_proxy().

◆ handle_methods_done()

static void handle_methods_done ( const managed_proxy_t *  mp)
static

This function is called when a proxy sends an {S,C}METHODS DONE message.

Definition at line 813 of file transports.c.

References tor_assert().

◆ handle_proxy_line()

STATIC void handle_proxy_line ( const char *  line,
managed_proxy_t *  mp 
)

Handle a configuration protocol line received from a managed proxy mp.

Definition at line 830 of file transports.c.

◆ launch_managed_proxy()

static int launch_managed_proxy ( managed_proxy_t *  mp)
static

◆ managed_proxy_create()

STATIC managed_proxy_t* managed_proxy_create ( const smartlist_t with_transport_list,
char **  proxy_argv,
int  is_server 
)

Create and return a new managed proxy for transport using proxy_argv. Also, add it to the global managed proxy list. If is_server is true, it's a server managed proxy. Takes ownership of proxy_argv.

Requires that proxy_argv have at least one element.

Definition at line 1459 of file transports.c.

Referenced by MOCK_IMPL().

◆ managed_proxy_destroy()

STATIC void managed_proxy_destroy ( managed_proxy_t *  mp,
int  also_terminate_process 
)

Free memory allocated by managed proxy mp.

Definition at line 693 of file transports.c.

References SMARTLIST_FOREACH.

Referenced by handle_finished_proxy(), pt_prepare_proxy_list_for_config_read(), and sweep_proxy_list().

◆ managed_proxy_exit_callback()

STATIC bool managed_proxy_exit_callback ( process_t process,
process_exit_code_t  exit_code 
)

Callback function that is called when our PT process terminates. The process exit code can be found in exit_code and our process can be found in process. Returns true iff we want the process subsystem to free our process_t handle for us.

Definition at line 1866 of file transports.c.

References tor_assert().

Referenced by launch_managed_proxy().

◆ managed_proxy_has_argv()

static int managed_proxy_has_argv ( const managed_proxy_t *  mp,
char **  proxy_argv 
)
static

Return true if mp has the same argv as proxy_argv

Definition at line 398 of file transports.c.

References tor_assert().

Referenced by get_managed_proxy_by_argv_and_type().

◆ managed_proxy_severity_parse()

STATIC int managed_proxy_severity_parse ( const char *  severity)

Returns a valid integer log severity level from severity that is compatible with Tor's logging functions. Returns -1 on error.

Definition at line 1883 of file transports.c.

References LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_NOTICE, LOG_WARN, and tor_assert().

◆ managed_proxy_stderr_callback()

STATIC void managed_proxy_stderr_callback ( process_t process,
const char *  line,
size_t  size 
)

Callback function that is called when our PT process have data on its stderr. Our process can be found in process, the data can be found in line and the length of our line is given in size.

Definition at line 1844 of file transports.c.

References process_get_data(), and tor_assert().

Referenced by launch_managed_proxy().

◆ managed_proxy_stdout_callback()

STATIC void managed_proxy_stdout_callback ( process_t process,
const char *  line,
size_t  size 
)

Callback function that is called when our PT process have data on its stdout. Our process can be found in process, the data can be found in line and the length of our line is given in size.

Definition at line 1818 of file transports.c.

References process_get_data(), and tor_assert().

Referenced by launch_managed_proxy().

◆ mark_transport_list()

void mark_transport_list ( void  )

Mark every entry of the transport list to be removed on our next call to sweep_transport_list unless it has first been un-marked.

Definition at line 177 of file transports.c.

References transport_t::marked_for_removal, SMARTLIST_FOREACH, and transport_list.

◆ MOCK_IMPL() [1/3]

MOCK_IMPL ( transport_t ,
transport_get_by_name  ,
(const char *name)   
)

Returns the transport in our transport list that has the name name. Else returns NULL.

Definition at line 232 of file transports.c.

◆ MOCK_IMPL() [2/3]

MOCK_IMPL ( int  ,
transport_add_from_config  ,
(const tor_addr_t *addr, uint16_t port, const char *name, int socks_ver)   
)

Remember a new pluggable transport proxy at addr:port. name is set to the name of the protocol this proxy uses. socks_ver is set to the SOCKS version of the proxy.

Definition at line 334 of file transports.c.

◆ MOCK_IMPL() [3/3]

MOCK_IMPL ( void  ,
pt_kickstart_proxy  ,
(const smartlist_t *with_transport_list, char **proxy_argv, int is_server)   
)

Register proxy with proxy_argv, supporting transports in transport_list, to the managed proxy subsystem. If is_server is true, then the proxy is a server proxy.

Takes ownership of proxy_argv.

Requires that proxy_argv be a NULL-terminated array of command-line elements, containing at least one element.

Definition at line 1494 of file transports.c.

References check_if_restarts_needed, get_managed_proxy_by_argv_and_type(), managed_proxy_create(), transport_t::marked_for_removal, and SMARTLIST_FOREACH_BEGIN.

◆ parse_cmethod_line()

STATIC int parse_cmethod_line ( const char *  line,
managed_proxy_t *  mp 
)

Parses a CMETHOD line, and if well-formed it registers the new transport in mp.

Definition at line 1128 of file transports.c.

References parse_method_line_helper().

◆ parse_env_error()

STATIC void parse_env_error ( const char *  line)

Parses an ENV-ERROR line and warns the user accordingly.

Definition at line 942 of file transports.c.

References PROTO_ENV_ERROR.

◆ parse_log_line()

STATIC void parse_log_line ( const char *  line,
managed_proxy_t *  mp 
)

Parses a LOG line and emit log events accordingly.

Definition at line 1152 of file transports.c.

References tor_assert().

◆ parse_method_error()

static void parse_method_error ( const char *  line,
int  is_server 
)
static

Parses {C,S}METHOD-ERROR line and warns the user accordingly. If is_server it is an SMETHOD-ERROR, otherwise it is a CMETHOD-ERROR.

Definition at line 980 of file transports.c.

◆ parse_method_line_helper()

static int parse_method_line_helper ( const char *  line,
managed_proxy_t *  mp,
int  is_smethod 
)
static

A helper for parse_{c,s}method_line(), bootstraps its functionalities. If is_smethod is true then the the line to parse is a SMETHOD line otherwise it is a CMETHOD line

Check for the proxy method sent to us in CMETHOD line.

Check for options in the SMETHOD line.

Logs info about line parsing success for client or server

Definition at line 1001 of file transports.c.

Referenced by parse_cmethod_line(), and parse_smethod_line().

◆ parse_proxy_error()

STATIC void parse_proxy_error ( const char *  line)

Parses an PROXY-ERROR line and warns the user accordingly.

Definition at line 1137 of file transports.c.

◆ parse_smethod_line()

STATIC int parse_smethod_line ( const char *  line,
managed_proxy_t *  mp 
)

Parses an SMETHOD line and if well-formed it registers the new transport in mp.

Definition at line 1118 of file transports.c.

References parse_method_line_helper().

◆ parse_status_line()

STATIC void parse_status_line ( const char *  line,
managed_proxy_t *  mp 
)

Parses a STATUS line and emit control events accordingly.

Definition at line 1218 of file transports.c.

References tor_assert().

◆ parse_version()

STATIC int parse_version ( const char *  line,
managed_proxy_t *  mp 
)

Handles a VERSION line. Updates the configuration protocol version in mp.

Definition at line 958 of file transports.c.

◆ proxy_configuration_finished()

static int proxy_configuration_finished ( const managed_proxy_t *  mp)
inlinestatic

Return true if the configuration of the managed proxy mp is finished.

Definition at line 804 of file transports.c.

◆ proxy_needs_restart()

static int proxy_needs_restart ( const managed_proxy_t *  mp)
static

Called when a SIGHUP occurs. Returns true if managed proxy mp needs to be restarted after the SIGHUP, based on the new torrc.

Definition at line 447 of file transports.c.

References get_pt_proxy_uri(), strcmp_opt(), and tor_assert().

◆ proxy_prepare_for_restart()

static void proxy_prepare_for_restart ( managed_proxy_t *  mp)
static

Managed proxy mp must be restarted. Do all the necessary preparations and then flag its state so that it will be relaunched in the next tick.

Definition at line 490 of file transports.c.

References transport_t::marked_for_removal, process_set_data(), process_terminate(), SMARTLIST_FOREACH_BEGIN, and tor_assert().

◆ pt_configure_remaining_proxies()

void pt_configure_remaining_proxies ( void  )

Check if any of the managed proxies we are currently trying to configure has anything new to say.

Definition at line 564 of file transports.c.

◆ pt_free_all()

void pt_free_all ( void  )

Release all storage held by the pluggable transports subsystem.

Definition at line 1754 of file transports.c.

References clear_transport_list(), and transport_list.

◆ pt_get_extra_info_descriptor_string()

char* pt_get_extra_info_descriptor_string ( void  )

Return the pluggable transport string that we should display in our extra-info descriptor. If we shouldn't display such a string, or we have nothing to display, return NULL. The string is allocated on the heap and it's the responsibility of the caller to free it.

Definition at line 1619 of file transports.c.

References fmt_addrport(), managed_proxy_list, smartlist_add_asprintf(), SMARTLIST_FOREACH_BEGIN, tor_addr_from_ipv4h, tor_addr_is_null(), tor_asprintf(), tor_assert(), and tor_free.

◆ pt_get_socks_args_for_proxy_addrport()

char* pt_get_socks_args_for_proxy_addrport ( const tor_addr_t addr,
uint16_t  port 
)

Return a string of the SOCKS arguments that we should pass to the pluggable transports proxy in addr:port according to 180_pluggable_transport.txt. The string is allocated on the heap and it's the responsibility of the caller to free it after use.

Definition at line 1722 of file transports.c.

References get_socks_args_by_bridge_addrport(), and pt_stringify_socks_args().

◆ pt_prepare_proxy_list_for_config_read()

void pt_prepare_proxy_list_for_config_read ( void  )

Tor will read its config. Prepare the managed proxy list so that proxies not used in the new config will shutdown, and proxies that need to spawn different transports will do so.

Definition at line 1556 of file transports.c.

References assert_unconfigured_count_ok(), managed_proxy_destroy(), managed_proxy_list, smartlist_clear(), SMARTLIST_DEL_CURRENT, SMARTLIST_FOREACH, SMARTLIST_FOREACH_BEGIN, tor_assert(), tor_free, and unconfigured_proxies_n.

◆ pt_proxies_configuration_pending()

int pt_proxies_configuration_pending ( void  )

Return true if there are still unconfigured managed proxies, or proxies that need restarting.

Definition at line 371 of file transports.c.

References check_if_restarts_needed, and unconfigured_proxies_n.

Referenced by fetch_bridge_descriptors().

◆ pt_stringify_socks_args()

char* pt_stringify_socks_args ( const smartlist_t socks_args)

Stringify the SOCKS arguments in socks_args according to 180_pluggable_transport.txt. The string is allocated on the heap and it's the responsibility of the caller to free it after use.

Definition at line 1686 of file transports.c.

References tor_assert().

Referenced by pt_get_socks_args_for_proxy_addrport().

◆ register_client_proxy()

static void register_client_proxy ( const managed_proxy_t *  mp)
static

Register all the transports supported by client managed proxy mp to the bridge subsystem.

Definition at line 654 of file transports.c.

References SMARTLIST_FOREACH_BEGIN, tor_assert(), transport_add(), and transport_copy().

Referenced by register_proxy().

◆ register_proxy()

static void register_proxy ( const managed_proxy_t *  mp)
inlinestatic

Register the transports of managed proxy mp.

Definition at line 683 of file transports.c.

References register_client_proxy(), and register_server_proxy().

◆ register_server_proxy()

static void register_server_proxy ( const managed_proxy_t *  mp)
static

Register server managed proxy mp transports to state

Definition at line 639 of file transports.c.

References save_transport_to_state(), SMARTLIST_FOREACH_BEGIN, and tor_assert().

Referenced by register_proxy().

◆ sweep_proxy_list()

void sweep_proxy_list ( void  )

The tor config was read. Destroy all managed proxies that were marked by a previous call to prepare_proxy_list_for_config_read() and are not used by the new config.

Definition at line 1738 of file transports.c.

References assert_unconfigured_count_ok(), managed_proxy_destroy(), managed_proxy_list, SMARTLIST_DEL_CURRENT, and SMARTLIST_FOREACH_BEGIN.

◆ sweep_transport_list()

void sweep_transport_list ( void  )

Remove every entry of the transport list that was marked with mark_transport_list if it has not subsequently been un-marked.

Definition at line 188 of file transports.c.

References SMARTLIST_DEL_CURRENT, SMARTLIST_FOREACH_BEGIN, and transport_list.

◆ tor_escape_str_for_pt_args()

char* tor_escape_str_for_pt_args ( const char *  string,
const char *  chars_to_escape 
)

Return a newly allocated string equal to string, except that every character in chars_to_escape is preceded by a backslash.

Definition at line 1780 of file transports.c.

References tor_assert().

Referenced by get_transport_options_for_server_proxy().

◆ transport_add()

static int transport_add ( transport_t t)
static

Add transport t to the internal list of pluggable transports. Returns 0 if the transport was added correctly, 1 if the same transport was already registered (in this case the caller must free the transport) and -1 if there was an error.

Definition at line 313 of file transports.c.

References smartlist_add(), tor_assert(), transport_list, and transport_resolve_conflicts().

Referenced by register_client_proxy().

◆ transport_copy()

static transport_t* transport_copy ( const transport_t transport)
static

Return a deep copy of transport.

Definition at line 213 of file transports.c.

References tor_assert().

Referenced by register_client_proxy().

◆ transport_free_()

void transport_free_ ( transport_t transport)

Free the pluggable transport struct transport.

Definition at line 164 of file transports.c.

References transport_t::extra_info_args, transport_t::name, and tor_free.

◆ transport_new()

STATIC transport_t* transport_new ( const tor_addr_t addr,
uint16_t  port,
const char *  name,
int  socks_ver,
const char *  extra_info_args 
)

Returns a transport_t struct for a transport proxy supporting the protocol name listening at addr:port using SOCKS version socks_ver.

Definition at line 146 of file transports.c.

◆ transport_resolve_conflicts()

static int transport_resolve_conflicts ( const transport_t t)
static

Resolve any conflicts that the insertion of transport t might cause. Return 0 if t is OK and should be registered, 1 if there is a transport identical to t already registered and -1 if t cannot be added due to conflicts.

Definition at line 254 of file transports.c.

References transport_t::addr, transport_t::marked_for_removal, transport_t::name, transport_t::port, and tor_addr_eq.

Referenced by transport_add().

Variable Documentation

◆ check_if_restarts_needed

int check_if_restarts_needed = 0
static

Boolean: True iff we might need to restart some proxies.

Definition at line 366 of file transports.c.

Referenced by MOCK_IMPL(), and pt_proxies_configuration_pending().

◆ managed_proxy_list

smartlist_t* managed_proxy_list = NULL
static

◆ transport_list

smartlist_t* transport_list = NULL
static

A list of pluggable transports found in torrc.

Definition at line 140 of file transports.c.

Referenced by clear_transport_list(), mark_transport_list(), parse_transport_line(), pt_free_all(), sweep_transport_list(), and transport_add().

◆ unconfigured_proxies_n

int unconfigured_proxies_n = 0
static

Number of still unconfigured proxies.

Definition at line 364 of file transports.c.

Referenced by assert_unconfigured_count_ok(), pt_prepare_proxy_list_for_config_read(), and pt_proxies_configuration_pending().