Start server offering our hostlist.
645 unsigned long long port;
652 struct sockaddr_in v4;
653 struct sockaddr_in6 v6;
654 const struct sockaddr *sa4;
655 const struct sockaddr *sa6;
661 "Advertising not enabled on this hostlist server\n");
666 "Advertising enabled on this hostlist server\n");
674 _ (
"Could not access PEERINFO service. Exiting.\n"));
682 if ((0 ==
port) || (
port > UINT16_MAX))
685 _ (
"Invalid port number %llu. Exiting.\n"),
697 _ (
"Hostlist service starts on %s:%llu\n"),
712 (
unsigned int)
port);
714 _ (
"Address to obtain hostlist: `%s'\n"),
729 _ (
"BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV4.\n"));
743 _ (
"BINDTOIP does not a valid IPv4 address! Ignoring BINDTOIPV6.\n"));
751 if (1 == inet_pton (AF_INET,
ipv4, &i4))
753 memset (&v4, 0,
sizeof(v4));
754 v4.sin_family = AF_INET;
756 v4.sin_port = htons (
port);
757 #if HAVE_SOCKADDR_IN_SIN_LEN
758 v4.sin_len =
sizeof(v4);
760 sa4 = (
const struct sockaddr *) &v4;
765 "`%s' is not a valid IPv4 address! Ignoring BINDTOIPV4.\n"),
772 if (1 == inet_pton (AF_INET6,
ipv6, &i6))
774 memset (&v6, 0,
sizeof(v6));
775 v6.sin6_family = AF_INET6;
777 v6.sin6_port = htons (
port);
778 #if HAVE_SOCKADDR_IN_SIN_LEN
779 v6.sin6_len =
sizeof(v6);
781 sa6 = (
const struct sockaddr *) &v6;
786 "`%s' is not a valid IPv6 address! Ignoring BINDTOIPV6.\n"),
797 MHD_OPTION_CONNECTION_LIMIT,
799 MHD_OPTION_PER_IP_CONNECTION_LIMIT,
801 MHD_OPTION_CONNECTION_TIMEOUT,
803 MHD_OPTION_CONNECTION_MEMORY_LIMIT,
804 (
size_t) (16 * 1024),
805 MHD_OPTION_SOCK_ADDR,
814 MHD_OPTION_CONNECTION_LIMIT,
816 MHD_OPTION_PER_IP_CONNECTION_LIMIT,
818 MHD_OPTION_CONNECTION_TIMEOUT,
820 MHD_OPTION_CONNECTION_MEMORY_LIMIT,
821 (
size_t) (16 * 1024),
822 MHD_OPTION_SOCK_ADDR,
829 _ (
"Could not start hostlist HTTP server on port %u\n"),
830 (
unsigned short)
port);
static uint16_t port
Port number.
static struct GNUNET_SCHEDULER_Task * st
The shutdown task.
static GNUNET_CORE_ConnectEventHandler server_ch
Handle to hostlist server's connect handler.
#define MAX_URL_LEN
How long can hostlist URLs be?
static void * connect_handler(void *cls, const struct GNUNET_PeerIdentity *peer, struct GNUNET_MQ_Handle *mq)
Method called whenever a given peer connects.
static struct MHD_Daemon * daemon_handle_v6
Handle to the HTTP server as provided by libmicrohttpd for IPv6.
static struct MHD_Daemon * daemon_handle_v4
Handle to the HTTP server as provided by libmicrohttpd for IPv4.
static struct GNUNET_SCHEDULER_Task * hostlist_task_v4
Our primary task for IPv4.
static struct GNUNET_CORE_Handle * core
Handle to the core service (NULL until we've connected to it).
static int advertising
Set if we are allowed to advertise our hostlist to others.
static struct GNUNET_STATISTICS_Handle * stats
For keeping statistics.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_SCHEDULER_Task * hostlist_task_v6
Our primary task for IPv6.
static void process_notify(void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Message *hello, const char *err_msg)
PEERINFO calls this function to let us know about a possible peer that we might want to connect to.
static struct GNUNET_PEERINFO_Handle * peerinfo
Handle for accessing peerinfo service.
static struct GNUNET_SCHEDULER_Task * prepare_daemon(struct MHD_Daemon *daemon_handle)
Function that queries MHD's select sets and starts the task waiting for them.
static MHD_RESULT access_handler_callback(void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **con_cls)
Main request handler.
static struct GNUNET_PEERINFO_NotifyContext * notify
Handle to the peerinfo notify service (NULL until we've connected to it).
static char * hostlist_uri
Buffer for the hostlist address.
static MHD_RESULT accept_policy_callback(void *cls, const struct sockaddr *addr, socklen_t addrlen)
Hostlist access policy (very permissive, allows everything).
static char * hostname
Our hostname; we give this to all the peers we start.
static int ipv4
Option -4: IPv4 requested.
static int ipv6
Option -6: IPv6 requested.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_have_value(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option)
Test if we have a value for a particular option.
#define GNUNET_log(kind,...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PEERINFO_NotifyContext * GNUNET_PEERINFO_notify(const struct GNUNET_CONFIGURATION_Handle *cfg, int include_friend_only, GNUNET_PEERINFO_Processor callback, void *callback_cls)
Call a method whenever our known information about peers changes.
struct GNUNET_PEERINFO_Handle * GNUNET_PEERINFO_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Connect to the peerinfo service.
char * GNUNET_RESOLVER_local_fqdn_get(void)
Get local fully qualified domain name.
static unsigned int size
Size of the "table".