mirror of
https://github.com/mirror/wget.git
synced 2025-01-10 12:20:47 +08:00
[svn] Don't auto-set opt.ipv4_only on systems without IPv6 sockets.
This commit is contained in:
parent
a9d4f29c9e
commit
133d69ff24
@ -1,3 +1,11 @@
|
|||||||
|
2003-11-17 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
|
* host.c (lookup_host): Check for the ability to create IPv6
|
||||||
|
sockets here.
|
||||||
|
|
||||||
|
* init.c (defaults): Don't auto-set --inet4-only on IPv6-less
|
||||||
|
systems.
|
||||||
|
|
||||||
2003-11-16 Hrvoje Niksic <hniksic@xemacs.org>
|
2003-11-16 Hrvoje Niksic <hniksic@xemacs.org>
|
||||||
|
|
||||||
* main.c (print_help): Fix typo in `-O' help message. Fix docs of
|
* main.c (print_help): Fix typo in `-O' help message. Fix docs of
|
||||||
|
@ -614,6 +614,24 @@ retryable_socket_connect_error (int err)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
socket_has_inet6 (void)
|
||||||
|
{
|
||||||
|
static int supported = -1;
|
||||||
|
if (supported == -1)
|
||||||
|
{
|
||||||
|
int sock = socket (AF_INET6, SOCK_STREAM, 0);
|
||||||
|
if (sock < 0)
|
||||||
|
supported = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
xclose (sock);
|
||||||
|
supported = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return supported;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SELECT
|
#ifdef HAVE_SELECT
|
||||||
|
|
||||||
/* Wait for file descriptor FD to be readable or writable or both,
|
/* Wait for file descriptor FD to be readable or writable or both,
|
||||||
|
@ -65,6 +65,7 @@ enum {
|
|||||||
};
|
};
|
||||||
int select_fd PARAMS ((int, double, int));
|
int select_fd PARAMS ((int, double, int));
|
||||||
int test_socket_open PARAMS ((int));
|
int test_socket_open PARAMS ((int));
|
||||||
|
int socket_has_inet6 PARAMS ((void));
|
||||||
|
|
||||||
typedef int (*xreader_t) PARAMS ((int, char *, int, void *));
|
typedef int (*xreader_t) PARAMS ((int, char *, int, void *));
|
||||||
typedef int (*xwriter_t) PARAMS ((int, char *, int, void *));
|
typedef int (*xwriter_t) PARAMS ((int, char *, int, void *));
|
||||||
|
12
src/host.c
12
src/host.c
@ -67,6 +67,7 @@ so, delete this exception statement from your version. */
|
|||||||
#include "host.h"
|
#include "host.h"
|
||||||
#include "url.h"
|
#include "url.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
#include "connect.h" /* for socket_has_inet6 */
|
||||||
|
|
||||||
#ifndef errno
|
#ifndef errno
|
||||||
extern int errno;
|
extern int errno;
|
||||||
@ -575,17 +576,20 @@ lookup_host (const char *host, int flags)
|
|||||||
|
|
||||||
xzero (hints);
|
xzero (hints);
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
if (opt.ipv4_only && !opt.ipv6_only)
|
if (opt.ipv4_only)
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
else if (opt.ipv6_only && !opt.ipv4_only)
|
else if (opt.ipv6_only)
|
||||||
hints.ai_family = AF_INET6;
|
hints.ai_family = AF_INET6;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
#ifdef HAVE_GETADDRINFO_AI_ADDRCONFIG
|
#ifdef HAVE_GETADDRINFO_AI_ADDRCONFIG
|
||||||
/* Use AI_ADDRCONFIG if available and if specific family isn't
|
|
||||||
explicitly requested. See init.c:defaults(). */
|
|
||||||
hints.ai_flags |= AI_ADDRCONFIG;
|
hints.ai_flags |= AI_ADDRCONFIG;
|
||||||
|
#else
|
||||||
|
/* On systems without AI_ADDRCONFIG, emulate it by manually
|
||||||
|
checking whether the system supports IPv6 sockets and. */
|
||||||
|
if (!socket_has_inet6 ())
|
||||||
|
hints.ai_family = AF_INET;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (flags & LH_BIND)
|
if (flags & LH_BIND)
|
||||||
|
24
src/init.c
24
src/init.c
@ -304,30 +304,6 @@ defaults (void)
|
|||||||
opt.restrict_files_os = restrict_windows;
|
opt.restrict_files_os = restrict_windows;
|
||||||
#endif
|
#endif
|
||||||
opt.restrict_files_ctrl = 1;
|
opt.restrict_files_ctrl = 1;
|
||||||
|
|
||||||
#ifdef ENABLE_IPV6
|
|
||||||
# ifndef HAVE_GETADDRINFO_AI_ADDRCONFIG
|
|
||||||
/* If IPv6 is enabled, but AI_ADDRCONFIG is missing, check whether
|
|
||||||
we can create AF_INET6 sockets. If we can't, turn on the
|
|
||||||
--inet4-only setting. This is necessary because on some systems
|
|
||||||
(e.g. RHL 9) getaddrinfo resolves AAAA records, but socket()
|
|
||||||
can't even create an AF_INET6 socket, let alone connect to IPv6
|
|
||||||
hosts. To avoid "address family not supported" error messages,
|
|
||||||
we set ipv4_only.
|
|
||||||
|
|
||||||
We do it as early as here, so that the user can revert the
|
|
||||||
settingn using --no-inet4-only, in case he wants to see the error
|
|
||||||
messages, for whatever reason. */
|
|
||||||
{
|
|
||||||
int sock = socket (AF_INET6, SOCK_STREAM, 0);
|
|
||||||
if (sock < 0)
|
|
||||||
opt.ipv4_only = -1; /* special value -1 because the option
|
|
||||||
was not specified by the user. */
|
|
||||||
else
|
|
||||||
close (sock);
|
|
||||||
}
|
|
||||||
# endif /* not HAVE_GETADDRINFO_AI_ADDRCONFIG */
|
|
||||||
#endif /* ENABLE_IPV6 */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the user's home directory (strdup-ed), or NULL if none is
|
/* Return the user's home directory (strdup-ed), or NULL if none is
|
||||||
|
@ -547,7 +547,7 @@ HTTPS (SSL) options:\n"),
|
|||||||
N_("\
|
N_("\
|
||||||
FTP options:\n"),
|
FTP options:\n"),
|
||||||
N_("\
|
N_("\
|
||||||
-nr, --no-remove-listing don't remove `.listing' files.\n"),
|
--no-remove-listing don't remove `.listing' files.\n"),
|
||||||
N_("\
|
N_("\
|
||||||
--no-glob turn off FTP file name globbing.\n"),
|
--no-glob turn off FTP file name globbing.\n"),
|
||||||
N_("\
|
N_("\
|
||||||
@ -809,11 +809,6 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
|||||||
}
|
}
|
||||||
if (opt.ipv4_only && opt.ipv6_only)
|
if (opt.ipv4_only && opt.ipv6_only)
|
||||||
{
|
{
|
||||||
if (opt.ipv4_only == -1)
|
|
||||||
/* ipv4_only was set automatically because the system doesn't
|
|
||||||
support IPv6. */
|
|
||||||
printf (_("Cannot use --inet6-only on a system without IPv6 support.\n"));
|
|
||||||
else
|
|
||||||
printf (_("Cannot specify both --inet4-only and --inet6-only.\n"));
|
printf (_("Cannot specify both --inet4-only and --inet6-only.\n"));
|
||||||
print_usage ();
|
print_usage ();
|
||||||
exit (1);
|
exit (1);
|
||||||
|
Loading…
Reference in New Issue
Block a user