aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorAlessio Vanni <vannilla@firemail.cc>2020-05-27 15:01:30 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-27 22:37:08 +0200
commitcf4608196bc02093409dbf6b7a24e6ed08c36f76 (patch)
tree46c2ecc852810e35d9d5eabcfcb52620e06aaa3f /src/cadet
parent3a966c83d32db67d0e9cb23675f28b7233280aeb (diff)
downloadgnunet-cf4608196bc02093409dbf6b7a24e6ed08c36f76.tar.gz
gnunet-cf4608196bc02093409dbf6b7a24e6ed08c36f76.zip
Make REQUEST_AGPL messages configurable and add handler by default
This makes two changes: * Add a field to `struct GNUNET_OS_ProjectData' containing a URL (as a string) pointing to the source code of the application. * If the field is not NULL, add a handler for the REQUEST_AGPL messages sending the specified URL to the client. The handler is added both in client-service communications (i.e. local services that don't make requests to other peers in the network) and in peer-peer communications (CADET.) This way, any client (local or remote with CADET) can request the source code location using a standardized mechanism instead of writing ad-hoc solutions (unless the service/peer explicitly specifies a NULL pointer.) Signed-off-by: Christian Grothoff <christian@grothoff.org>
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/cadet_api.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index 68bd4c290..3a75266b7 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -995,6 +995,32 @@ GNUNET_CADET_connect (const struct GNUNET_CONFIGURATION_Handle *cfg)
995 995
996 996
997/** 997/**
998 * Function to return link to AGPL source upon request.
999 *
1000 * @param cls closure with the identification of the client
1001 * @param msg AGPL request
1002 */
1003static void
1004return_agpl (void *cls, const struct GNUNET_MessageHeader *msg)
1005{
1006 struct GNUNET_SERVICE_Client *client = cls;
1007 struct GNUNET_MQ_Handle *mq;
1008 struct GNUNET_MQ_Envelope *env;
1009 struct GNUNET_MessageHeader *res;
1010 size_t slen;
1011 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
1012
1013 (void) msg;
1014 slen = strlen (pd->agpl_url) + 1;
1015 env = GNUNET_MQ_msg_extra (res, GNUNET_MESSAGE_TYPE_RESPONSE_AGPL, slen);
1016 memcpy (&res[1], GNUNET_AGPL_URL, slen);
1017 mq = GNUNET_SERVICE_client_get_mq (client);
1018 GNUNET_MQ_send (mq, env);
1019 GNUNET_SERVICE_client_continue (client);
1020}
1021
1022
1023/**
998 * Open a port to receive incomming MQ-based channels. 1024 * Open a port to receive incomming MQ-based channels.
999 * 1025 *
1000 * @param h CADET handle. 1026 * @param h CADET handle.
@@ -1016,6 +1042,7 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
1016 const struct GNUNET_MQ_MessageHandler *handlers) 1042 const struct GNUNET_MQ_MessageHandler *handlers)
1017{ 1043{
1018 struct GNUNET_CADET_Port *p; 1044 struct GNUNET_CADET_Port *p;
1045 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
1019 1046
1020 GNUNET_assert (NULL != connects); 1047 GNUNET_assert (NULL != connects);
1021 GNUNET_assert (NULL != disconnects); 1048 GNUNET_assert (NULL != disconnects);
@@ -1039,7 +1066,9 @@ GNUNET_CADET_open_port (struct GNUNET_CADET_Handle *h,
1039 p->cls = connects_cls; 1066 p->cls = connects_cls;
1040 p->window_changes = window_changes; 1067 p->window_changes = window_changes;
1041 p->disconnects = disconnects; 1068 p->disconnects = disconnects;
1042 p->handlers = GNUNET_MQ_copy_handlers (handlers); 1069 p->handlers = (NULL == pd->agpl_url)
1070 ? GNUNET_MQ_copy_handlers (handlers)
1071 : GNUNET_MQ_copy_handlers2 (handlers, &return_agpl, NULL);
1043 1072
1044 GNUNET_assert (GNUNET_OK == open_port_cb (h, &p->id, p)); 1073 GNUNET_assert (GNUNET_OK == open_port_cb (h, &p->id, p));
1045 return p; 1074 return p;