aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-06-06 00:32:36 +0200
committerChristian Grothoff <christian@grothoff.org>2018-06-06 00:32:36 +0200
commit90e29258a5339d232ea1b22f3f83d61701b52358 (patch)
tree1dcdab00bbbafdc3a30c82c390f66af0d82ecba2 /src
parente13828526819ba1b37877950b8cef75a4c7787b4 (diff)
changes for AGPL handling
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_mq_lib.h18
-rw-r--r--src/include/gnunet_protocols.h17
-rw-r--r--src/include/gnunet_util_lib.h8
-rw-r--r--src/util/mq.c37
-rw-r--r--src/util/service.c40
5 files changed, 115 insertions, 5 deletions
diff --git a/src/include/gnunet_mq_lib.h b/src/include/gnunet_mq_lib.h
index fe699c48f0..daf1869fb5 100644
--- a/src/include/gnunet_mq_lib.h
+++ b/src/include/gnunet_mq_lib.h
@@ -340,6 +340,24 @@ GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers);
/**
+ * Copy an array of handlers, appending AGPL handler.
+ *
+ * Useful if the array has been delared in local memory and needs to be
+ * persisted for future use.
+ *
+ * @param handlers Array of handlers to be copied. Can be NULL (nothing done).
+ * @param agpl_handler function to call for AGPL handling
+ * @param agpl_cls closure for @a agpl_handler
+ * @return A newly allocated array of handlers.
+ * Needs to be freed with #GNUNET_free.
+ */
+struct GNUNET_MQ_MessageHandler *
+GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers,
+ GNUNET_MQ_MessageCallback agpl_handler,
+ void *agpl_cls);
+
+
+/**
* Count the handlers in a handler array.
*
* @param handlers Array of handlers to be counted.
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h
index 7040f2cbf5..60dbeeb789 100644
--- a/src/include/gnunet_protocols.h
+++ b/src/include/gnunet_protocols.h
@@ -1,6 +1,6 @@
/*
This file is part of GNUnet.
- Copyright (C) 2001--2015 GNUnet e.V.
+ Copyright (C) 2001--2018 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -86,6 +86,21 @@ extern "C"
#define GNUNET_MESSAGE_TYPE_RESOLVER_RESPONSE 5
/*******************************************************************************
+ * AGPL source code download
+ * *****************************************************************************/
+
+/**
+ * Message to request source code link.
+ */
+#define GNUNET_MESSAGE_TYPE_REQUEST_AGPL 6
+
+/**
+ * Source code link.
+ */
+#define GNUNET_MESSAGE_TYPE_RESPONSE_AGPL 7
+
+
+/*******************************************************************************
* ARM message types
******************************************************************************/
diff --git a/src/include/gnunet_util_lib.h b/src/include/gnunet_util_lib.h
index a9bd6c33fe..e82e6caee9 100644
--- a/src/include/gnunet_util_lib.h
+++ b/src/include/gnunet_util_lib.h
@@ -52,6 +52,14 @@ extern "C"
*/
#define GNUNET_MIN_MESSAGE_SIZE sizeof (struct GNUNET_MessageHeader)
+/**
+ * NOTE: You MUST adjust this URL to point to the location of a
+ * publicly accessible repository (or TGZ) containing the sources of
+ * THIS release. Otherwise, you are violating the Affero GPL if you make
+ * this service available to anyone but yourself.
+ */
+#define GNUNET_AGPL_URL "https://gnunet.org/git/gnunet.git#" PACKAGE_VERSION;
+
#include "gnunet_crypto_lib.h"
#include "gnunet_bandwidth_lib.h"
diff --git a/src/util/mq.c b/src/util/mq.c
index 81a42e0c68..bf8f957906 100644
--- a/src/util/mq.c
+++ b/src/util/mq.c
@@ -1216,6 +1216,43 @@ GNUNET_MQ_copy_handlers (const struct GNUNET_MQ_MessageHandler *handlers)
/**
+ * Copy an array of handlers, appending AGPL handler.
+ *
+ * Useful if the array has been delared in local memory and needs to be
+ * persisted for future use.
+ *
+ * @param handlers Array of handlers to be copied. Can be NULL (nothing done).
+ * @param agpl_handler function to call for AGPL handling
+ * @param agpl_cls closure for @a agpl_handler
+ * @return A newly allocated array of handlers.
+ * Needs to be freed with #GNUNET_free.
+ */
+struct GNUNET_MQ_MessageHandler *
+GNUNET_MQ_copy_handlers2 (const struct GNUNET_MQ_MessageHandler *handlers,
+ GNUNET_MQ_MessageCallback agpl_handler,
+ void *agpl_cls)
+{
+ struct GNUNET_MQ_MessageHandler *copy;
+ unsigned int count;
+
+ if (NULL == handlers)
+ return NULL;
+ count = GNUNET_MQ_count_handlers (handlers);
+ copy = GNUNET_new_array (count + 2,
+ struct GNUNET_MQ_MessageHandler);
+ GNUNET_memcpy (copy,
+ handlers,
+ count * sizeof (struct GNUNET_MQ_MessageHandler));
+ copy[count].mv = NULL;
+ copy[count].cb = agpl_handler;
+ copy[count].cls = agpl_cls;
+ copy[count].type = GNUNET_MESSAGE_TYPE_REQUEST_AGPL;
+ copy[count].expected_size = sizeof (struct GNUNET_MessageHeader);
+ return copy;
+}
+
+
+/**
* Count the handlers in a handler array.
*
* @param handlers Array of handlers to be counted.
diff --git a/src/util/service.c b/src/util/service.c
index 1156093f4c..ae18099508 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1572,6 +1572,36 @@ teardown_service (struct GNUNET_SERVICE_Handle *sh)
/**
+ * Function to return link to AGPL source upon request.
+ *
+ * @param cls closure with the identification of the client
+ * @param msg AGPL request
+ */
+static void
+return_agpl (void *cls,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct GNUNET_SERVICE_Client *client = cls;
+ struct GNUNET_MQ_Handle *mq;
+ struct GNUNET_MQ_Envelope *env;
+ struct GNUNET_MessageHeader *res;
+ size_t slen;
+
+ slen = strlen (GNUNET_AGPL_URL) + 1;
+ env = GNUNET_MQ_msg_extra (res,
+ GNUNET_MESSAGE_TYPE_RESPONSE_AGPL,
+ slen);
+ memcpy (&res[1],
+ GNUNET_AGPL_URL,
+ slen);
+ mq = GNUNET_SERVICE_client_get_mq (client);
+ GNUNET_MQ_send (mq,
+ env);
+ GNUNET_SERVICE_client_continue (client);
+}
+
+
+/**
* Low-level function to start a service if the scheduler
* is already running. Should only be used directly in
* special cases.
@@ -1623,7 +1653,9 @@ GNUNET_SERVICE_start (const char *service_name,
sh->connect_cb = connect_cb;
sh->disconnect_cb = disconnect_cb;
sh->cb_cls = cls;
- sh->handlers = GNUNET_MQ_copy_handlers (handlers);
+ sh->handlers = GNUNET_MQ_copy_handlers2 (handlers,
+ &return_agpl,
+ NULL);
if (GNUNET_OK != setup_service (sh))
{
GNUNET_free_non_null (sh->handlers);
@@ -1723,9 +1755,9 @@ GNUNET_SERVICE_run_ (int argc,
struct GNUNET_GETOPT_CommandLineOption service_options[] = {
GNUNET_GETOPT_option_cfgfile (&opt_cfg_filename),
GNUNET_GETOPT_option_flag ('d',
- "daemonize",
- gettext_noop ("do daemonize (detach from terminal)"),
- &do_daemonize),
+ "daemonize",
+ gettext_noop ("do daemonize (detach from terminal)"),
+ &do_daemonize),
GNUNET_GETOPT_option_help (NULL),
GNUNET_GETOPT_option_loglevel (&loglev),
GNUNET_GETOPT_option_logfile (&logfile),