Core: only resolve address families configured on the local system.
This is done by passing AI_ADDRCONFIG to getaddrinfo(). On Linux, setting net.ipv6.conf.all.disable_ipv6 to 1 will now be respected. On FreeBSD, AI_ADDRCONFIG filtering is currently implemented by attempting to create a datagram socket for the corresponding family, which succeeds even if the system doesn't in fact have any addresses of that family configured. That is, if the system with IPv6 support in the kernel doesn't have IPv6 addresses configured, AI_ADDRCONFIG will filter out IPv6 only inside a jail without IPv6 addresses or with IPv6 disabled.
This commit is contained in:
parent
a15541168b
commit
4ea173e06e
2 changed files with 7 additions and 2 deletions
|
@ -788,7 +788,11 @@ ngx_feature_incs="#include <sys/types.h>
|
||||||
#include <netdb.h>"
|
#include <netdb.h>"
|
||||||
ngx_feature_path=
|
ngx_feature_path=
|
||||||
ngx_feature_libs=
|
ngx_feature_libs=
|
||||||
ngx_feature_test='struct addrinfo *res;
|
ngx_feature_test='struct addrinfo hints, *res;
|
||||||
if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_ADDRCONFIG;
|
||||||
|
if (getaddrinfo("localhost", NULL, &hints, &res) != 0)
|
||||||
|
return 1;
|
||||||
freeaddrinfo(res)'
|
freeaddrinfo(res)'
|
||||||
. auto/feature
|
. auto/feature
|
||||||
|
|
|
@ -963,6 +963,7 @@ ngx_inet_resolve_host(ngx_pool_t *pool, ngx_url_t *u)
|
||||||
ngx_memzero(&hints, sizeof(struct addrinfo));
|
ngx_memzero(&hints, sizeof(struct addrinfo));
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
|
hints.ai_flags = AI_ADDRCONFIG;
|
||||||
|
|
||||||
if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) {
|
if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) {
|
||||||
u->err = "host not found";
|
u->err = "host not found";
|
||||||
|
|
Loading…
Reference in a new issue