aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/gns/gns.conf.in4
-rw-r--r--src/gns/gnunet-dns2gns.c60
-rw-r--r--src/gns/gnunet-gns-proxy.c57
4 files changed, 122 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index f1c0bfa7e..c33c6071b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
1Sat Mar 9 15:58:45 2019 +0100 1Sat Mar 9 15:58:45 2019 +0100
2 REST: Config option for address bind. Defaults to localhost. 2 REST: Config option for address bind. Defaults to localhost.
3 GNS: dns2gns/gns-proxy config option for address bind. Defaults to localhost.
3 4
4Sat Mar 9 01:58:22 CET 2019 5Sat Mar 9 01:58:22 CET 2019
5 gnunet-publish now by default does not expose the creation time, 6 gnunet-publish now by default does not expose the creation time,
diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in
index 2e6a02b07..3252e4888 100644
--- a/src/gns/gns.conf.in
+++ b/src/gns/gns.conf.in
@@ -32,6 +32,8 @@ INTERCEPT_DNS = NO
32BINARY = gnunet-gns-proxy 32BINARY = gnunet-gns-proxy
33START_ON_DEMAND = NO 33START_ON_DEMAND = NO
34RUN_PER_USER = YES 34RUN_PER_USER = YES
35BIND_TO=127.0.0.1
36BIND_TO6=::1
35 37
36# Where is the certificate for the GNS proxy stored? 38# Where is the certificate for the GNS proxy stored?
37PROXY_CACERT = $GNUNET_DATA_HOME/gns/gns_ca_cert.pem 39PROXY_CACERT = $GNUNET_DATA_HOME/gns/gns_ca_cert.pem
@@ -42,6 +44,8 @@ PROXY_UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-gns-proxy.sock
42BINARY = gnunet-dns2gns 44BINARY = gnunet-dns2gns
43START_ON_DEMAND = NO 45START_ON_DEMAND = NO
44RUN_PER_USER = YES 46RUN_PER_USER = YES
47BIND_TO=127.0.0.1
48BIND_TO6=::1
45 49
46# -d: DNS resolver to use, -s: suffix to use, -f: fcfs suffix to use 50# -d: DNS resolver to use, -s: suffix to use, -f: fcfs suffix to use
47OPTIONS = -d 8.8.8.8 51OPTIONS = -d 8.8.8.8
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c
index 68d090579..a4d3ffedc 100644
--- a/src/gns/gnunet-dns2gns.c
+++ b/src/gns/gnunet-dns2gns.c
@@ -92,6 +92,17 @@ struct Request
92 uint16_t original_request_id; 92 uint16_t original_request_id;
93}; 93};
94 94
95/**
96 * The address to bind to
97 */
98static in_addr_t address;
99
100/**
101 * The IPv6 address to bind to
102 */
103static struct in6_addr address6;
104
105
95 106
96/** 107/**
97 * Handle to GNS resolver. 108 * Handle to GNS resolver.
@@ -578,6 +589,7 @@ run (void *cls,
578 const char *cfgfile, 589 const char *cfgfile,
579 const struct GNUNET_CONFIGURATION_Handle *c) 590 const struct GNUNET_CONFIGURATION_Handle *c)
580{ 591{
592 char *addr_str;
581 (void) cls; 593 (void) cls;
582 (void) args; 594 (void) args;
583 (void) cfgfile; 595 (void) cfgfile;
@@ -602,6 +614,52 @@ run (void *cls,
602 gns = NULL; 614 gns = NULL;
603 return; 615 return;
604 } 616 }
617
618 /* Get address to bind to */
619 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "dnns2gns",
620 "BIND_TO",
621 &addr_str))
622 {
623 //No address specified
624 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
625 "Don't know what to bind to...\n");
626 GNUNET_free (addr_str);
627 GNUNET_SCHEDULER_shutdown ();
628 return;
629 }
630 if (1 != inet_pton (AF_INET, addr_str, &address))
631 {
632 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
633 "Unable to parse address %s\n",
634 addr_str);
635 GNUNET_free (addr_str);
636 GNUNET_SCHEDULER_shutdown ();
637 return;
638 }
639 GNUNET_free (addr_str);
640 /* Get address to bind to */
641 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "dns2gns",
642 "BIND_TO6",
643 &addr_str))
644 {
645 //No address specified
646 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
647 "Don't know what to bind6 to...\n");
648 GNUNET_free (addr_str);
649 GNUNET_SCHEDULER_shutdown ();
650 return;
651 }
652 if (1 != inet_pton (AF_INET6, addr_str, &address6))
653 {
654 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
655 "Unable to parse IPv6 address %s\n",
656 addr_str);
657 GNUNET_free (addr_str);
658 GNUNET_SCHEDULER_shutdown ();
659 return;
660 }
661 GNUNET_free (addr_str);
662
605 listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET, 663 listen_socket4 = GNUNET_NETWORK_socket_create (PF_INET,
606 SOCK_DGRAM, 664 SOCK_DGRAM,
607 IPPROTO_UDP); 665 IPPROTO_UDP);
@@ -611,6 +669,7 @@ run (void *cls,
611 669
612 memset (&v4, 0, sizeof (v4)); 670 memset (&v4, 0, sizeof (v4));
613 v4.sin_family = AF_INET; 671 v4.sin_family = AF_INET;
672 v4.sin_addr.s_addr = address;
614#if HAVE_SOCKADDR_IN_SIN_LEN 673#if HAVE_SOCKADDR_IN_SIN_LEN
615 v4.sin_len = sizeof (v4); 674 v4.sin_len = sizeof (v4);
616#endif 675#endif
@@ -634,6 +693,7 @@ run (void *cls,
634 693
635 memset (&v6, 0, sizeof (v6)); 694 memset (&v6, 0, sizeof (v6));
636 v6.sin6_family = AF_INET6; 695 v6.sin6_family = AF_INET6;
696 v6.sin6_addr = address6;
637#if HAVE_SOCKADDR_IN_SIN_LEN 697#if HAVE_SOCKADDR_IN_SIN_LEN
638 v6.sin6_len = sizeof (v6); 698 v6.sin6_len = sizeof (v6);
639#endif 699#endif
diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c
index 65a7b6018..a6b053e56 100644
--- a/src/gns/gnunet-gns-proxy.c
+++ b/src/gns/gnunet-gns-proxy.c
@@ -661,6 +661,15 @@ struct Socks5Request
661 661
662/* *********************** Globals **************************** */ 662/* *********************** Globals **************************** */
663 663
664/**
665 * The address to bind to
666 */
667static in_addr_t address;
668
669/**
670 * The IPv6 address to bind to
671 */
672static struct in6_addr address6;
664 673
665/** 674/**
666 * The port the proxy is running on (default 7777) 675 * The port the proxy is running on (default 7777)
@@ -3516,6 +3525,7 @@ bind_v4 ()
3516 memset (&sa4, 0, sizeof (sa4)); 3525 memset (&sa4, 0, sizeof (sa4));
3517 sa4.sin_family = AF_INET; 3526 sa4.sin_family = AF_INET;
3518 sa4.sin_port = htons (port); 3527 sa4.sin_port = htons (port);
3528 sa4.sin_addr.s_addr = address;
3519#if HAVE_SOCKADDR_IN_SIN_LEN 3529#if HAVE_SOCKADDR_IN_SIN_LEN
3520 sa4.sin_len = sizeof (sa4); 3530 sa4.sin_len = sizeof (sa4);
3521#endif 3531#endif
@@ -3553,6 +3563,7 @@ bind_v6 ()
3553 memset (&sa6, 0, sizeof (sa6)); 3563 memset (&sa6, 0, sizeof (sa6));
3554 sa6.sin6_family = AF_INET6; 3564 sa6.sin6_family = AF_INET6;
3555 sa6.sin6_port = htons (port); 3565 sa6.sin6_port = htons (port);
3566 sa6.sin6_addr = address6;
3556#if HAVE_SOCKADDR_IN_SIN_LEN 3567#if HAVE_SOCKADDR_IN_SIN_LEN
3557 sa6.sin6_len = sizeof (sa6); 3568 sa6.sin6_len = sizeof (sa6);
3558#endif 3569#endif
@@ -3591,10 +3602,56 @@ run (void *cls,
3591{ 3602{
3592 char* cafile_cfg = NULL; 3603 char* cafile_cfg = NULL;
3593 char* cafile; 3604 char* cafile;
3605 char* addr_str;
3594 struct MhdHttpList *hd; 3606 struct MhdHttpList *hd;
3595 3607
3596 cfg = c; 3608 cfg = c;
3597 3609
3610 /* Get address to bind to */
3611 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "gns-proxy",
3612 "BIND_TO",
3613 &addr_str))
3614 {
3615 //No address specified
3616 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3617 "Don't know what to bind to...\n");
3618 GNUNET_free (addr_str);
3619 GNUNET_SCHEDULER_shutdown ();
3620 return;
3621 }
3622 if (1 != inet_pton (AF_INET, addr_str, &address))
3623 {
3624 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3625 "Unable to parse address %s\n",
3626 addr_str);
3627 GNUNET_free (addr_str);
3628 GNUNET_SCHEDULER_shutdown ();
3629 return;
3630 }
3631 GNUNET_free (addr_str);
3632 /* Get address to bind to */
3633 if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "gns-proxy",
3634 "BIND_TO6",
3635 &addr_str))
3636 {
3637 //No address specified
3638 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3639 "Don't know what to bind6 to...\n");
3640 GNUNET_free (addr_str);
3641 GNUNET_SCHEDULER_shutdown ();
3642 return;
3643 }
3644 if (1 != inet_pton (AF_INET6, addr_str, &address6))
3645 {
3646 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3647 "Unable to parse IPv6 address %s\n",
3648 addr_str);
3649 GNUNET_free (addr_str);
3650 GNUNET_SCHEDULER_shutdown ();
3651 return;
3652 }
3653 GNUNET_free (addr_str);
3654
3598 if (NULL == (curl_multi = curl_multi_init ())) 3655 if (NULL == (curl_multi = curl_multi_init ()))
3599 { 3656 {
3600 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 3657 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,