Commit be7054c6 authored by Nick Mathewson's avatar Nick Mathewson 🐻
Browse files

r8607@Kushana: nickm | 2006-08-27 15:45:42 -0400

 Change configuration strategy for eventdns. Instead of elaborate option set, just allow the user to specify another resolv.conf to use.


svn:r8254
parent c38cc0eb
......@@ -96,10 +96,12 @@ N . Improve memory usage on tight-memory machines.
o Implement
. Enable
- Test
- Make the Nameservers option documented, and make it work right on
X Make the Nameservers option documented, and make it work right on
reload.
o Fail when we have no configured nameservers!
o Make it the default on platforms where it works.
- Make resolv.conf (or local equivalent) get checked on reload,
settable while running, etc.
- Add ipv6 support; make API closer to getaddrinfo(). (i.e., allow a
single AAAA/A query, return cname as well)
- Teach it to be able to listen for A and PTR requests to be processed.
......
......@@ -188,7 +188,6 @@ static config_var_t _option_vars[] = {
OBSOLETE("MonthlyAccountingStart"),
VAR("MyFamily", STRING, MyFamily, NULL),
VAR("NewCircuitPeriod", INTERVAL, NewCircuitPeriod, "30 seconds"),
VAR("Nameservers", CSV, Nameservers, ""),
VAR("NamingAuthoritativeDirectory",BOOL, NamingAuthoritativeDir, "0"),
VAR("Nickname", STRING, Nickname, NULL),
VAR("NoPublish", BOOL, NoPublish, "0"),
......@@ -216,11 +215,13 @@ static config_var_t _option_vars[] = {
VAR("RendNodes", STRING, RendNodes, NULL),
VAR("RendPostPeriod", INTERVAL, RendPostPeriod, "1 hour"),
VAR("RephistTrackTime", INTERVAL, RephistTrackTime, "24 hours"),
VAR("ResolvConf", STRING, ResolvConf, NULL),
OBSOLETE("RouterFile"),
VAR("RunAsDaemon", BOOL, RunAsDaemon, "0"),
VAR("RunTesting", BOOL, RunTesting, "0"),
VAR("SafeLogging", BOOL, SafeLogging, "1"),
VAR("SafeSocks", BOOL, SafeSocks, "0"),
VAR("SearchDomains", BOOL, SearchDomains, "0"),
VAR("ShutdownWaitLength", INTERVAL, ShutdownWaitLength, "30 seconds"),
VAR("SocksListenAddress", LINELIST, SocksListenAddress, NULL),
VAR("SocksPolicy", LINELIST, SocksPolicy, NULL),
......@@ -1982,7 +1983,9 @@ validate_ports_csv(smartlist_t *sl, const char *name, char **msg)
return 0;
}
/* Return 0 if every element of sl is a string holding an IP address, or if sl
#if 0
/* XXXX Unused. */
/** Return 0 if every element of sl is a string holding an IP address, or if sl
* is NULL. Otherwise set *msg and return -1. */
static int
validate_ips_csv(smartlist_t *sl, const char *name, char **msg)
......@@ -2005,6 +2008,7 @@ validate_ips_csv(smartlist_t *sl, const char *name, char **msg)
});
return 0;
}
#endif
/** Lowest allowable value for RendPostPeriod; if this is too low, hidden
* services can overload the directory system. */
......@@ -2239,9 +2243,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
if (validate_ports_csv(options->LongLivedPorts, "LongLivedPorts", msg) < 0)
return -1;
if (validate_ips_csv(options->Nameservers, "Nameservers", msg) < 0)
return -1;
if (options->FascistFirewall && !options->ReachableAddresses) {
if (options->FirewallPorts && smartlist_len(options->FirewallPorts)) {
/* We already have firewall ports set, so migrate them to
......
......@@ -952,6 +952,7 @@ dnsworker_main(void *data)
int *fdarray = data;
int fd;
int result;
int search = get_options()->SearchDomains;
/* log_fn(LOG_NOTICE,"After spawn: fdarray @%d has %d:%d", (int)fdarray,
* fdarray[0],fdarray[1]); */
......@@ -990,7 +991,7 @@ dnsworker_main(void *data)
spawn_exit();
}
/* Add a period to prevent local domain search, and NUL-terminate. */
if (address[address_len-1] != '.') {
if (address[address_len-1] != '.' && !search) {
address[address_len] = '.';
address[address_len+1] = '\0';
} else {
......@@ -1193,50 +1194,40 @@ static int
configure_nameservers(void)
{
or_options_t *options;
const char *conf_fname;
struct stat st;
if (nameservers_configured)
return 0;
options = get_options();
eventdns_set_log_fn(eventdns_log_cb);
if (options->Nameservers && smartlist_len(options->Nameservers)) {
log_info(LD_EXIT, "Configuring nameservers from Tor configuration");
SMARTLIST_FOREACH(options->Nameservers, const char *, ip,
{
struct in_addr in;
if (tor_inet_aton(ip, &in)) {
log_info(LD_EXIT, "Adding nameserver '%s'", ip);
if (eventdns_nameserver_add(in.s_addr))
log_warn(LD_EXIT, "Unable to add nameserver '%s'", ip);
}
});
conf_fname = options->ResolvConf;
#ifndef MS_WINDOWS
if (!conf_fname) conf_fname = "/etc/resolv.conf";
#endif
if (conf_fname) {
log_info(LD_EXIT, "Parsing resolver configuration in '%s'", conf_fname);
if (eventdns_resolv_conf_parse(DNS_OPTIONS_ALL, conf_fname))
return -1;
if (eventdns_count_nameservers() == 0) {
log_warn(LD_EXIT, "Unable to add any configured nameserver. "
"Either remove the Nameservers line from your configuration, "
"or put in a nameserver that we can parse.");
log_warn(LD_EXIT, "Unable to find any nameservers in '%s'.", conf_fname);
return -1;
}
} else {
}
#ifdef MS_WINDOWS
else {
if (eventdns_config_windows_nameservers())
return -1;
if (eventdns_count_nameservers() == 0) {
log_warn(LD_EXIT, "Unable to find any platform nameservers in "
"your Windows configuration. Perhaps you should add a "
"Nameservers line to your torrc?");
return -1;
}
#else
log_info(LD_EXIT, "Parsing /etc/resolv.conf");
if (eventdns_resolv_conf_parse(DNS_OPTION_NAMESERVERS|DNS_OPTION_MISC,
"/etc/resolv.conf"))
return -1;
if (eventdns_count_nameservers() == 0) {
log_warn(LD_EXIT, "Unable to find any platform nameservers in "
"/etc/resolv.conf. Perhaps you should add a Nameservers line "
"to your torrc?");
"your Windows configuration. Perhaps you should list a "
"ResolvConf file in your torrc?");
return -1;
}
#endif
}
#endif
nameservers_configured = 1;
return 0;
}
......@@ -1282,12 +1273,13 @@ launch_resolve(edge_connection_t *exitconn)
{
char *addr = tor_strdup(exitconn->_base.address);
int r;
int options = get_options()->SearchDomains ? 0 : DNS_QUERY_NO_SEARCH;
if (!nameservers_configured)
if (configure_nameservers() < 0)
return -1;
log_info(LD_EXIT, "Launching eventdns request for %s",
escaped_safe_str(exitconn->_base.address));
r = eventdns_resolve_ipv4(exitconn->_base.address, DNS_QUERY_NO_SEARCH,
r = eventdns_resolve_ipv4(exitconn->_base.address, options,
eventdns_callback, addr);
if (r) {
log_warn(LD_EXIT, "eventdns rejected address %s: error %d.",
......
......@@ -1556,8 +1556,12 @@ typedef struct {
char *VirtualAddrNetwork; /**< Address and mask to hand out for virtual
* MAPADDRESS requests. */
smartlist_t *Nameservers; /**< If provided, overrides the platform nameserver
* list. when using eventdns. */
int SearchDomains; /**< If provided, we don't force exit addresses to be
* fqdns, but rather search for them in the local
* domains. */
char *ResolvConf; /**< If provided, we configure our internal resolver from
* the file here rather than from /etc/resolv.conf (unix)
* or the registry (windows) */
} or_options_t;
/** Persistent state for an onion router, as saved to disk. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment