diff --git a/TODO b/TODO index 0ad8b932..d6084c89 100644 --- a/TODO +++ b/TODO @@ -15,10 +15,6 @@ represent user-visible changes. mirror remote FTP permissions by default. There should be a new option add an option that enables this back on. -* Implement a `--disable-dns-cache' option that disables DNS caching. - It is trivial to implement; simply avoid calling cache_host_lookup - at the end of lookup_host. - * Honor `Content-Disposition: XXX; filename="FILE"' when creating the file name. diff --git a/doc/ChangeLog b/doc/ChangeLog index a8c79c3e..1f0f1c09 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,7 @@ +2003-09-10 Hrvoje Niksic + + * wget.texi (Download Options): Documented new option --dns-cache. + 2002-04-24 Hrvoje Niksic * wget.texi (Robot Exclusion): Explain how to turn off the robot diff --git a/doc/wget.texi b/doc/wget.texi index d24459d5..19eb439a 100644 --- a/doc/wget.texi +++ b/doc/wget.texi @@ -16,8 +16,8 @@ @c This should really be generated automatically, possibly by including @c an auto-generated file. -@set VERSION 1.8.1+cvs -@set UPDATED December 2001 +@set VERSION 1.9-cvs +@set UPDATED September 2003 @dircategory Net Utilities @dircategory World Wide Web @@ -777,6 +777,29 @@ Thus you may safely type @samp{wget -Q2m -i sites}---download will be aborted when the quota is exceeded. Setting quota to 0 or to @samp{inf} unlimits the download quota. + +@cindex DNS cache +@cindex caching of DNS lookups +@itemx --dns-cache=off +Turn off caching of DNS lookups. Normally, Wget remembers the addresses +it looked up from DNS so it doesn't have to repeatedly contact the DNS +server for the same (typically small) set of addresses it retrieves +from. This cache exists in memory only; a new Wget run will contact DNS +again. + +However, in some cases it is not desirable to cache host names, even for +the duration of a short-running application like Wget. For example, +some HTTP servers are hosted on machines with dynamically allocated IP +addresses that change from time to time. Their DNS entries are updated +along with each change. When Wget's download from such a host gets +interrupted by IP address change, Wget retries the download, but (due to +DNS caching) it contacts the old address. With the DNS cache turned +off, Wget will repeat the DNS lookup for every connect and will thus get +the correct dynamic address every time---at the cost of additional DNS +lookups where they're probably not needed. + +If you don't understand the above description, you probably won't need +this option. @end table @node Directory Options, HTTP Options, Download Options, Invoking @@ -2046,6 +2069,10 @@ Top of directory tree---the same as @samp{-P}. Turning dirstruct on or off---the same as @samp{-x} or @samp{-nd}, respectively. +@item dns_cache = on/off +Turn DNS caching on/off. Since DNS caching is on by default, this +option is normally used to turn it off. Same as @samp{--dns-cache}. + @item domains = @var{string} Same as @samp{-D} (@pxref{Spanning Hosts}). diff --git a/src/ChangeLog b/src/ChangeLog index 73201fb7..e9137edd 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2003-09-10 Hrvoje Niksic + + * init.c: New command dns_cache. + + * main.c (main): New option --dns-cache[=off]. + 2003-09-09 Hrvoje Niksic * config.h.in: Initialize HAVE_GETADDRINFO and ENABLE_IPV6. diff --git a/src/host.c b/src/host.c index 382707db..9989022a 100644 --- a/src/host.c +++ b/src/host.c @@ -691,7 +691,8 @@ lookup_host (const char *host, int silent) logprintf (LOG_VERBOSE, _("done.\n")); /* Cache the lookup information. */ - cache_host_lookup (host, al); + if (opt.dns_cache) + cache_host_lookup (host, al); return al; } diff --git a/src/init.c b/src/init.c index e342b848..16ef2561 100644 --- a/src/init.c +++ b/src/init.c @@ -131,6 +131,7 @@ static struct { { "deleteafter", &opt.delete_after, cmd_boolean }, { "dirprefix", &opt.dir_prefix, cmd_directory }, { "dirstruct", NULL, cmd_spec_dirstruct }, + { "dnscache", &opt.dns_cache, cmd_boolean }, { "domains", &opt.domains, cmd_vector }, { "dotbytes", &opt.dot_bytes, cmd_bytes }, { "dotsinline", &opt.dots_in_line, cmd_number }, @@ -278,6 +279,8 @@ defaults (void) opt.dot_bytes = 1024; opt.dot_spacing = 10; opt.dots_in_line = 50; + + opt.dns_cache = 1; } /* Return the user's home directory (strdup-ed), or NULL if none is diff --git a/src/main.c b/src/main.c index cfcdbbe3..67bf55cd 100644 --- a/src/main.c +++ b/src/main.c @@ -178,6 +178,7 @@ Download:\n\ -Q, --quota=NUMBER set retrieval quota to NUMBER.\n\ --bind-address=ADDRESS bind to ADDRESS (hostname or IP) on local host.\n\ --limit-rate=RATE limit download rate to RATE.\n\ + --dns-cache=off disable caching DNS lookups.\n\ \n"), stdout); fputs (_("\ Directories:\n\ @@ -314,6 +315,7 @@ main (int argc, char *const *argv) { "cookies", required_argument, NULL, 160 }, { "cut-dirs", required_argument, NULL, 145 }, { "directory-prefix", required_argument, NULL, 'P' }, + { "dns-cache", required_argument, NULL, 175 }, { "domains", required_argument, NULL, 'D' }, { "dot-style", required_argument, NULL, 134 }, { "execute", required_argument, NULL, 'e' }, @@ -605,6 +607,9 @@ GNU General Public License for more details.\n")); case 168: setval ("postfile", optarg); break; + case 175: + setval ("dnscache", optarg); + break; case 'A': setval ("accept", optarg); break; diff --git a/src/options.h b/src/options.h index 518a50de..e7eff5e2 100644 --- a/src/options.h +++ b/src/options.h @@ -70,6 +70,7 @@ struct options char **domains; /* See host.c */ char **exclude_domains; + int dns_cache; /* whether we cache DNS lookups. */ char **follow_tags; /* List of HTML tags to recursively follow. */ char **ignore_tags; /* List of HTML tags to ignore if recursing. */