Use correct address family where necessary for bridges on IPv6.

This commit is contained in:
Linus Nordberg 2011-11-24 19:01:56 +01:00 committed by Nick Mathewson
parent f89c619679
commit 529820f8ba
4 changed files with 7 additions and 6 deletions

View File

@ -880,7 +880,8 @@ connection_create_listener(const struct sockaddr *listensockaddr,
return NULL;
}
if (listensockaddr->sa_family == AF_INET) {
if (listensockaddr->sa_family == AF_INET ||
listensockaddr->sa_family == AF_INET6) {
int is_tcp = (type != CONN_TYPE_AP_DNS_LISTENER);
if (is_tcp)
start_reading = 1;
@ -890,7 +891,7 @@ connection_create_listener(const struct sockaddr *listensockaddr,
log_notice(LD_NET, "Opening %s on %s:%d",
conn_type_to_string(type), fmt_addr(&addr), usePort);
s = tor_open_socket(PF_INET,
s = tor_open_socket(tor_addr_family(&addr),
is_tcp ? SOCK_STREAM : SOCK_DGRAM,
is_tcp ? IPPROTO_TCP: IPPROTO_UDP);
if (!SOCKET_OK(s)) {

View File

@ -2593,7 +2593,7 @@ connection_ap_make_link(connection_t *partner,
want_onehop ? "direct" : "anonymized",
safe_str_client(address), port);
conn = entry_connection_new(CONN_TYPE_AP, AF_INET);
conn = entry_connection_new(CONN_TYPE_AP, tor_addr_family(&partner->addr));
base_conn = ENTRY_TO_CONN(conn);
base_conn->linked = 1; /* so that we can add it safely below. */
@ -3199,7 +3199,7 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
exitconn->_base.state = EXIT_CONN_STATE_OPEN;
dirconn = dir_connection_new(AF_INET);
dirconn = dir_connection_new(tor_addr_family(&exitconn->_base.addr));
tor_addr_copy(&dirconn->_base.addr, &exitconn->_base.addr);
dirconn->_base.port = 0;

View File

@ -1036,7 +1036,7 @@ connection_or_connect(const tor_addr_t *_addr, uint16_t port,
return NULL;
}
conn = or_connection_new(AF_INET);
conn = or_connection_new(tor_addr_family(&addr));
/* set up conn so it's got all the data we need to remember */
connection_or_init_conn_from_address(conn, &addr, port, id_digest, 1);

View File

@ -919,7 +919,7 @@ directory_initiate_command_rend(const char *address, const tor_addr_t *_addr,
return;
}
conn = dir_connection_new(AF_INET);
conn = dir_connection_new(tor_addr_family(&addr));
/* set up conn so it's got all the data we need to remember */
tor_addr_copy(&conn->_base.addr, &addr);