diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-03-09 16:10:53 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-03-09 16:10:53 +0100 |
commit | f275f660e1d44af17cca122b9cba2845c5e37f2a (patch) | |
tree | 6eb34a8aef675aa71a1eaec9af9886d6e92fb38a /src/gns/gnunet-gns-proxy.c | |
parent | 0abf3edaea47f19aa5ee32c98cc6c299c3b4fddd (diff) | |
download | gnunet-f275f660e1d44af17cca122b9cba2845c5e37f2a.tar.gz gnunet-f275f660e1d44af17cca122b9cba2845c5e37f2a.zip |
bind to config option (default localhost) for GNS
Diffstat (limited to 'src/gns/gnunet-gns-proxy.c')
-rw-r--r-- | src/gns/gnunet-gns-proxy.c | 57 |
1 files changed, 57 insertions, 0 deletions
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 | */ | ||
667 | static in_addr_t address; | ||
668 | |||
669 | /** | ||
670 | * The IPv6 address to bind to | ||
671 | */ | ||
672 | static 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, |