comparison src/core/ngx_inet.c @ 5312:ec8594b9bf11

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.
author Ruslan Ermilov <ru@nginx.com>
date Mon, 05 Aug 2013 10:55:59 +0400
parents 05ba5bce31e0
children 1fe5f7fb6ced
comparison
equal deleted inserted replaced
5311:ae3fd1ca62e0 5312:ec8594b9bf11
961 (void) ngx_cpystrn(host, u->host.data, u->host.len + 1); 961 (void) ngx_cpystrn(host, u->host.data, u->host.len + 1);
962 962
963 ngx_memzero(&hints, sizeof(struct addrinfo)); 963 ngx_memzero(&hints, sizeof(struct addrinfo));
964 hints.ai_family = AF_UNSPEC; 964 hints.ai_family = AF_UNSPEC;
965 hints.ai_socktype = SOCK_STREAM; 965 hints.ai_socktype = SOCK_STREAM;
966 hints.ai_flags = AI_ADDRCONFIG;
966 967
967 if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) { 968 if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) {
968 u->err = "host not found"; 969 u->err = "host not found";
969 ngx_free(host); 970 ngx_free(host);
970 return NGX_ERROR; 971 return NGX_ERROR;