Cache control file
[tor/appveyor.git] / src / or / transports.h
blob1b2786472c2e1b65c81c8333cec3690dc88f2154
1 /* Copyright (c) 2003-2004, Roger Dingledine
2 * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3 * Copyright (c) 2007-2017, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
6 /**
7 * \file transports.h
8 * \brief Headers for transports.c
9 **/
11 #ifndef TOR_TRANSPORTS_H
12 #define TOR_TRANSPORTS_H
14 /** Represents a pluggable transport used by a bridge. */
15 typedef struct transport_t {
16 /** SOCKS version: One of PROXY_SOCKS4, PROXY_SOCKS5. */
17 int socks_version;
18 /** Name of pluggable transport protocol */
19 char *name;
20 /** The IP address where the transport bound and is waiting for
21 * connections. */
22 tor_addr_t addr;
23 /** Port of proxy */
24 uint16_t port;
25 /** Boolean: We are re-parsing our transport list, and we are going to remove
26 * this one if we don't find it in the list of configured transports. */
27 unsigned marked_for_removal : 1;
28 /** Arguments for this transport that must be written to the
29 extra-info descriptor. */
30 char *extra_info_args;
31 } transport_t;
33 void mark_transport_list(void);
34 void sweep_transport_list(void);
35 MOCK_DECL(int, transport_add_from_config,
36 (const tor_addr_t *addr, uint16_t port,
37 const char *name, int socks_ver));
38 void transport_free_(transport_t *transport);
39 #define transport_free(tr) FREE_AND_NULL(transport_t, transport_free_, (tr))
41 transport_t *transport_get_by_name(const char *name);
43 MOCK_DECL(void, pt_kickstart_proxy,
44 (const smartlist_t *transport_list, char **proxy_argv,
45 int is_server));
47 #define pt_kickstart_client_proxy(tl, pa) \
48 pt_kickstart_proxy(tl, pa, 0)
49 #define pt_kickstart_server_proxy(tl, pa) \
50 pt_kickstart_proxy(tl, pa, 1)
52 void pt_configure_remaining_proxies(void);
54 int pt_proxies_configuration_pending(void);
56 char *pt_get_extra_info_descriptor_string(void);
58 void pt_free_all(void);
60 void pt_prepare_proxy_list_for_config_read(void);
61 void sweep_proxy_list(void);
63 smartlist_t *get_transport_proxy_ports(void);
64 char *pt_stringify_socks_args(const smartlist_t *socks_args);
66 char *pt_get_socks_args_for_proxy_addrport(const tor_addr_t *addr,
67 uint16_t port);
69 #ifdef PT_PRIVATE
70 /** State of the managed proxy configuration protocol. */
71 enum pt_proto_state {
72 PT_PROTO_INFANT, /* was just born */
73 PT_PROTO_LAUNCHED, /* was just launched */
74 PT_PROTO_ACCEPTING_METHODS, /* accepting methods */
75 PT_PROTO_CONFIGURED, /* configured successfully */
76 PT_PROTO_COMPLETED, /* configure and registered its transports */
77 PT_PROTO_BROKEN, /* broke during the protocol */
78 PT_PROTO_FAILED_LAUNCH /* failed while launching */
81 /** Structure containing information of a managed proxy. */
82 typedef struct {
83 enum pt_proto_state conf_state; /* the current configuration state */
84 char **argv; /* the cli arguments of this proxy */
85 int conf_protocol; /* the configuration protocol version used */
87 char *proxy_uri; /* the outgoing proxy in TOR_PT_PROXY URI format */
88 unsigned int proxy_supported : 1; /* the proxy honors TOR_PT_PROXY */
90 int is_server; /* is it a server proxy? */
92 /* A pointer to the process handle of this managed proxy. */
93 process_handle_t *process_handle;
95 int pid; /* The Process ID this managed proxy is using. */
97 /** Boolean: We are re-parsing our config, and we are going to
98 * remove this managed proxy if we don't find it any transport
99 * plugins that use it. */
100 unsigned int marked_for_removal : 1;
102 /** Boolean: We got a SIGHUP while this proxy was running. We use
103 * this flag to signify that this proxy might need to be restarted
104 * so that it can listen for other transports according to the new
105 * torrc. */
106 unsigned int was_around_before_config_read : 1;
108 /* transports to-be-launched by this proxy */
109 smartlist_t *transports_to_launch;
111 /* The 'transports' list contains all the transports this proxy has
112 launched. */
113 smartlist_t *transports;
114 } managed_proxy_t;
116 STATIC int parse_cmethod_line(const char *line, managed_proxy_t *mp);
117 STATIC int parse_smethod_line(const char *line, managed_proxy_t *mp);
119 STATIC int parse_version(const char *line, managed_proxy_t *mp);
120 STATIC void parse_env_error(const char *line);
121 STATIC void parse_proxy_error(const char *line);
122 STATIC void handle_proxy_line(const char *line, managed_proxy_t *mp);
123 STATIC char *get_transport_options_for_server_proxy(const managed_proxy_t *mp);
125 STATIC void managed_proxy_destroy(managed_proxy_t *mp,
126 int also_terminate_process);
128 STATIC managed_proxy_t *managed_proxy_create(const smartlist_t *transport_list,
129 char **proxy_argv, int is_server);
131 STATIC int configure_proxy(managed_proxy_t *mp);
133 STATIC char* get_pt_proxy_uri(void);
135 STATIC void free_execve_args(char **arg);
137 #endif /* defined(PT_PRIVATE) */
139 #endif /* !defined(TOR_TRANSPORTS_H) */