[tor-commits] [tor/master] Merge branch 'bug8546_squashed'
nickm at torproject.org
nickm at torproject.org
Fri Jan 16 14:32:28 UTC 2015
commit 4b23b398a307e9d1503ebcb1adf0b92a30f145b1
Merge: d807c7c 15dd690
Author: Nick Mathewson <nickm at torproject.org>
Date: Fri Jan 16 09:31:50 2015 -0500
Merge branch 'bug8546_squashed'
Conflicts:
src/or/connection.c
src/or/or.h
src/or/relay.c
changes/bug8546 | 6 ++
src/or/addressmap.c | 8 +--
src/or/config.c | 88 ++++++++++++------------
src/or/connection.c | 59 ++++++----------
src/or/connection_edge.c | 52 +++++++-------
src/or/dnsserv.c | 20 +++---
src/or/or.h | 165 ++++++++++++++-------------------------------
src/or/relay.c | 14 ++--
src/or/router.c | 4 +-
src/test/test_relaycell.c | 12 ++--
10 files changed, 175 insertions(+), 253 deletions(-)
diff --cc src/or/config.c
index 982cb2e,b6d9d4e..23edd3a
--- a/src/or/config.c
+++ b/src/or/config.c
@@@ -6070,65 -6021,13 +6070,65 @@@ parse_unix_socket_config(smartlist_t *o
if (!out)
return 0;
+ ports_to_add = smartlist_new();
+
for ( ; cfg; cfg = cfg->next) {
- size_t len = strlen(cfg->value);
- port_cfg_t *port = tor_malloc_zero(sizeof(port_cfg_t) + len + 1);
- port->is_unix_addr = 1;
- memcpy(port->unix_addr, cfg->value, len+1);
- port->type = listener_type;
- smartlist_add(out, port);
+ if (strcmp(cfg->value, "0") != 0) {
+ /* We have a non-disable; add it */
+ len = strlen(cfg->value);
+ port_cfg_t *port = tor_malloc_zero(sizeof(port_cfg_t) + len + 1);
+ port->is_unix_addr = 1;
+ memcpy(port->unix_addr, cfg->value, len+1);
+ port->type = listener_type;
+ if (listener_type == CONN_TYPE_AP_LISTENER) {
+ /* Some more bits to twiddle for this case
+ *
+ * XXX this should support parsing the same options
+ * parse_port_config() does, and probably that code should be
+ * factored out into a function we can call from here. For
+ * now, some reasonable defaults.
+ */
+
- port->ipv4_traffic = 1;
- port->ipv6_traffic = 1;
- port->cache_ipv4_answers = 1;
- port->cache_ipv6_answers = 1;
++ port->entry_cfg.ipv4_traffic = 1;
++ port->entry_cfg.ipv6_traffic = 1;
++ port->entry_cfg.cache_ipv4_answers = 1;
++ port->entry_cfg.cache_ipv6_answers = 1;
+ }
+ smartlist_add(ports_to_add, port);
+ } else {
+ /* Keep track that we've seen a disable */
+ unix_socket_disable = 1;
+ }
+ }
+
+ if (unix_socket_disable) {
+ if (smartlist_len(ports_to_add) > 0) {
+ /* We saw a disable line and a path; bad news */
+ SMARTLIST_FOREACH(ports_to_add, port_cfg_t *, port, tor_free(port));
+ smartlist_free(ports_to_add);
+ return -1;
+ }
+ /* else we have a disable and nothing else, so add nothing to out */
+ } else {
+ /* No disable; do we have any ports to add that we parsed? */
+ if (smartlist_len(ports_to_add) > 0) {
+ SMARTLIST_FOREACH_BEGIN(ports_to_add, port_cfg_t *, port) {
+ smartlist_add(out, port);
+ } SMARTLIST_FOREACH_END(port);
+ } else if (defaults != NULL && smartlist_len(defaults) > 0) {
+ /* No, but we have some defaults to copy */
+ SMARTLIST_FOREACH_BEGIN(defaults, const port_cfg_t *, defport) {
+ tor_assert(defport->is_unix_addr);
+ tor_assert(defport->unix_addr);
+ len = sizeof(port_cfg_t) + strlen(defport->unix_addr) + 1;
+ port_cfg_t *port = tor_malloc_zero(len);
+ memcpy(port, defport, len);
+ smartlist_add(out, port);
+ } SMARTLIST_FOREACH_END(defport);
+ }
+
+ /* Free the temporary smartlist we used */
+ smartlist_free(ports_to_add);
}
return 0;
diff --cc src/or/connection.c
index 11ff224,707bf73..ccd8231
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@@ -305,11 -305,9 +305,11 @@@ entry_connection_new(int type, int sock
* in a little while. Otherwise, we're doing this as a linked connection
* of some kind, and we should set it up here based on the socket family */
if (socket_family == AF_INET)
- entry_conn->ipv4_traffic_ok = 1;
+ entry_conn->entry_cfg.ipv4_traffic = 1;
else if (socket_family == AF_INET6)
- entry_conn->ipv6_traffic_ok = 1;
+ entry_conn->entry_cfg.ipv6_traffic = 1;
+ else if (socket_family == AF_UNIX)
+ entry_conn->is_socks_socket = 1;
return entry_conn;
}
@@@ -1499,19 -1411,6 +1493,15 @@@ connection_handle_listener_read(connect
newconn->port = port;
newconn->address = tor_dup_addr(&addr);
+ if (new_type == CONN_TYPE_AP && conn->socket_family != AF_UNIX) {
+ log_info(LD_NET, "New SOCKS connection opened from %s.",
+ fmt_and_decorate_addr(&addr));
- TO_ENTRY_CONN(newconn)->socks_request->socks_prefer_no_auth =
- TO_LISTENER_CONN(conn)->socks_prefer_no_auth;
+ }
+ if (new_type == CONN_TYPE_AP && conn->socket_family == AF_UNIX) {
+ newconn->port = 0;
+ newconn->address = tor_strdup(conn->address);
+ log_info(LD_NET, "New SOCKS SocksSocket connection opened");
- TO_ENTRY_CONN(newconn)->socks_request->socks_prefer_no_auth =
- TO_LISTENER_CONN(conn)->socks_prefer_no_auth;
+ }
if (new_type == CONN_TYPE_CONTROL) {
log_notice(LD_CONTROL, "New control connection opened from %s.",
fmt_and_decorate_addr(&addr));
diff --cc src/or/or.h
index 8a15529,56a40eb..7568fc1
--- a/src/or/or.h
+++ b/src/or/or.h
@@@ -1675,36 -1673,6 +1673,8 @@@ typedef struct entry_connection_t
*/
unsigned int may_use_optimistic_data : 1;
- /** Should we permit IPv4 and IPv6 traffic to use this connection?
- *
- * @{ */
- unsigned int ipv4_traffic_ok : 1;
- unsigned int ipv6_traffic_ok : 1;
- /** @} */
- /** Should we say we prefer IPv6 traffic? */
- unsigned int prefer_ipv6_traffic : 1;
-
- /** For a socks listener: should we cache IPv4/IPv6 DNS information that
- * exit nodes tell us?
- *
- * @{ */
- unsigned int cache_ipv4_answers : 1;
- unsigned int cache_ipv6_answers : 1;
- /** @} */
- /** For a socks listeners: if we find an answer in our client-side DNS cache,
- * should we use it?
- *
- * @{ */
- unsigned int use_cached_ipv4_answers : 1;
- unsigned int use_cached_ipv6_answers : 1;
- /** @} */
- /** For socks listeners: When we can automap an address to IPv4 or IPv6,
- * do we prefer IPv6? */
- unsigned int prefer_ipv6_virtaddr : 1;
-
+ /** Are we a socks SocksSocket listener? */
+ unsigned int is_socks_socket:1;
-
} entry_connection_t;
typedef enum {
More information about the tor-commits
mailing list