From 244efb6e50a2b084096f44587acfe84144821818 Mon Sep 17 00:00:00 2001 From: hniksic Date: Tue, 11 Nov 2003 13:48:35 -0800 Subject: [PATCH] [svn] Added (currently no-op) -4 and -6. --- src/ChangeLog | 4 ++++ src/host.c | 18 +++++++++--------- src/init.c | 4 ++++ src/main.c | 8 +++++++- src/options.h | 5 +++++ 5 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index c8486ce9..bf6919b3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2003-11-11 Hrvoje Niksic + + * main.c: Added options --inet4-only and --inet6-only. + 2003-11-11 Hrvoje Niksic * host.c (host_errstr): Use the more standard message "Unknown diff --git a/src/host.c b/src/host.c index 7bc5b2f7..3e29ad98 100644 --- a/src/host.c +++ b/src/host.c @@ -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 /* 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); diff --git a/src/init.c b/src/init.c index abafecdd..182c0648 100644 --- a/src/init.c +++ b/src/init.c @@ -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 }, diff --git a/src/main.c b/src/main.c index 2cddd239..eb6570ab 100644 --- a/src/main.c +++ b/src/main.c @@ -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_("\ diff --git a/src/options.h b/src/options.h index e107fb09..00d89c34 100644 --- a/src/options.h +++ b/src/options.h @@ -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; -- 2.39.2