aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/gnunet-gns-proxy.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 7e25e367b..882303086 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -522,6 +522,11 @@ struct Socks5Request
522 * HTTP request headers for the curl request. 522 * HTTP request headers for the curl request.
523 */ 523 */
524 struct curl_slist *headers; 524 struct curl_slist *headers;
525
526 /**
527 * DNS->IP mappings resolved through GNS
528 */
529 struct curl_slist *hosts;
525 530
526 /** 531 /**
527 * HTTP response code to give to MHD for the response. 532 * HTTP response code to give to MHD for the response.
@@ -713,6 +718,10 @@ cleanup_s5r (struct Socks5Request *s5r)
713 s5r->curl = NULL; 718 s5r->curl = NULL;
714 } 719 }
715 curl_slist_free_all (s5r->headers); 720 curl_slist_free_all (s5r->headers);
721 if (NULL != s5r->hosts)
722 {
723 curl_slist_free_all (s5r->hosts);
724 }
716 if ( (NULL != s5r->response) && 725 if ( (NULL != s5r->response) &&
717 (curl_failure_response != s5r->response) ) 726 (curl_failure_response != s5r->response) )
718 MHD_destroy_response (s5r->response); 727 MHD_destroy_response (s5r->response);
@@ -1481,6 +1490,7 @@ create_response (void *cls,
1481{ 1490{
1482 struct Socks5Request *s5r = *con_cls; 1491 struct Socks5Request *s5r = *con_cls;
1483 char *curlurl; 1492 char *curlurl;
1493 char *curl_hosts;
1484 char ipstring[INET6_ADDRSTRLEN]; 1494 char ipstring[INET6_ADDRSTRLEN];
1485 char ipaddr[INET6_ADDRSTRLEN + 2]; 1495 char ipaddr[INET6_ADDRSTRLEN + 2];
1486 const struct sockaddr *sa; 1496 const struct sockaddr *sa;
@@ -1554,11 +1564,29 @@ create_response (void *cls,
1554 curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L); 1564 curl_easy_setopt (s5r->curl, CURLOPT_NOSIGNAL, 1L);
1555 curl_easy_setopt (s5r->curl, CURLOPT_PRIVATE, s5r); 1565 curl_easy_setopt (s5r->curl, CURLOPT_PRIVATE, s5r);
1556 curl_easy_setopt (s5r->curl, CURLOPT_VERBOSE, 0); 1566 curl_easy_setopt (s5r->curl, CURLOPT_VERBOSE, 0);
1567 /**
1568 * Pre-populate cache to resolve Hostname.
1569 * This is necessary as the DNS name in the CURLOPT_URL is used
1570 * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication
1571 */
1572 if (NULL != s5r->leho)
1573 {
1574 GNUNET_asprintf (&curl_hosts,
1575 "%s:%d:%s",
1576 s5r->leho,
1577 port,
1578 ipaddr);
1579 s5r->hosts = curl_slist_append(NULL, curl_hosts);
1580 curl_easy_setopt(s5r->curl, CURLOPT_RESOLVE, s5r->hosts);
1581 GNUNET_free (curl_hosts);
1582 }
1557 GNUNET_asprintf (&curlurl, 1583 GNUNET_asprintf (&curlurl,
1558 (HTTPS_PORT != s5r->port) 1584 (HTTPS_PORT != s5r->port)
1559 ? "http://%s:%d%s" 1585 ? "http://%s:%d%s"
1560 : "https://%s:%d%s", 1586 : "https://%s:%d%s",
1561 ipaddr, 1587 (NULL != s5r->leho)
1588 ? s5r->leho
1589 : ipaddr,
1562 port, 1590 port,
1563 s5r->url); 1591 s5r->url);
1564 curl_easy_setopt (s5r->curl, 1592 curl_easy_setopt (s5r->curl,