mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Remove get_bridge_pt_addrport().
The code was not disambiguating ClientTransportPlugin configured and not used, and ClientTransportPlugin configured, but in a failed state. The right thing to do is to undo moving the get_transport_by_addrport() call back into get_proxy_addrport(), and remove and explicit check for using a Bridge since by the time the check is made, if a Bridge is being used, it is PT/proxy-less.
This commit is contained in:
+12
-34
@@ -86,8 +86,6 @@ static int connection_read_https_proxy_response(connection_t *conn);
|
||||
static void connection_send_socks5_connect(connection_t *conn);
|
||||
static const char *proxy_type_to_string(int proxy_type);
|
||||
static int get_proxy_type(void);
|
||||
static int get_bridge_pt_addrport(tor_addr_t *addr, uint16_t *port,
|
||||
int *proxy_type, const connection_t *conn);
|
||||
|
||||
/** The last addresses that our network interface seemed to have been
|
||||
* binding to. We use this as one way to detect when our IP changes.
|
||||
@@ -4772,35 +4770,6 @@ assert_connection_ok(connection_t *conn, time_t now)
|
||||
}
|
||||
}
|
||||
|
||||
/** Fills <b>addr</b> and <b>port</b> with the details of the global
|
||||
* pluggable transport or bridge we are using.
|
||||
* <b>conn</b> contains the connection we are using the PT/bridge for.
|
||||
*
|
||||
* Return 0 on success, -1 on failure.
|
||||
*/
|
||||
static int
|
||||
get_bridge_pt_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
|
||||
const connection_t *conn)
|
||||
{
|
||||
const or_options_t *options = get_options();
|
||||
|
||||
if (options->ClientTransportPlugin || options->Bridges) {
|
||||
const transport_t *transport = NULL;
|
||||
int r;
|
||||
r = get_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
|
||||
if (r<0)
|
||||
return -1;
|
||||
if (transport) { /* transport found */
|
||||
tor_addr_copy(addr, &transport->addr);
|
||||
*port = transport->port;
|
||||
*proxy_type = transport->socks_version;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Fills <b>addr</b> and <b>port</b> with the details of the global
|
||||
* proxy server we are using.
|
||||
* <b>conn</b> contains the connection we are using the proxy for.
|
||||
@@ -4819,8 +4788,19 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
|
||||
* the config to have unused ClientTransportPlugin entries.
|
||||
*/
|
||||
if (options->ClientTransportPlugin) {
|
||||
if (get_bridge_pt_addrport(addr, port, proxy_type, conn) == 0)
|
||||
const transport_t *transport = NULL;
|
||||
int r;
|
||||
r = get_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
|
||||
if (r<0)
|
||||
return -1;
|
||||
if (transport) { /* transport found */
|
||||
tor_addr_copy(addr, &transport->addr);
|
||||
*port = transport->port;
|
||||
*proxy_type = transport->socks_version;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Unused ClientTransportPlugin. */
|
||||
}
|
||||
|
||||
if (options->HTTPSProxy) {
|
||||
@@ -4838,8 +4818,6 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
|
||||
*port = options->Socks5ProxyPort;
|
||||
*proxy_type = PROXY_SOCKS5;
|
||||
return 0;
|
||||
} else if (options->Bridges) {
|
||||
return get_bridge_pt_addrport(addr, port, proxy_type, conn);
|
||||
}
|
||||
|
||||
tor_addr_make_unspec(addr);
|
||||
|
||||
Reference in New Issue
Block a user