]> sjero.net Git - wget/commitdiff
[svn] New option --dns-cache.
authorhniksic <devnull@localhost>
Wed, 10 Sep 2003 19:41:54 +0000 (12:41 -0700)
committerhniksic <devnull@localhost>
Wed, 10 Sep 2003 19:41:54 +0000 (12:41 -0700)
TODO
doc/ChangeLog
doc/wget.texi
src/ChangeLog
src/host.c
src/init.c
src/main.c
src/options.h

diff --git a/TODO b/TODO
index 0ad8b9327a3dbb7316d5e611789f3230a0a1c50d..d6084c891762283498a0958e88f086f276514192 100644 (file)
--- 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.
 
index a8c79c3e918a75391b188a598e696a04fc1f09fe..1f0f1c09e5530a9d94ba09e6766585bc6cd8df1e 100644 (file)
@@ -1,3 +1,7 @@
+2003-09-10  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * wget.texi (Download Options): Documented new option --dns-cache.
+
 2002-04-24  Hrvoje Niksic  <hniksic@arsdigita.com>
 
        * wget.texi (Robot Exclusion): Explain how to turn off the robot
index d24459d586e6cf7c88f375ce9600c84971585a54..19eb439a26dc796d07f59fcb12afead817485ed3 100644 (file)
@@ -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}).
 
index 73201fb79535054b0291d320bcb73630253b51e7..e9137edd8a22c6df5ac2c3cd87d8a2d7c8b5f86a 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-10  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * init.c: New command dns_cache.
+
+       * main.c (main): New option --dns-cache[=off].
+
 2003-09-09  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * config.h.in: Initialize HAVE_GETADDRINFO and ENABLE_IPV6.
index 382707db4f4d151029e9e85b69326b246769ec01..9989022ac592e74d381b82eeb16879fbbe94aef0 100644 (file)
@@ -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;
 }
index e342b848ccb8bdfd207888f0cbaffde5294d48f2..16ef2561d4f2345abdbc79b67319e5022b7fc213 100644 (file)
@@ -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;
 }
 \f
 /* Return the user's home directory (strdup-ed), or NULL if none is
index cfcdbbe3ad52f9e72fefbbaa31fb4505231d62a7..67bf55cdda2a791b0c847836a3c0ef3dfa588291 100644 (file)
@@ -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;
index 518a50def859087382e27ede11b98bd3a03b9f19..e7eff5e2766a663804370c494dbdfeafab905c13 100644 (file)
@@ -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. */