[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add options to turn DNS cache use on or off per client port.
commit d3e9e03cacda3d99f3c585fd7bc00b3dd2390d61
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sun Nov 25 13:18:26 2012 -0500
Add options to turn DNS cache use on or off per client port.
(This is part 1 of making DNS cache use enabled/disabled on a
per-client port basis. These options are shuffled around correctly,
but don't do anything yet.)
---
src/or/config.c | 29 ++++++++++++++++++++++++++++-
src/or/connection.c | 11 +++++++++++
src/or/or.h | 20 ++++++++++++++++++++
3 files changed, 59 insertions(+), 1 deletions(-)
diff --git a/src/or/config.c b/src/or/config.c
index e91d244..d0d0049 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -4790,6 +4790,7 @@ parse_port_config(smartlist_t *out,
cfg->isolation_flags = ISO_DEFAULT;
cfg->no_advertise = 1;
cfg->ipv4_traffic = 1;
+ cfg->cache_ipv4_answers = cfg->use_cached_ipv4_answers = 1;
smartlist_add(out, cfg);
}
}
@@ -4814,6 +4815,7 @@ parse_port_config(smartlist_t *out,
cfg->session_group = SESSION_GROUP_UNSET;
cfg->isolation_flags = ISO_DEFAULT;
cfg->ipv4_traffic = 1;
+ cfg->cache_ipv4_answers = cfg->use_cached_ipv4_answers = 1;
smartlist_add(out, cfg);
}
return 0;
@@ -4834,7 +4836,9 @@ parse_port_config(smartlist_t *out,
int ok;
int no_listen = 0, no_advertise = 0, all_addrs = 0,
bind_ipv4_only = 0, bind_ipv6_only = 0,
- ipv4_traffic = 1, ipv6_traffic = 0, prefer_ipv6 = 0;
+ ipv4_traffic = 1, ipv6_traffic = 0, prefer_ipv6 = 0,
+ cache_ipv4 = 1, use_cached_ipv4 = 1,
+ cache_ipv6 = 0, use_cached_ipv6 = 0;
smartlist_split_string(elts, ports->value, NULL,
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
@@ -4971,6 +4975,25 @@ parse_port_config(smartlist_t *out,
continue;
}
}
+ if (!strcasecmp(elt, "CacheIPv4DNS")) {
+ cache_ipv4 = ! no;
+ continue;
+ } else if (!strcasecmp(elt, "CacheIPv6DNS")) {
+ cache_ipv6 = ! no;
+ continue;
+ } else if (!strcasecmp(elt, "CacheDNS")) {
+ cache_ipv4 = cache_ipv6 = ! no;
+ continue;
+ } else if (!strcasecmp(elt, "UseIPv4Cache")) {
+ use_cached_ipv4 = ! no;
+ continue;
+ } else if (!strcasecmp(elt, "UseIPv6Cache")) {
+ use_cached_ipv6 = ! no;
+ continue;
+ } else if (!strcasecmp(elt, "UseDNSCache")) {
+ use_cached_ipv4 = use_cached_ipv6 = ! no;
+ continue;
+ }
if (!strcasecmpend(elt, "s"))
elt[strlen(elt)-1] = '\0'; /* kill plurals. */
@@ -5024,6 +5047,10 @@ parse_port_config(smartlist_t *out,
cfg->ipv4_traffic = ipv4_traffic;
cfg->ipv6_traffic = ipv6_traffic;
cfg->prefer_ipv6 = prefer_ipv6;
+ cfg->cache_ipv4_answers = cache_ipv4;
+ cfg->cache_ipv6_answers = cache_ipv6;
+ cfg->use_cached_ipv4_answers = use_cached_ipv4;
+ cfg->use_cached_ipv6_answers = use_cached_ipv6;
smartlist_add(out, cfg);
}
diff --git a/src/or/connection.c b/src/or/connection.c
index 223bbd9..1395d3e 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1130,6 +1130,10 @@ connection_listener_new(const struct sockaddr *listensockaddr,
lis_conn->socks_ipv4_traffic = 1;
lis_conn->socks_ipv6_traffic = 1;
}
+ lis_conn->cache_ipv4_answers = port_cfg->cache_ipv4_answers;
+ lis_conn->cache_ipv6_answers = port_cfg->cache_ipv6_answers;
+ lis_conn->use_cached_ipv4_answers = port_cfg->use_cached_ipv4_answers;
+ lis_conn->use_cached_ipv6_answers = port_cfg->use_cached_ipv6_answers;
if (connection_add(conn) < 0) { /* no space, forget it */
log_warn(LD_NET,"connection_add for listener failed. Giving up.");
@@ -1366,6 +1370,13 @@ connection_init_accepted_conn(connection_t *conn,
TO_ENTRY_CONN(conn)->ipv4_traffic_ok = listener->socks_ipv4_traffic;
TO_ENTRY_CONN(conn)->ipv6_traffic_ok = listener->socks_ipv6_traffic;
TO_ENTRY_CONN(conn)->prefer_ipv6_traffic = listener->socks_prefer_ipv6;
+ TO_ENTRY_CONN(conn)->cache_ipv4_answers = listener->cache_ipv4_answers;
+ TO_ENTRY_CONN(conn)->cache_ipv6_answers = listener->cache_ipv6_answers;
+ TO_ENTRY_CONN(conn)->use_cached_ipv4_answers =
+ listener->use_cached_ipv4_answers;
+ TO_ENTRY_CONN(conn)->use_cached_ipv6_answers =
+ listener->use_cached_ipv6_answers;
+
switch (TO_CONN(listener)->type) {
case CONN_TYPE_AP_LISTENER:
conn->state = AP_CONN_STATE_SOCKS_WAIT;
diff --git a/src/or/or.h b/src/or/or.h
index 06a74f6..a2c4122 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1237,6 +1237,12 @@ typedef struct listener_connection_t {
* addresses? */
unsigned int socks_prefer_ipv6 : 1;
+ /*DOCDOC*/
+ unsigned int cache_ipv4_answers : 1;
+ unsigned int cache_ipv6_answers : 1;
+ unsigned int use_cached_ipv4_answers : 1;
+ unsigned int use_cached_ipv6_answers : 1;
+
} listener_connection_t;
/** Minimum length of the random part of an AUTH_CHALLENGE cell. */
@@ -1545,6 +1551,12 @@ typedef struct entry_connection_t {
/** Should we say we prefer IPv6 traffic? */
unsigned int prefer_ipv6_traffic : 1;
+ /* DOCDOC*/
+ unsigned int cache_ipv4_answers : 1;
+ unsigned int cache_ipv6_answers : 1;
+ unsigned int use_cached_ipv4_answers : 1;
+ unsigned int use_cached_ipv6_answers : 1;
+
} entry_connection_t;
/** Subtype of connection_t for an "directory connection" -- that is, an HTTP
@@ -3084,10 +3096,18 @@ typedef struct port_cfg_t {
unsigned int all_addrs : 1;
unsigned int bind_ipv4_only : 1;
unsigned int bind_ipv6_only : 1;
+
+ /* Client port types only: */
unsigned int ipv4_traffic : 1;
unsigned int ipv6_traffic : 1;
unsigned int prefer_ipv6 : 1;
+ /* DOCDOC */
+ unsigned int cache_ipv4_answers : 1;
+ unsigned int cache_ipv6_answers : 1;
+ unsigned int use_cached_ipv4_answers : 1;
+ unsigned int use_cached_ipv6_answers : 1;
+
/* Unix sockets only: */
/** Path for an AF_UNIX address */
char unix_addr[FLEXIBLE_ARRAY_MEMBER];
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits