]> sjero.net Git - wget/commitdiff
[svn] Added (currently no-op) -4 and -6.
authorhniksic <devnull@localhost>
Tue, 11 Nov 2003 21:48:35 +0000 (13:48 -0800)
committerhniksic <devnull@localhost>
Tue, 11 Nov 2003 21:48:35 +0000 (13:48 -0800)
src/ChangeLog
src/host.c
src/init.c
src/main.c
src/options.h

index c8486ce9d97fe0669264b53fee9afc51e6445f09..bf6919b3f077f4890c4ccbc664ef59b215771523 100644 (file)
@@ -1,3 +1,7 @@
+2003-11-11  Hrvoje Niksic  <hniksic@xemacs.org>
+
+       * main.c: Added options --inet4-only and --inet6-only.
+
 2003-11-11  Hrvoje Niksic  <hniksic@xemacs.org>
 
        * host.c (host_errstr): Use the more standard message "Unknown
index 7bc5b2f7b74f70ccc8bee82d95f8b5b27c79b850..3e29ad98bb5d9c95db7b10f809055269bb4fc6fa 100644 (file)
@@ -81,13 +81,6 @@ extern int h_errno;
 /* Mapping between known hosts and to lists of their addresses. */
 
 static struct hash_table *host_name_addresses_map;
-
-#ifdef ENABLE_IPV6
-/* The IP family to request when connecting to remote hosts.  This
-   should be moved to an entry in struct options when we implement the
-   --inet4/--inet6 flags.  */
-static int requested_family = AF_UNSPEC;
-#endif
 \f
 /* Lists of addresses.  This should eventually be extended to handle
    IPv6.  */
@@ -537,7 +530,8 @@ lookup_host (const char *host, int silent)
 
     xzero (hints);
     hints.ai_socktype = SOCK_STREAM;
-    hints.ai_family = requested_family;
+    hints.ai_family = AF_UNSPEC; /* #### should look at opt.ipv4_only
+                                   and opt.ipv6_only */
     hints.ai_flags = 0;
 
     err = getaddrinfo_with_timeout (host, NULL, &hints, &res, opt.dns_timeout);
@@ -550,6 +544,11 @@ lookup_host (const char *host, int silent)
       }
     al = address_list_from_addrinfo (res);
     freeaddrinfo (res);
+    if (!al)
+      {
+       logprintf (LOG_VERBOSE, _("failed: No IPv4/IPv6 addresses.\n"));
+       return NULL;
+      }
   }
 #else
   {
@@ -619,7 +618,8 @@ lookup_host_passive (const char *host)
 
   xzero (hints);
   hints.ai_socktype = SOCK_STREAM;
-  hints.ai_family = requested_family;
+  hints.ai_family = AF_UNSPEC; /* #### should look at opt.ipv4_only
+                                  and opt.ipv6_only */
   hints.ai_flags = AI_PASSIVE;
 
   err = getaddrinfo (host, NULL, &hints, &res);
index abafecddd00d97e4fe42c2a6c8c4b2f8921d7c25..182c06485f480283ccb77d29f9f250cf00bdd61a 100644 (file)
@@ -167,6 +167,10 @@ static struct {
   { "ignoretags",      &opt.ignore_tags,       cmd_vector },
   { "includedirectories", &opt.includes,       cmd_directory_vector },
   { "input",           &opt.input_filename,    cmd_file },
+#ifdef ENABLE_IPV6
+  { "inet4only",       &opt.ipv4_only,         cmd_boolean },
+  { "inet6only",       &opt.ipv6_only,         cmd_boolean },
+#endif
   { "keepsessioncookies", &opt.keep_session_cookies, cmd_boolean },
   { "killlonger",      &opt.kill_longer,       cmd_boolean },
   { "limitrate",       &opt.limit_rate,        cmd_bytes },
index 2cddd239a82fdf2be10ebe4a601c8bb488559a2d..eb6570ab8e4ad2023dcd1e48bd81e492e5318c6a 100644 (file)
@@ -194,6 +194,8 @@ struct cmdline_option option_data[] =
     { "ignore-length", 0, OPT_BOOLEAN, "ignorelength", -1 },
     { "ignore-tags", 0, OPT_VALUE, "ignoretags", -1 },
     { "include-directories", 'I', OPT_VALUE, "includedirectories", -1 },
+    { "inet4-only", '4', OPT_BOOLEAN, "inet4only", -1 },
+    { "inet6-only", '6', OPT_BOOLEAN, "inet6only", -1 },
     { "input-file", 'i', OPT_VALUE, "input", -1 },
     { "keep-session-cookies", 0, OPT_BOOLEAN, "keepsessioncookies", -1 },
     { "level", 'l', OPT_VALUE, "reclevel", -1 },
@@ -396,7 +398,7 @@ Logging and input file:\n"),
     N_("\
   -v,  --verbose             be verbose (this is the default).\n"),
     N_("\
-  -nv, --non-verbose         turn off verboseness, without being quiet.\n"),
+  -nv, --no-verbose         turn off verboseness, without being quiet.\n"),
     N_("\
   -i,  --input-file=FILE     download URLs found in FILE.\n"),
     N_("\
@@ -453,6 +455,10 @@ Download:\n"),
        --dns-cache=off           disable caching DNS lookups.\n"),
     N_("\
        --restrict-file-names=OS  restrict chars in file names to ones OS allows.\n"),
+    N_("\
+  -4,  --inet4-only              connect only to IPv4 addresses.\n"),
+    N_("\
+  -6,  --inet6-only              connect only to IPv6 addresses.\n"),
     "\n",
 
     N_("\
index e107fb09987a1a9cbf1dec15537102cc475ba1d8..00d89c349312ad1da002649fc0fe2c112bdf09b5 100644 (file)
@@ -199,6 +199,11 @@ struct options
 
   int preserve_perm;           /* whether remote permissions are used
                                  or that what is set by umask. */
+
+#ifdef ENABLE_IPV6
+  int ipv4_only;               /* IPv4 connections have been requested. */
+  int ipv6_only;               /* IPv4 connections have been requested. */
+#endif
 };
 
 extern struct options opt;