aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/libevent/patches/2291017-addrconfig.patch
blob: 6350201b91f49db097cd95c1585340869bd4cde0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
commit a46378f35d88b65b816774a43196ac9862692071
author: dldmitry
date: 2016-04-27T13:25:03+03:00
revision: 2291017

    libevent: don't use ADDRCONFIG
    __BYPASS_CHECKS__

--- libevent/http.c	(index)
+++ libevent/http.c	(working tree)
@@ -4424,12 +4424,33 @@ make_addrinfo(const char *address, ev_uint16_t port)
 	char strport[NI_MAXSERV];
 	int ai_result;

+	static const char* names[] = {
+		"127.0.0.1",
+		"::1",
+		"localhost",
+		"localhost.localdomain",
+		"localhost6",
+		"localhost6.localdomain6",
+		NULL
+	};
+	const char **name_ptr = names;
+	int name_exists = 0;
+
 	memset(&hints, 0, sizeof(hints));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
 	/* turn NULL hostname into INADDR_ANY, and skip looking up any address
 	 * types we don't have an interface to connect to. */
-	hints.ai_flags = EVUTIL_AI_PASSIVE|EVUTIL_AI_ADDRCONFIG;
+	hints.ai_flags = EVUTIL_AI_PASSIVE;
+	while (*name_ptr) {
+	    const char* tmp = *name_ptr++;
+	    if (evutil_ascii_strcasecmp(tmp, address) == 0) {
+	        name_exists = 1;
+	        break;
+	    }
+	}
+	if (!name_exists)
+	    hints.ai_flags |= EVUTIL_AI_ADDRCONFIG;
 	evutil_snprintf(strport, sizeof(strport), "%d", port);
 	if ((ai_result = evutil_getaddrinfo(address, strport, &hints, &ai))
 	    != 0) {