aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/Makefile.am3
-rw-r--r--src/gns/gnunet-bcd.c22
-rw-r--r--src/gns/gnunet-dns2gns.c8
-rw-r--r--src/gns/gnunet-gns-proxy.c23
-rw-r--r--src/gns/gnunet-service-gns_interceptor.c1
-rw-r--r--src/gns/gnunet-service-gns_resolver.c27
-rw-r--r--src/gns/plugin_rest_gns.c4
7 files changed, 55 insertions, 33 deletions
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 9f03311e1..3aaa734f2 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -80,9 +80,7 @@ bin_PROGRAMS = \
80noinst_PROGRAMS = \ 80noinst_PROGRAMS = \
81 gnunet-gns-benchmark 81 gnunet-gns-benchmark
82 82
83if LINUX
84bin_PROGRAMS += gnunet-bcd 83bin_PROGRAMS += gnunet-bcd
85endif
86 84
87REST_PLUGIN = libgnunet_plugin_rest_gns.la 85REST_PLUGIN = libgnunet_plugin_rest_gns.la
88 86
@@ -156,6 +154,7 @@ gnunet_bcd_SOURCES = \
156 gnunet-bcd.c 154 gnunet-bcd.c
157gnunet_bcd_LDADD = \ 155gnunet_bcd_LDADD = \
158 $(top_builddir)/src/util/libgnunetutil.la \ 156 $(top_builddir)/src/util/libgnunetutil.la \
157 $(top_builddir)/src/identity/libgnunetidentity.la \
159 $(GN_LIBINTL) $(MHD_LIBS) 158 $(GN_LIBINTL) $(MHD_LIBS)
160gnunet_bcd_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS) 159gnunet_bcd_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
161 160
diff --git a/src/gns/gnunet-bcd.c b/src/gns/gnunet-bcd.c
index f71f477ef..a2e94089c 100644
--- a/src/gns/gnunet-bcd.c
+++ b/src/gns/gnunet-bcd.c
@@ -27,6 +27,7 @@
27#include "platform.h" 27#include "platform.h"
28#include <microhttpd.h> 28#include <microhttpd.h>
29#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
30#include "gnunet_identity_service.h"
30#include "gnunet_mhd_compat.h" 31#include "gnunet_mhd_compat.h"
31 32
32/** 33/**
@@ -148,7 +149,7 @@ access_handler_callback (void *cls,
148 char *p; 149 char *p;
149 char *tmp; 150 char *tmp;
150 char *deffile; 151 char *deffile;
151 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 152 struct GNUNET_IDENTITY_PublicKey pub;
152 size_t slen; 153 size_t slen;
153 FILE *f; 154 FILE *f;
154 struct stat st; 155 struct stat st;
@@ -166,9 +167,8 @@ access_handler_callback (void *cls,
166 MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "gnskey"); 167 MHD_lookup_connection_value (connection, MHD_GET_ARGUMENT_KIND, "gnskey");
167 if ((NULL == gnskey) || 168 if ((NULL == gnskey) ||
168 (GNUNET_OK != 169 (GNUNET_OK !=
169 GNUNET_CRYPTO_ecdsa_public_key_from_string (gnskey, 170 GNUNET_IDENTITY_public_key_from_string (gnskey,
170 strlen (gnskey), 171 &pub)))
171 &pub)))
172 { 172 {
173 return MHD_queue_response (connection, 173 return MHD_queue_response (connection,
174 MHD_HTTP_OK, 174 MHD_HTTP_OK,
@@ -218,10 +218,10 @@ access_handler_callback (void *cls,
218 (NULL == gns_nick) ? "" : gns_nick); 218 (NULL == gns_nick) ? "" : gns_nick);
219 fclose (f); 219 fclose (f);
220 GNUNET_asprintf ( 220 GNUNET_asprintf (
221 &p, 221 &p,
222 "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null", 222 "cd %s; cp %s gns-bcd.tex | pdflatex --enable-write18 gns-bcd.tex > /dev/null 2> /dev/null",
223 tmp, 223 tmp,
224 resfile); 224 resfile);
225 GNUNET_free (deffile); 225 GNUNET_free (deffile);
226 ret = system (p); 226 ret = system (p);
227 if (WIFSIGNALED (ret) || (0 != WEXITSTATUS (ret))) 227 if (WIFSIGNALED (ret) || (0 != WEXITSTATUS (ret)))
@@ -506,7 +506,7 @@ main (int argc, char *const *argv)
506 "port", 506 "port",
507 "PORT", 507 "PORT",
508 gettext_noop ( 508 gettext_noop (
509 "Run HTTP serve on port PORT (default is 8888)"), 509 "Run HTTP serve on port PORT (default is 8888)"),
510 &port), 510 &port),
511 GNUNET_GETOPT_OPTION_END 511 GNUNET_GETOPT_OPTION_END
512 }; 512 };
@@ -523,8 +523,8 @@ main (int argc, char *const *argv)
523 options, 523 options,
524 &run, 524 &run,
525 NULL)) 525 NULL))
526 ? 0 526 ? 0
527 : 1; 527 : 1;
528 GNUNET_free_nz ((void *) argv); 528 GNUNET_free_nz ((void *) argv);
529 return ret; 529 return ret;
530} 530}
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 0a9b7c861..06f4c9841 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -309,6 +309,14 @@ dns_result_processor (void *cls,
309 } 309 }
310 request->packet = GNUNET_DNSPARSER_parse ((char *) dns, 310 request->packet = GNUNET_DNSPARSER_parse ((char *) dns,
311 r); 311 r);
312 if (NULL == request->packet)
313 {
314 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
315 _ ("Failed to parse DNS response!\n"));
316 GNUNET_SCHEDULER_cancel (request->timeout_task);
317 do_timeout (request);
318 return;
319 }
312 GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup); 320 GNUNET_DNSSTUB_resolve_cancel (request->dns_lookup);
313 send_response (request); 321 send_response (request);
314} 322}
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 833a8da01..d02f0f576 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -1841,6 +1841,7 @@ create_response (void *cls,
1841 char *curlurl; 1841 char *curlurl;
1842 char ipstring[INET6_ADDRSTRLEN]; 1842 char ipstring[INET6_ADDRSTRLEN];
1843 char ipaddr[INET6_ADDRSTRLEN + 2]; 1843 char ipaddr[INET6_ADDRSTRLEN + 2];
1844 char *curl_hosts;
1844 const struct sockaddr *sa; 1845 const struct sockaddr *sa;
1845 const struct sockaddr_in *s4; 1846 const struct sockaddr_in *s4;
1846 const struct sockaddr_in6 *s6; 1847 const struct sockaddr_in6 *s6;
@@ -1900,6 +1901,14 @@ create_response (void *cls,
1900 GNUNET_break (0); 1901 GNUNET_break (0);
1901 return MHD_NO; 1902 return MHD_NO;
1902 } 1903 }
1904 GNUNET_asprintf (&curl_hosts,
1905 "%s:%d:%s",
1906 s5r->leho,
1907 port,
1908 ipaddr);
1909 s5r->hosts = curl_slist_append (NULL,
1910 curl_hosts);
1911 GNUNET_free (curl_hosts);
1903 } 1912 }
1904 else 1913 else
1905 { 1914 {
@@ -1949,21 +1958,13 @@ create_response (void *cls,
1949 * Pre-populate cache to resolve Hostname. 1958 * Pre-populate cache to resolve Hostname.
1950 * This is necessary as the DNS name in the CURLOPT_URL is used 1959 * This is necessary as the DNS name in the CURLOPT_URL is used
1951 * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication 1960 * for SNI http://de.wikipedia.org/wiki/Server_Name_Indication
1952 */if (NULL != s5r->leho) 1961 */
1962 if ((NULL != s5r->leho) &&
1963 (NULL != s5r->hosts))
1953 { 1964 {
1954 char *curl_hosts;
1955
1956 GNUNET_asprintf (&curl_hosts,
1957 "%s:%d:%s",
1958 s5r->leho,
1959 port,
1960 ipaddr);
1961 s5r->hosts = curl_slist_append (NULL,
1962 curl_hosts);
1963 curl_easy_setopt (s5r->curl, 1965 curl_easy_setopt (s5r->curl,
1964 CURLOPT_RESOLVE, 1966 CURLOPT_RESOLVE,
1965 s5r->hosts); 1967 s5r->hosts);
1966 GNUNET_free (curl_hosts);
1967 } 1968 }
1968 if (s5r->is_gns) 1969 if (s5r->is_gns)
1969 { 1970 {
diff --git a/src/gns/gnunet-service-gns_interceptor.c b/src/gns/gnunet-service-gns_interceptor.c
index b53f4af6b..255f85598 100644
--- a/src/gns/gnunet-service-gns_interceptor.c
+++ b/src/gns/gnunet-service-gns_interceptor.c
@@ -323,7 +323,6 @@ handle_dns_request (void *cls,
323 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 323 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
324 "Received malformed DNS packet, leaving it untouched.\n"); 324 "Received malformed DNS packet, leaving it untouched.\n");
325 GNUNET_DNS_request_forward (rh); 325 GNUNET_DNS_request_forward (rh);
326 GNUNET_DNSPARSER_free_packet (p);
327 return; 326 return;
328 } 327 }
329 328
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 49c1b340a..2f8a55804 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -764,6 +764,7 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh)
764 rd[i].data = pos->data; 764 rd[i].data = pos->data;
765 rd[i].data_size = pos->data_size; 765 rd[i].data_size = pos->data_size;
766 rd[i].record_type = pos->record_type; 766 rd[i].record_type = pos->record_type;
767 rd[i].flags = GNUNET_GNSRECORD_RF_NONE;
767 /** 768 /**
768 * If this is a LEHO, we added this before. It must be a supplemental 769 * If this is a LEHO, we added this before. It must be a supplemental
769 * record #LSD0001 770 * record #LSD0001
@@ -772,12 +773,11 @@ transmit_lookup_dns_result (struct GNS_ResolverHandle *rh)
772 rd[i].flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL; 773 rd[i].flags |= GNUNET_GNSRECORD_RF_SUPPLEMENTAL;
773 if (0 == pos->expiration_time) 774 if (0 == pos->expiration_time)
774 { 775 {
775 rd[i].flags = GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION; 776 rd[i].flags |= GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
776 rd[i].expiration_time = 0; 777 rd[i].expiration_time = 0;
777 } 778 }
778 else 779 else
779 { 780 {
780 rd[i].flags = GNUNET_GNSRECORD_RF_NONE;
781 rd[i].expiration_time = pos->expiration_time; 781 rd[i].expiration_time = pos->expiration_time;
782 } 782 }
783 i++; 783 i++;
@@ -1764,6 +1764,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1764 /** 1764 /**
1765 * Records other than GNS2DNS not allowed 1765 * Records other than GNS2DNS not allowed
1766 */ 1766 */
1767 if (NULL != ns)
1768 GNUNET_free (ns);
1767 return GNUNET_SYSERR; 1769 return GNUNET_SYSERR;
1768 } 1770 }
1769 off = 0; 1771 off = 0;
@@ -1771,15 +1773,22 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1771 rd[i].data_size, 1773 rd[i].data_size,
1772 &off); 1774 &off);
1773 ip = GNUNET_strdup (&((const char *) rd[i].data)[off]); 1775 ip = GNUNET_strdup (&((const char *) rd[i].data)[off]);
1776 if ((NULL == n) ||
1777 (NULL == ip))
1778 {
1779 GNUNET_break_op (0);
1780 if (NULL != n)
1781 GNUNET_free (n);
1782 if (NULL != ip)
1783 GNUNET_free (ip);
1784 continue;
1785 }
1786
1774 off += strlen (ip) + 1; 1787 off += strlen (ip) + 1;
1775 1788
1776 if ((NULL == n) || 1789 if (off != rd[i].data_size)
1777 (NULL == ip) ||
1778 (off != rd[i].data_size))
1779 { 1790 {
1780 GNUNET_break_op (0); 1791 GNUNET_break_op (0);
1781 GNUNET_free (n);
1782 GNUNET_free (ip);
1783 continue; 1792 continue;
1784 } 1793 }
1785 /* resolve 'ip' to determine the IP(s) of the DNS 1794 /* resolve 'ip' to determine the IP(s) of the DNS
@@ -1909,6 +1918,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1909 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1918 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1910 _ ("Name `%s' cannot be converted to IDNA."), 1919 _ ("Name `%s' cannot be converted to IDNA."),
1911 tmp); 1920 tmp);
1921 GNUNET_free (tmp);
1922 GNUNET_free (ac);
1912 return GNUNET_SYSERR; 1923 return GNUNET_SYSERR;
1913 } 1924 }
1914 GNUNET_free (tmp); 1925 GNUNET_free (tmp);
@@ -1922,6 +1933,8 @@ recursive_gns2dns_resolution (struct GNS_ResolverHandle *rh,
1922 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1933 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1923 _ ("GNS lookup resulted in DNS name that is too long (`%s')\n"), 1934 _ ("GNS lookup resulted in DNS name that is too long (`%s')\n"),
1924 ac->label); 1935 ac->label);
1936 GNUNET_free (ac->label);
1937 GNUNET_free (ac);
1925 return GNUNET_SYSERR; 1938 return GNUNET_SYSERR;
1926 } 1939 }
1927 continue_with_gns2dns (ac); 1940 continue_with_gns2dns (ac);
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index 2ccb5be2b..3a35c9999 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -270,7 +270,9 @@ handle_gns_response (void *cls,
270 result = json_dumps (result_obj, 0); 270 result = json_dumps (result_obj, 0);
271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); 271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
272 resp = GNUNET_REST_create_response (result); 272 resp = GNUNET_REST_create_response (result);
273 MHD_add_response_header (resp, "Content-Type", "application/json"); 273 GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
274 "Content-Type",
275 "application/json"));
274 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 276 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
275 GNUNET_free (result); 277 GNUNET_free (result);
276 json_decref (result_obj); 278 json_decref (result_obj);