We can now connect using transports as well!

This commit is contained in:
George Kadianakis 2011-06-12 00:14:11 +02:00
parent e09f302589
commit 29203b7f3f
3 changed files with 42 additions and 0 deletions

View File

@ -100,6 +100,7 @@ static int count_acceptable_nodes(smartlist_t *routers);
static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
static void entry_guards_changed(void);
static void transport_free(transport_info_t *transport);
/**
* This function decides if CBT learning should be disabled. It returns
@ -4803,6 +4804,26 @@ find_bridge_by_digest(const char *digest)
return NULL;
}
/** If <b>addr</b> and <b>port</b> match one of our known bridges,
* returns it's transport protocol if it has one, else returns NULL.
*/
transport_info_t *
find_bridge_transport_by_addrport(const tor_addr_t *addr, uint16_t port)
{
SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, bridge)
{
if (tor_addr_eq(&bridge->addr, addr) &&
(bridge->port == port)) {
if (bridge->transport) {
log_debug(LD_GENERAL, "Found matching bridge!\n");
return bridge->transport;
} else /* bridge found, but it had no transport */
return NULL;
}
} SMARTLIST_FOREACH_END(bridge);
return NULL;
}
/** We need to ask <b>bridge</b> for its server descriptor. */
static void
launch_direct_bridge_descriptor_fetch(bridge_info_t *bridge)

View File

@ -148,5 +148,8 @@ void clear_transport_list(void);
int match_bridges_with_transports(void);
void transport_add_from_config(const tor_addr_t *addr, uint16_t port,
const char *name, int socks_ver);
transport_info_t *
find_bridge_transport_by_addrport(const tor_addr_t *addr, uint16_t port);
#endif

View File

@ -335,6 +335,14 @@ connection_or_finished_connecting(or_connection_t *or_conn)
proxy_type = PROXY_SOCKS4;
else if (get_options()->Socks5Proxy)
proxy_type = PROXY_SOCKS5;
else if (get_options()->UseBridges) {
transport_info_t *transport;
transport = find_bridge_transport_by_addrport(&conn->addr,conn->port);
if (transport) { /* this bridge supports transports. use proxy. */
log_warn(LD_GENERAL, "Setting up pluggable transport plugin proxy type!\n");
proxy_type = transport->socks_version;
}
}
if (proxy_type != PROXY_NONE) {
/* start proxy handshake */
@ -861,6 +869,16 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
using_proxy = 1;
tor_addr_copy(&addr, &options->Socks5ProxyAddr);
port = options->Socks5ProxyPort;
} else if (options->ClientTransportPlugin) {
transport_info_t *transport;
transport = find_bridge_transport_by_addrport(&addr, port);
if (transport) {
log_warn(LD_GENERAL, "Our bridge uses a pluggable transport plugin. "
"Setting up proxying!");
using_proxy = 1;
tor_addr_copy(&addr, &transport->addr);
port = transport->port;
}
}
switch (connection_connect(TO_CONN(conn), conn->_base.address,