Skip to content
This repository
Browse code

Adds all the IPs that resolves a domain name to an access restriction…

… list.

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6877 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
commit 03257c4c22ee21837bcf6a239558dddb1ff8fc03 1 parent 2c8bc6f
Antonio Pérez authored October 01, 2011

Showing 1 changed file with 16 additions and 4 deletions. Show diff stats Hide diff stats

  1. 20  cherokee/access.c
20  cherokee/access.c
@@ -325,8 +325,9 @@ static ret_t
325 325
 cherokee_access_add_domain (cherokee_access_t *entry, char *domain)
326 326
 {
327 327
 	ret_t                    ret;
328  
-	const char              *ip;
  328
+	char                     ip[46]; // Max IPv6 length is 45
329 329
 	cherokee_resolv_cache_t *resolv;
  330
+	const struct addrinfo   *addr_info, *addr;
330 331
 	cherokee_buffer_t        domain_buf = CHEROKEE_BUF_INIT;
331 332
 
332 333
 	cherokee_buffer_fake (&domain_buf, domain, strlen(domain));
@@ -334,11 +335,22 @@ cherokee_access_add_domain (cherokee_access_t *entry, char *domain)
334 335
 	ret = cherokee_resolv_cache_get_default (&resolv);
335 336
 	if (unlikely(ret!=ret_ok)) return ret;
336 337
 
337  
-	ret = cherokee_resolv_cache_get_ipstr (resolv, &domain_buf, &ip);
  338
+	ret = cherokee_resolv_cache_get_addrinfo (resolv, &domain_buf, &addr_info);
338 339
 	if (unlikely(ret!=ret_ok)) return ret;
339 340
 
340  
-	TRACE (ENTRIES, "Access: domain '%s'\n", domain);
341  
-	return cherokee_access_add_ip (entry, (char *)ip);
  341
+	addr = addr_info;
  342
+	while (addr != NULL) {
  343
+		ret = cherokee_ntop (addr->ai_family, addr->ai_addr, ip, sizeof(ip));
  344
+		if (unlikely(ret!=ret_ok)) return ret;
  345
+	
  346
+		TRACE (ENTRIES, "Access: domain '%s' -> IP: %s\n", domain, ip);
  347
+		ret = cherokee_access_add_ip (entry, (char *)ip);
  348
+		if (unlikely(ret!=ret_ok)) return ret;
  349
+
  350
+		addr = addr->ai_next;
  351
+	}
  352
+
  353
+	return ret_ok;
342 354
 }
343 355
 
344 356
 

0 notes on commit 03257c4

Please sign in to comment.
Something went wrong with that request. Please try again.