diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-03-11 22:51:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-03-11 22:51:28 +0000 |
commit | 0d7234799b96e9822330d70d3dd8ffea89eb0a75 (patch) | |
tree | 8bc6d77541f1b60ae67f9de6767b4a9a4c255a0d /src | |
parent | ad67fbaa9f73e51a687ce276afa17317e464d969 (diff) | |
download | gnunet-0d7234799b96e9822330d70d3dd8ffea89eb0a75.tar.gz gnunet-0d7234799b96e9822330d70d3dd8ffea89eb0a75.zip |
vminko: implementing BINDTO option for hostlist service (#2140)
Diffstat (limited to 'src')
-rw-r--r-- | src/hostlist/hostlist-server.c | 60 | ||||
-rw-r--r-- | src/hostlist/hostlist.conf | 3 |
2 files changed, 60 insertions, 3 deletions
diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index a5cc4785a..e7bddbbf3 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c | |||
@@ -537,7 +537,13 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
537 | { | 537 | { |
538 | unsigned long long port; | 538 | unsigned long long port; |
539 | char *hostname; | 539 | char *hostname; |
540 | char *ip; | ||
540 | size_t size; | 541 | size_t size; |
542 | struct in_addr i4; | ||
543 | struct in6_addr i6; | ||
544 | struct sockaddr_in v4; | ||
545 | struct sockaddr_in6 v6; | ||
546 | const struct sockaddr *sa; | ||
541 | 547 | ||
542 | advertising = advertise; | 548 | advertising = advertise; |
543 | if (!advertising) | 549 | if (!advertising) |
@@ -589,6 +595,50 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
589 | } | 595 | } |
590 | GNUNET_free (hostname); | 596 | GNUNET_free (hostname); |
591 | } | 597 | } |
598 | |||
599 | if (GNUNET_CONFIGURATION_have_value (cfg, "HOSTLIST", "BINDTOIP")) | ||
600 | { | ||
601 | GNUNET_break (GNUNET_OK == | ||
602 | GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", | ||
603 | "BINDTOIP", &ip)); | ||
604 | } | ||
605 | else | ||
606 | ip = NULL; | ||
607 | if (ip != NULL) | ||
608 | { | ||
609 | if (1 == inet_pton (AF_INET, ip, &i4)) | ||
610 | { | ||
611 | memset (&v4, 0, sizeof (v4)); | ||
612 | v4.sin_family = AF_INET; | ||
613 | v4.sin_addr = i4; | ||
614 | v4.sin_port = htons (port); | ||
615 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
616 | v4.sin_len = sizeof (v4); | ||
617 | #endif | ||
618 | sa = (const struct sockaddr *) &v4; | ||
619 | } | ||
620 | else if (1 == inet_pton (AF_INET6, ip, &i6)) | ||
621 | { | ||
622 | memset (&v6, 0, sizeof (v6)); | ||
623 | v6.sin6_family = AF_INET6; | ||
624 | v6.sin6_addr = i6; | ||
625 | v6.sin6_port = htons (port); | ||
626 | #if HAVE_SOCKADDR_IN_SIN_LEN | ||
627 | v6.sin6_len = sizeof (v6); | ||
628 | #endif | ||
629 | sa = (const struct sockaddr *) &v6; | ||
630 | } | ||
631 | else | ||
632 | { | ||
633 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
634 | _("`%s' is not a valid IP address! Ignoring BINDTOIP.\n"), | ||
635 | ip); | ||
636 | sa = NULL; | ||
637 | } | ||
638 | } | ||
639 | else | ||
640 | sa = NULL; | ||
641 | |||
592 | daemon_handle_v6 = MHD_start_daemon (MHD_USE_IPv6 | 642 | daemon_handle_v6 = MHD_start_daemon (MHD_USE_IPv6 |
593 | #if DEBUG_HOSTLIST_SERVER | 643 | #if DEBUG_HOSTLIST_SERVER |
594 | | MHD_USE_DEBUG | 644 | | MHD_USE_DEBUG |
@@ -603,7 +653,10 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
603 | MHD_OPTION_CONNECTION_TIMEOUT, | 653 | MHD_OPTION_CONNECTION_TIMEOUT, |
604 | (unsigned int) 16, | 654 | (unsigned int) 16, |
605 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 655 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
606 | (size_t) (16 * 1024), MHD_OPTION_END); | 656 | (size_t) (16 * 1024), |
657 | MHD_OPTION_SOCK_ADDR, | ||
658 | sa, | ||
659 | MHD_OPTION_END); | ||
607 | daemon_handle_v4 = MHD_start_daemon (MHD_NO_FLAG | 660 | daemon_handle_v4 = MHD_start_daemon (MHD_NO_FLAG |
608 | #if DEBUG_HOSTLIST_SERVER | 661 | #if DEBUG_HOSTLIST_SERVER |
609 | | MHD_USE_DEBUG | 662 | | MHD_USE_DEBUG |
@@ -618,7 +671,10 @@ GNUNET_HOSTLIST_server_start (const struct GNUNET_CONFIGURATION_Handle *c, | |||
618 | MHD_OPTION_CONNECTION_TIMEOUT, | 671 | MHD_OPTION_CONNECTION_TIMEOUT, |
619 | (unsigned int) 16, | 672 | (unsigned int) 16, |
620 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, | 673 | MHD_OPTION_CONNECTION_MEMORY_LIMIT, |
621 | (size_t) (16 * 1024), MHD_OPTION_END); | 674 | (size_t) (16 * 1024), |
675 | MHD_OPTION_SOCK_ADDR, | ||
676 | sa, | ||
677 | MHD_OPTION_END); | ||
622 | 678 | ||
623 | if ((daemon_handle_v6 == NULL) && (daemon_handle_v4 == NULL)) | 679 | if ((daemon_handle_v6 == NULL) && (daemon_handle_v4 == NULL)) |
624 | { | 680 | { |
diff --git a/src/hostlist/hostlist.conf b/src/hostlist/hostlist.conf index b13e1e59e..2e0c85484 100644 --- a/src/hostlist/hostlist.conf +++ b/src/hostlist/hostlist.conf | |||
@@ -10,5 +10,6 @@ OPTIONS = -b | |||
10 | SERVERS = http://v9.gnunet.org:58080/ http://ioerror.gnunet.org:65535/ | 10 | SERVERS = http://v9.gnunet.org:58080/ http://ioerror.gnunet.org:65535/ |
11 | # proxy for downloading hostlists | 11 | # proxy for downloading hostlists |
12 | HTTP-PROXY = | 12 | HTTP-PROXY = |
13 | 13 | # bind hostlist http server to a specific IPv4 or IPv6 | |
14 | # BINDTOIP = | ||
14 | 15 | ||