aboutsummaryrefslogtreecommitdiff
path: root/src/util/service.c
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/util/service.c
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/util/service.c')
-rw-r--r--src/util/service.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/util/service.c b/src/util/service.c
index 9dc14eba9..ea078b19b 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1823,9 +1823,10 @@ return_agpl (void *cls, const struct GNUNET_MessageHeader *msg)
1823 struct GNUNET_MQ_Envelope *env; 1823 struct GNUNET_MQ_Envelope *env;
1824 struct GNUNET_MessageHeader *res; 1824 struct GNUNET_MessageHeader *res;
1825 size_t slen; 1825 size_t slen;
1826 const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get ();
1826 1827
1827 (void) msg; 1828 (void) msg;
1828 slen = strlen (GNUNET_AGPL_URL) + 1; 1829 slen = strlen (pd->agpl_url) + 1;
1829 env = GNUNET_MQ_msg_extra (res, GNUNET_MESSAGE_TYPE_RESPONSE_AGPL, slen); 1830 env = GNUNET_MQ_msg_extra (res, GNUNET_MESSAGE_TYPE_RESPONSE_AGPL, slen);
1830 memcpy (&res[1], GNUNET_AGPL_URL, slen); 1831 memcpy (&res[1], GNUNET_AGPL_URL, slen);
1831 mq = GNUNET_SERVICE_client_get_mq (client); 1832 mq = GNUNET_SERVICE_client_get_mq (client);
@@ -2019,7 +2020,9 @@ GNUNET_SERVICE_run_ (int argc,
2019 sh.connect_cb = connect_cb; 2020 sh.connect_cb = connect_cb;
2020 sh.disconnect_cb = disconnect_cb; 2021 sh.disconnect_cb = disconnect_cb;
2021 sh.cb_cls = cls; 2022 sh.cb_cls = cls;
2022 sh.handlers = GNUNET_MQ_copy_handlers (handlers); 2023 sh.handlers = (NULL == pd->agpl_url)
2024 ? GNUNET_MQ_copy_handlers (handlers)
2025 : GNUNET_MQ_copy_handlers2 (handlers, &return_agpl, NULL);
2023 sh.service_name = service_name; 2026 sh.service_name = service_name;
2024 sh.ret = 0; 2027 sh.ret = 0;
2025 /* setup subsystems */ 2028 /* setup subsystems */