Browse Source

[core] try AF_INET after AF_INET6 if use-ipv6

try AF_INET after AF_INET6 if server.use-ipv6 = "enable" and
getaddrinfo() fails EAI_ADDRFAMILY when hints.ai_family is AF_INET6.
(Prefer IPv6 instead of setting hinst.ai_family to AF_UNSPEC since
lighttpd only uses the first address returned)
personal/stbuehler/mod-csrf-old
Glenn Strauss 5 years ago
parent
commit
a69a803e35
  1. 10
      src/network.c

10
src/network.c

@ -281,6 +281,16 @@ static int network_server_init(server *srv, buffer *host_token, specific_config
hints.ai_protocol = IPPROTO_TCP;
if (0 != (r = getaddrinfo(host, NULL, &hints, &res))) {
hints.ai_family = AF_INET;
if (EAI_ADDRFAMILY == r && 0 == getaddrinfo(host, NULL, &hints, &res)) {
srv_socket->addr.ipv4.sin_family = AF_INET;
srv_socket->addr.ipv4.sin_port = htons(port);
memcpy(&(srv_socket->addr.ipv4.sin_addr.s_addr), res->ai_addr, res->ai_addrlen);
addr_len = sizeof(struct sockaddr_in);
freeaddrinfo(res);
break;
}
log_error_write(srv, __FILE__, __LINE__,
"sssss", "getaddrinfo failed: ",
gai_strerror(r), "'", host, "'");

Loading…
Cancel
Save