summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-08-14 11:17:30 +0200
committerChristian Grothoff <christian@grothoff.org>2018-08-14 11:17:30 +0200
commit5bb2565bab0b8fa8cac263b9fb70edf3ae2278d9 (patch)
tree33d2a86abe831bfd3cd711ad7332433b35891766
parent97e72521285a2ff2189334cb43d0a8f385d73e4a (diff)
parent4cc09ba10da89ac32b4a40bde9abbe77bba21c78 (diff)
resolve merge conflict with peerinfo plugin move
-rw-r--r--configure.ac1
-rw-r--r--po/POTFILES.in12
-rw-r--r--src/Makefile.am8
-rw-r--r--src/cadet/Makefile.am12
-rw-r--r--src/cadet/cadet_api.c3
-rw-r--r--src/cadet/gnunet-service-cadet_hello.c7
-rw-r--r--src/cadet/test_cadet.c261
-rw-r--r--src/gns/Makefile.am19
-rw-r--r--src/hostlist/hostlist.conf2
-rw-r--r--src/identity/Makefile.am19
-rw-r--r--src/identity/gnunet-service-identity.c2
-rwxr-xr-xsrc/identity/test_plugin_rest_identity.sh159
-rw-r--r--src/json/json_generator.c32
-rw-r--r--src/json/json_gnsrecord.c8
-rw-r--r--src/jsonapi/Makefile.am19
-rw-r--r--src/jsonapi/plugin_rest_reclaim.c (renamed from src/reclaim/plugin_rest_reclaim.c)0
-rw-r--r--src/namestore/Makefile.am23
-rwxr-xr-xsrc/namestore/test_plugin_rest_namestore.sh208
-rw-r--r--src/peerinfo-tool/Makefile.am21
-rw-r--r--src/peerinfo/Makefile.am1
-rw-r--r--src/reclaim/Makefile.am33
-rw-r--r--src/rest-plugins/Makefile.am105
-rw-r--r--src/rest-plugins/oidc_helper.c (renamed from src/reclaim/oidc_helper.c)0
-rw-r--r--src/rest-plugins/oidc_helper.h (renamed from src/reclaim/oidc_helper.h)0
-rw-r--r--src/rest-plugins/plugin_rest_copying.c (renamed from src/rest/plugin_rest_copying.c)0
-rw-r--r--src/rest-plugins/plugin_rest_gns.c (renamed from src/gns/plugin_rest_gns.c)62
-rw-r--r--src/rest-plugins/plugin_rest_identity.c (renamed from src/identity/plugin_rest_identity.c)806
-rw-r--r--src/rest-plugins/plugin_rest_namestore.c (renamed from src/namestore/plugin_rest_namestore.c)524
-rw-r--r--src/rest-plugins/plugin_rest_openid_connect.c (renamed from src/reclaim/plugin_rest_openid_connect.c)0
-rw-r--r--src/rest-plugins/plugin_rest_peerinfo.c (renamed from src/peerinfo-tool/plugin_rest_peerinfo.c)57
-rwxr-xr-xsrc/rest-plugins/test_plugin_rest_gns.sh (renamed from src/gns/test_plugin_rest_gns.sh)22
-rwxr-xr-xsrc/rest-plugins/test_plugin_rest_identity.sh157
-rwxr-xr-xsrc/rest-plugins/test_plugin_rest_namestore.sh147
-rw-r--r--src/rest/Makefile.am13
-rw-r--r--src/rps/gnunet-rps-profiler.c20
-rw-r--r--src/rps/gnunet-service-rps.c828
-rw-r--r--src/rps/gnunet-service-rps_custommap.c1
-rw-r--r--src/rps/rps-test_util.c2
-rw-r--r--src/rps/test_rps.c2
-rw-r--r--src/rps/test_rps.conf3
40 files changed, 1940 insertions, 1659 deletions
diff --git a/configure.ac b/configure.ac
index 535ce0ffe..6a75b1ebf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1758,6 +1758,7 @@ src/vpn/vpn.conf
src/zonemaster/Makefile
src/zonemaster/zonemaster.conf
src/rest/Makefile
+src/rest-plugins/Makefile
src/abe/Makefile
src/reclaim-attribute/Makefile
src/reclaim/Makefile
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 070ecc4ce..5eda765b1 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -235,7 +235,6 @@ src/namestore/namestore_api_monitor.c
src/namestore/plugin_namestore_flat.c
src/namestore/plugin_namestore_postgres.c
src/namestore/plugin_namestore_sqlite.c
-src/namestore/plugin_rest_namestore.c
src/nat-auto/gnunet-nat-auto.c
src/nat-auto/gnunet-nat-auto_legacy.c
src/nat-auto/gnunet-nat-server.c
@@ -262,7 +261,6 @@ src/nse/nse_api.c
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/peerinfo_api.c
src/peerinfo/peerinfo_api_notify.c
-src/peerinfo/plugin_rest_peerinfo.c
src/peerinfo-tool/gnunet-peerinfo.c
src/peerinfo-tool/gnunet-peerinfo_plugins.c
src/peerstore/gnunet-peerstore.c
@@ -297,8 +295,6 @@ src/reclaim/jwt.c
src/reclaim/oidc_helper.c
src/reclaim/plugin_gnsrecord_reclaim.c
src/reclaim/plugin_reclaim_sqlite.c
-src/reclaim/plugin_rest_openid_connect.c
-src/reclaim/plugin_rest_reclaim.c
src/reclaim/reclaim_api.c
src/regex/gnunet-daemon-regexprofiler.c
src/regex/gnunet-regex-profiler.c
@@ -314,6 +310,13 @@ src/regex/regex_internal_dht.c
src/regex/regex_test_graph.c
src/regex/regex_test_lib.c
src/regex/regex_test_random.c
+src/rest-plugins/oidc_helper.c
+src/rest-plugins/plugin_rest_copying.c
+src/rest-plugins/plugin_rest_gns.c
+src/rest-plugins/plugin_rest_identity.c
+src/rest-plugins/plugin_rest_namestore.c
+src/rest-plugins/plugin_rest_openid_connect.c
+src/rest-plugins/plugin_rest_peerinfo.c
src/rest/gnunet-rest-server.c
src/rest/plugin_rest_copying.c
src/rest/rest.c
@@ -329,6 +332,7 @@ src/rps/gnunet-service-rps_sampler.c
src/rps/gnunet-service-rps_sampler_elem.c
src/rps/gnunet-service-rps_view.c
src/rps/rps_api.c
+src/rps/rps_test_lib.c
src/rps/rps-test_util.c
src/scalarproduct/gnunet-scalarproduct.c
src/scalarproduct/gnunet-service-scalarproduct_alice.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 53d157da3..43b1004eb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -65,9 +65,8 @@ if HAVE_POSTGRESQL
endif
if HAVE_MHD
- REST_DIR = rest
if HAVE_JSON
- JSONAPI_DIR = jsonapi
+ REST_DIR = rest jsonapi rest-plugins
endif
endif
@@ -82,9 +81,6 @@ SUBDIRS = \
include $(INTLEMU_SUBDIRS) \
util \
gnsrecord \
- $(JSON_DIR) \
- $(REST_DIR) \
- $(JSONAPI_DIR) \
hello \
block \
statistics \
@@ -130,6 +126,8 @@ SUBDIRS = \
exit \
pt \
secretsharing \
+ $(JSON_DIR) \
+ $(REST_DIR) \
integration-tests \
$(EXP_DIR)
diff --git a/src/cadet/Makefile.am b/src/cadet/Makefile.am
index ce30ebe46..b2d436061 100644
--- a/src/cadet/Makefile.am
+++ b/src/cadet/Makefile.am
@@ -90,6 +90,7 @@ check_PROGRAMS = \
test_cadet_2_speed_backwards \
test_cadet_2_speed_reliable \
test_cadet_2_speed_reliable_backwards \
+ test_cadet_2_reopen \
test_cadet_5_forward \
test_cadet_5_signal \
test_cadet_5_keepalive \
@@ -97,7 +98,8 @@ check_PROGRAMS = \
test_cadet_5_speed_ack \
test_cadet_5_speed_reliable \
test_cadet_5_speed_reliable_backwards \
- test_cadet_5_speed_backwards
+ test_cadet_5_speed_backwards \
+ test_cadet_5_reopen
endif
@@ -197,6 +199,14 @@ test_cadet_5_speed_reliable_backwards_SOURCES = \
test_cadet.c
test_cadet_5_speed_reliable_backwards_LDADD = $(ld_cadet_test_lib)
+test_cadet_2_reopen_SOURCES = \
+ test_cadet.c
+test_cadet_2_reopen_LDADD = $(ld_cadet_test_lib)
+
+test_cadet_5_reopen_SOURCES = \
+ test_cadet.c
+test_cadet_5_reopen_LDADD = $(ld_cadet_test_lib)
+
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
diff --git a/src/cadet/cadet_api.c b/src/cadet/cadet_api.c
index e2ca461a5..23ea46e59 100644
--- a/src/cadet/cadet_api.c
+++ b/src/cadet/cadet_api.c
@@ -549,6 +549,9 @@ cadet_mq_error_handler (void *cls,
else
{
GNUNET_break (0);
+ if (NULL != ch->disconnects)
+ ch->disconnects (ch->ctx,
+ ch);
GNUNET_CADET_channel_destroy (ch);
}
}
diff --git a/src/cadet/gnunet-service-cadet_hello.c b/src/cadet/gnunet-service-cadet_hello.c
index 61686e5da..0061bddc2 100644
--- a/src/cadet/gnunet-service-cadet_hello.c
+++ b/src/cadet/gnunet-service-cadet_hello.c
@@ -17,13 +17,10 @@
*/
/**
* @file cadet/gnunet-service-cadet_hello.c
- * @brief spread knowledge about how to contact other peers from PEERINFO
+ * @brief spread knowledge about how to contact us (get HELLO from peerinfo),
+ * and remember HELLOs of other peers we have an interest in
* @author Bartlomiej Polot
* @author Christian Grothoff
- *
- * TODO:
- * - is most of this necessary/helpful?
- * - should we not simply restrict this to OUR hello?
*/
#include "platform.h"
#include "gnunet_util_lib.h"
diff --git a/src/cadet/test_cadet.c b/src/cadet/test_cadet.c
index 5187bc504..76ff258e0 100644
--- a/src/cadet/test_cadet.c
+++ b/src/cadet/test_cadet.c
@@ -70,6 +70,7 @@ struct CadetTestChannelWrapper
#define SPEED_ACK 4
#define SPEED_REL 8
#define P2P_SIGNAL 10
+#define REOPEN 11
/**
* Which test are we running?
@@ -177,6 +178,11 @@ struct GNUNET_CADET_TEST_Context *test_ctx;
static struct GNUNET_SCHEDULER_Task *disconnect_task;
/**
+ * Task called to reconnect peers.
+ */
+static struct GNUNET_SCHEDULER_Task *reconnect_task;
+
+/**
* Task To perform tests
*/
static struct GNUNET_SCHEDULER_Task *test_task;
@@ -374,7 +380,8 @@ stats_cont (void *cls,
"KA sent: %u, KA received: %u\n",
ka_sent,
ka_received);
- if ((KEEPALIVE == test) && ((ka_sent < 2) || (ka_sent > ka_received + 1)))
+ if ((KEEPALIVE == test || REOPEN == test) &&
+ ((ka_sent < 2) || (ka_sent > ka_received + 1)))
{
GNUNET_break (0);
ok--;
@@ -459,6 +466,152 @@ gather_stats_and_exit (void *cls)
/**
+ * Send a message on the channel with the appropriate size and payload.
+ *
+ * Update the appropriate *_sent counter.
+ *
+ * @param channel Channel to send the message on.
+ */
+static void
+send_test_message (struct GNUNET_CADET_Channel *channel);
+
+/**
+ * Check if payload is sane (size contains payload).
+ *
+ * @param cls should match #ch
+ * @param message The actual message.
+ * @return #GNUNET_OK to keep the channel open,
+ * #GNUNET_SYSERR to close it (signal serious error).
+ */
+static int
+check_data (void *cls,
+ const struct GNUNET_MessageHeader *message);
+
+/**
+ * Function is called whenever a message is received.
+ *
+ * @param cls closure (set from GNUNET_CADET_connect(), peer number)
+ * @param message the actual message
+ */
+static void
+handle_data (void *cls,
+ const struct GNUNET_MessageHeader *message);
+
+/**
+ * Function called whenever an MQ-channel is destroyed, even if the destruction
+ * was requested by #GNUNET_CADET_channel_destroy.
+ * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
+ *
+ * It should clean up any associated state, including cancelling any pending
+ * transmission on this channel.
+ *
+ * @param cls Channel closure (channel wrapper).
+ * @param channel Connection to the other end (henceforth invalid).
+ */
+static void
+disconnect_handler (void *cls,
+ const struct GNUNET_CADET_Channel *channel);
+
+
+/**
+ * Task to reconnect to other peer.
+ *
+ * @param cls Closure (line from which the task was scheduled).
+ */
+static void
+reconnect_op (void *cls)
+{
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (data,
+ GNUNET_MESSAGE_TYPE_DUMMY,
+ struct GNUNET_MessageHeader,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };
+ long l = (long) cls;
+ struct CadetTestChannelWrapper *ch;
+ enum GNUNET_CADET_ChannelOption flags;
+
+ reconnect_task = NULL;
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "reconnecting from line %ld\n",
+ l);
+ if (NULL != outgoing_ch)
+ {
+ GNUNET_CADET_channel_destroy (outgoing_ch);
+ outgoing_ch = NULL;
+ }
+ flags = GNUNET_CADET_OPTION_DEFAULT;
+ ch = GNUNET_new (struct CadetTestChannelWrapper);
+ outgoing_ch = GNUNET_CADET_channel_create (h1,
+ ch,
+ p_id[1],
+ &port,
+ flags,
+ NULL,
+ &disconnect_handler,
+ handlers);
+ ch->ch = outgoing_ch;
+ send_test_message (outgoing_ch);
+}
+
+/**
+ * Function called whenever an MQ-channel is destroyed, even if the destruction
+ * was requested by #GNUNET_CADET_channel_destroy.
+ * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
+ *
+ * It should clean up any associated state, including cancelling any pending
+ * transmission on this channel.
+ *
+ * @param cls Channel closure (channel wrapper).
+ * @param channel Connection to the other end (henceforth invalid).
+ */
+static void
+disconnect_handler (void *cls,
+ const struct GNUNET_CADET_Channel *channel)
+{
+ struct CadetTestChannelWrapper *ch_w = cls;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Channel disconnected at %d\n",
+ ok);
+ GNUNET_assert (ch_w->ch == channel);
+ if (channel == incoming_ch)
+ {
+ ok++;
+ incoming_ch = NULL;
+ }
+ else if (outgoing_ch == channel)
+ {
+ if (P2P_SIGNAL == test)
+ {
+ ok++;
+ }
+ outgoing_ch = NULL;
+ }
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Unknown channel! %p\n",
+ channel);
+ if (NULL != disconnect_task && REOPEN != test)
+ {
+ GNUNET_SCHEDULER_cancel (disconnect_task);
+ disconnect_task =
+ GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
+ (void *) __LINE__);
+ }
+ else if (NULL != reconnect_task && REOPEN == test)
+ {
+ GNUNET_SCHEDULER_cancel (reconnect_task);
+ reconnect_task =
+ GNUNET_SCHEDULER_add_now (&reconnect_op,
+ (void *) __LINE__);
+ }
+ GNUNET_free (ch_w);
+}
+
+
+/**
* Abort test: schedule disconnect and shutdown immediately
*
* @param line Line in the code the abort is requested from (__LINE__).
@@ -536,6 +689,14 @@ send_test_message (struct GNUNET_CADET_Channel *channel)
{
payload = data_sent;
}
+ else if (REOPEN == test)
+ {
+ payload = data_sent;
+ data_sent++;
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending DATA %u [%d bytes]\n",
+ data_sent, size);
+ }
else
{
GNUNET_assert (0);
@@ -784,13 +945,29 @@ connect_handler (void *cls,
(long) cls);
GNUNET_assert (0);
}
- if (NULL != disconnect_task)
+ if (NULL != disconnect_task && REOPEN != test)
{
GNUNET_SCHEDULER_cancel (disconnect_task);
disconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
&gather_stats_and_exit,
(void *) __LINE__);
}
+ else if ((NULL != disconnect_task) && (REOPEN == test))
+ {
+ GNUNET_SCHEDULER_cancel (disconnect_task);
+ disconnect_task = GNUNET_SCHEDULER_add_delayed (
+ GNUNET_TIME_relative_multiply (short_time, 2),
+ &gather_stats_and_exit,
+ (void *) __LINE__);
+ }
+
+ if ((NULL != reconnect_task) && (REOPEN == test))
+ {
+ GNUNET_SCHEDULER_cancel (reconnect_task);
+ reconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
+ &reconnect_op,
+ (void *) __LINE__);
+ }
/* TODO: cannot return channel as-is, in order to unify the data handlers */
ch = GNUNET_new (struct CadetTestChannelWrapper);
@@ -801,55 +978,6 @@ connect_handler (void *cls,
/**
- * Function called whenever an MQ-channel is destroyed, even if the destruction
- * was requested by #GNUNET_CADET_channel_destroy.
- * It must NOT call #GNUNET_CADET_channel_destroy on the channel.
- *
- * It should clean up any associated state, including cancelling any pending
- * transmission on this channel.
- *
- * @param cls Channel closure (channel wrapper).
- * @param channel Connection to the other end (henceforth invalid).
- */
-static void
-disconnect_handler (void *cls,
- const struct GNUNET_CADET_Channel *channel)
-{
- struct CadetTestChannelWrapper *ch_w = cls;
-
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Channel disconnected at %d\n",
- ok);
- GNUNET_assert (ch_w->ch == channel);
- if (channel == incoming_ch)
- {
- ok++;
- incoming_ch = NULL;
- }
- else if (outgoing_ch == channel)
- {
- if (P2P_SIGNAL == test)
- {
- ok++;
- }
- outgoing_ch = NULL;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Unknown channel! %p\n",
- channel);
- if (NULL != disconnect_task)
- {
- GNUNET_SCHEDULER_cancel (disconnect_task);
- disconnect_task =
- GNUNET_SCHEDULER_add_now (&gather_stats_and_exit,
- (void *) __LINE__);
- }
- GNUNET_free (ch_w);
-}
-
-
-/**
* START THE TESTCASE ITSELF, AS WE ARE CONNECTED TO THE CADET SERVICES.
*
* Testcase continues when the root receives confirmation of connected peers,
@@ -871,7 +999,7 @@ start_test (void *cls)
enum GNUNET_CADET_ChannelOption flags;
test_task = NULL;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test\n");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "start_test: %s\n", test_name);
if (NULL != disconnect_task)
{
GNUNET_SCHEDULER_cancel (disconnect_task);
@@ -903,7 +1031,6 @@ start_test (void *cls)
if (KEEPALIVE == test)
return; /* Don't send any data. */
-
data_received = 0;
data_sent = 0;
ack_received = 0;
@@ -912,6 +1039,18 @@ start_test (void *cls)
"Sending data initializer on channel %p...\n",
outgoing_ch);
send_test_message (outgoing_ch);
+ if (REOPEN == test)
+ {
+ reconnect_task = GNUNET_SCHEDULER_add_delayed (short_time,
+ &reconnect_op,
+ (void *) __LINE__);
+ GNUNET_SCHEDULER_cancel (disconnect_task);
+ disconnect_task = GNUNET_SCHEDULER_add_delayed (
+ GNUNET_TIME_relative_multiply (short_time, 2),
+ &gather_stats_and_exit,
+ (void *) __LINE__);
+ }
+
}
@@ -1055,6 +1194,11 @@ main (int argc, char *argv[])
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "5 PEER LINE\n");
peers_requested = 5;
}
+ else if (strstr (argv[0], "_6_") != NULL)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "6 PEER LINE\n");
+ peers_requested = 6;
+ }
else
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "SIZE UNKNOWN, USING 2\n");
@@ -1122,6 +1266,17 @@ main (int argc, char *argv[])
*/
ok_goal = 2;
}
+ else if (strstr (argv[0], "_reopen") != NULL)
+ {
+ test = REOPEN;
+ test_name = "reopen";
+ ///* Test is supposed to generate the following callbacks:
+ // * 1 incoming channel (@dest)
+ // * [wait]
+ // * 1 received channel destroy (@dest)
+ // */
+ ok_goal = 7;
+ }
else
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "UNKNOWN\n");
diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am
index 2c7bb8ebb..2659f7e6a 100644
--- a/src/gns/Makefile.am
+++ b/src/gns/Makefile.am
@@ -92,12 +92,6 @@ plugin_LTLIBRARIES = \
libgnunet_plugin_gnsrecord_gns.la
-if HAVE_MHD
-if HAVE_JSON
-plugin_LTLIBRARIES += libgnunet_plugin_rest_gns.la
-endif
-endif
-
libgnunet_plugin_gnsrecord_gns_la_SOURCES = \
plugin_gnsrecord_gns.c
libgnunet_plugin_gnsrecord_gns_la_LIBADD = \
@@ -238,19 +232,6 @@ libgnunet_plugin_block_gns_la_LIBADD = \
libgnunet_plugin_block_gns_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_gns_la_SOURCES = \
- plugin_rest_gns.c
-libgnunet_plugin_rest_gns_la_LIBADD = \
- libgnunetgns.la \
- $(top_builddir)/src/rest/libgnunetrest.la \
- $(top_builddir)/src/identity/libgnunetidentity.la \
- $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \
- $(top_builddir)/src/jsonapi/libgnunetjsonapiutils.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lmicrohttpd
-libgnunet_plugin_rest_gns_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
check_SCRIPTS = \
test_gns_lookup.sh \
diff --git a/src/hostlist/hostlist.conf b/src/hostlist/hostlist.conf
index 59cc351cc..32e5d8320 100644
--- a/src/hostlist/hostlist.conf
+++ b/src/hostlist/hostlist.conf
@@ -41,3 +41,5 @@ SERVERS = http://v10.gnunet.org/hostlist https://gnunet.io/hostlist
# Valid values: HTTP, HTTP_1_0, SOCKS4, SOCKS5, SOCKS4A, SOCKS5_HOSTNAME
# Default: HTTP
# PROXY_TYPE = HTTP
+
+
diff --git a/src/identity/Makefile.am b/src/identity/Makefile.am
index e7104f0c3..1f21fc65d 100644
--- a/src/identity/Makefile.am
+++ b/src/identity/Makefile.am
@@ -39,14 +39,6 @@ bin_PROGRAMS = \
libexec_PROGRAMS = \
gnunet-service-identity
-if HAVE_MHD
-if HAVE_JSON
-plugin_LTLIBRARIES = \
- libgnunet_plugin_rest_identity.la
-endif
-endif
-
-
gnunet_service_identity_SOURCES = \
gnunet-service-identity.c
gnunet_service_identity_LDADD = \
@@ -55,17 +47,6 @@ gnunet_service_identity_LDADD = \
$(GN_LIBINTL)
-libgnunet_plugin_rest_identity_la_SOURCES = \
- plugin_rest_identity.c
-libgnunet_plugin_rest_identity_la_LIBADD = \
- libgnunetidentity.la \
- $(top_builddir)/src/rest/libgnunetrest.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lmicrohttpd
-libgnunet_plugin_rest_identity_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
-
gnunet_identity_SOURCES = \
gnunet-identity.c
gnunet_identity_LDADD = \
diff --git a/src/identity/gnunet-service-identity.c b/src/identity/gnunet-service-identity.c
index 266f5ccc3..155c49cc5 100644
--- a/src/identity/gnunet-service-identity.c
+++ b/src/identity/gnunet-service-identity.c
@@ -752,7 +752,7 @@ handle_rename_message (void *cls,
old_name = GNUNET_strdup (old_name_tmp);
GNUNET_STRINGS_utf8_tolower (old_name_tmp, old_name);
new_name = GNUNET_strdup (&old_name_tmp[old_name_len]);
- GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], old_name);
+ GNUNET_STRINGS_utf8_tolower (&old_name_tmp[old_name_len], new_name);
/* check if new name is already in use */
for (ego = ego_head; NULL != ego; ego = ego->next)
diff --git a/src/identity/test_plugin_rest_identity.sh b/src/identity/test_plugin_rest_identity.sh
deleted file mode 100755
index d9377500e..000000000
--- a/src/identity/test_plugin_rest_identity.sh
+++ /dev/null
@@ -1,159 +0,0 @@
-#!/usr/bin/bash
-
-#First, start gnunet-arm and the rest-service.
-#Exit 0 means success, exit 1 means failed test
-
-identity_link="http://localhost:7776/identity"
-wrong_link="http://localhost:7776/identityandmore"
-
-
-curl_get () {
- #$1 is link
- #$2 is grep
- cache="$(curl -v "$1" 2>&1 | grep "$2")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-curl_post () {
- #$1 is link
- #$2 is data
- #$3 is grep
- cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-curl_delete () {
- #$1 is link
- #$2 is grep
- cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-curl_put () {
- #$1 is link
- #$2 is data
- #$3 is grep
- cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-#Test GET
-test="$(gnunet-identity -d)"
-#if no identity exists
-if [ "" == "$test" ]
-then
- curl_get "$identity_link" "error"
- gnunet-identity -C "test_plugin_rest_identity"
- name="$(gnunet-identity -d | awk 'NR==1{print $1}')"
- public="$(gnunet-identity -d | awk 'NR==1{print $3}')"
-
- curl_get "${identity_link}?name=$name" "$public"
- curl_get "${identity_link}?name=" "error"
- curl_get "${identity_link}?name=$public" "error"
-
- curl_get "${identity_link}?pubkey=$public" "$name"
- curl_get "${identity_link}?pubkey=$name" "error"
- curl_get "${identity_link}?pubkey=" "error"
-
- gnunet-identity -D "test_plugin_rest_identity"
-else
- name="$(gnunet-identity -d | awk 'NR==1{print $1}')"
- public="$(gnunet-identity -d | awk 'NR==1{print $3}')"
-
- curl_get "${identity_link}?name=$name" "$public"
- curl_get "${identity_link}?name=" "error"
- curl_get "${identity_link}?name=$public" "error"
-
- curl_get "${identity_link}?pubkey=$public" "$name"
- curl_get "${identity_link}?pubkey=$name" "error"
- curl_get "${identity_link}?pubkey=" "error"
-fi
-
-#Test POST
-gnunet-identity -D "test_plugin_rest_identity" > /dev/null 2>&1
-gnunet-identity -D "test_plugin_rest_identity1" > /dev/null 2>&1
-
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created"
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409"
-curl_post "${identity_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409"
-curl_post "${identity_link}" '{}' "error"
-curl_post "${identity_link}" '' "error"
-curl_post "${identity_link}" '{"name":""}' "error"
-curl_post "${identity_link}" '{"name":123}' "error"
-curl_post "${identity_link}" '{"name":[]}' "error"
-curl_post "${identity_link}" '{"name1":"test_plugin_rest_identity"}' "error"
-curl_post "${identity_link}" '{"other":""}' "error"
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error"
-
-#Test PUT
-name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')"
-public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
-
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 204"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'"}' "HTTP/1.1 409"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubkey":"'$public'xx"}' "HTTP/1.1 404"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubkey":""}' "HTTP/1.1 404"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubke":""}' "HTTP/1.1 404"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","other":"sdfdsf"}' "HTTP/1.1 404"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","pubke":"","name":"sdfdsf"}' "HTTP/1.1 404"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity","pubke":"","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
-curl_put "${identity_link}" '{"newnam":"test_plugin_rest_identity","pubkey":"'$public'"}' "error"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
-curl_put "${identity_link}" '{"newname":"TEST_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identityxxx"}' "HTTP/1.1 404"
-curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
-curl_put "${identity_link}" '{"newnam":"test_plugin_rest_identityfail","name":"test_plugin_rest_identity"}' "error"
-
-
-#Test subsystem
-curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
-curl_put "${identity_link}" '{"subsystem":"namestore","name":"test_plugin_rest_identity"}' "HTTP/1.1 204"
-curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity"
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
-public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
-curl_put "${identity_link}" '{"subsystem":"namestore","pubkey":"'"$public"'"}' "HTTP/1.1 204"
-curl_get "${identity_link}?subsystem=namestore" "test_plugin_rest_identity1"
-curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "error"
-curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
-curl_get "${identity_link}?subsystem=test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1"
-
-curl_put "${identity_link}" '{"subsyste":"test_plugin_rest_identity_no_subsystem","name":"test_plugin_rest_identity1"}' "error"
-curl_put "${identity_link}" '{"subsystem":"test_plugin_rest_identity_no_subsystem","name":"Test_plugin_rest_identity1"}' "HTTP/1.1 204"
-
-#Test DELETE
-curl_delete "${identity_link}?name=test_plugin_rest_identity" "HTTP/1.1 204"
-curl_get "${identity_link}?name=test_plugin_rest_identity" "error"
-curl_delete "${identity_link}?name=TEST_plugin_rest_identity1" "HTTP/1.1 404"
-curl_delete "${identity_link}?name=test_plugin_rest_identity1" "HTTP/1.1 204"
-curl_get "${identity_link}?name=test_plugin_rest_identity1" "error"
-curl_delete "${identity_link}?name=test_plugin_rest_identity_not_found" "HTTP/1.1 404"
-curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
-public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')"
-curl_delete "${identity_link}?pubkey=$public" "HTTP/1.1 204"
-curl_delete "${identity_link}?pubke=$public" "error"
-curl_delete "${identity_link}?pubkey=$public&other=232" "HTTP/1.1 404"
-
-#Test wrong_link
-curl_get "$wrong_link" "HTTP/1.1 404"
-curl_post "$wrong_link" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 404"
-curl_put "$wrong_link" '{"newname":"test_plugin_rest_identity1","name":"test_plugin_rest_identity"}' "HTTP/1.1 404"
-curl_delete "$wrong_link?name=test_plugin_rest_identity1" "HTTP/1.1 404"
-
-exit 0;
diff --git a/src/json/json_generator.c b/src/json/json_generator.c
index d8c82bc86..96f07bdc2 100644
--- a/src/json/json_generator.c
+++ b/src/json/json_generator.c
@@ -182,12 +182,32 @@ GNUNET_JSON_from_gns_record (const char* rname,
record_type_str = GNUNET_GNSRECORD_number_to_typename(rd->record_type);
// ? for possible NULL values
- ret = json_pack("{s:s?,s:s?,s:s?,s:i,s:s?}",
- "value", value_str,
- "type", record_type_str,
- "expiration_time", expiration_time_str,
- "flag", flags,
- "label", rname);
+ if (NULL != rname)
+ {
+ ret = json_pack ("{s:s?,s:s?,s:s?,s:i,s:s?}",
+ "value",
+ value_str,
+ "record_type",
+ record_type_str,
+ "expiration_time",
+ expiration_time_str,
+ "flag",
+ flags,
+ "record_name",
+ rname);
+ }
+ else
+ {
+ ret = json_pack ("{s:s?,s:s?,s:s?,s:i}",
+ "value",
+ value_str,
+ "record_type",
+ record_type_str,
+ "expiration_time",
+ expiration_time_str,
+ "flag",
+ flags);
+ }
GNUNET_free_non_null(value_str);
return ret;
}
diff --git a/src/json/json_gnsrecord.c b/src/json/json_gnsrecord.c
index 7bdf97f06..fe51119b1 100644
--- a/src/json/json_gnsrecord.c
+++ b/src/json/json_gnsrecord.c
@@ -26,10 +26,10 @@
#include "gnunet_json_lib.h"
#define GNUNET_JSON_GNSRECORD_VALUE "value"
-#define GNUNET_JSON_GNSRECORD_TYPE "type"
+#define GNUNET_JSON_GNSRECORD_TYPE "record_type"
#define GNUNET_JSON_GNSRECORD_EXPIRATION_TIME "expiration_time"
#define GNUNET_JSON_GNSRECORD_FLAG "flag"
-#define GNUNET_JSON_GNSRECORD_LABEL "label"
+#define GNUNET_JSON_GNSRECORD_RECORD_NAME "record_name"
#define GNUNET_JSON_GNSRECORD_NEVER "never"
@@ -52,7 +52,7 @@ parse_gnsrecordobject (void *cls,
const char *value;
const char *expiration_time;
const char *record_type;
- const char *label;
+ const char *name;
int flag;
void *rdata = NULL;
size_t rdata_size;
@@ -71,7 +71,7 @@ parse_gnsrecordobject (void *cls,
GNUNET_JSON_GNSRECORD_TYPE, &record_type,
GNUNET_JSON_GNSRECORD_EXPIRATION_TIME, &expiration_time,
GNUNET_JSON_GNSRECORD_FLAG, &flag,
- GNUNET_JSON_GNSRECORD_LABEL, &label);
+ GNUNET_JSON_GNSRECORD_RECORD_NAME, &name);
if (0 != unpack_state)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/jsonapi/Makefile.am b/src/jsonapi/Makefile.am
index 054d3c550..489c4d9f2 100644
--- a/src/jsonapi/Makefile.am
+++ b/src/jsonapi/Makefile.am
@@ -10,6 +10,25 @@ lib_LTLIBRARIES = \
libgnunetjsonapi.la \
libgnunetjsonapiutils.la
+if HAVE_ABE
+lib_LTLIBRARIES += libgnunet_plugin_rest_reclaim.la
+endif
+
+libgnunet_plugin_rest_reclaim_la_SOURCES = \
+ plugin_rest_reclaim.c
+libgnunet_plugin_rest_reclaim_la_LIBADD = \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(top_builddir)/src/reclaim/libgnunetreclaim.la \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ libgnunetjsonapi.la \
+ $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson -lmicrohttpd
+libgnunet_plugin_rest_reclaim_la_LDFLAGS = \
+ i$(GN_PLUGIN_LDFLAGS)
+
+
libgnunetjsonapiutils_la_LDFLAGS = \
-version-info 0:0:0 \
-no-undefined
diff --git a/src/reclaim/plugin_rest_reclaim.c b/src/jsonapi/plugin_rest_reclaim.c
index 38ffc4ddb..38ffc4ddb 100644
--- a/src/reclaim/plugin_rest_reclaim.c
+++ b/src/jsonapi/plugin_rest_reclaim.c
diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am
index 7f44c2a71..a349921d7 100644
--- a/src/namestore/Makefile.am
+++ b/src/namestore/Makefile.am
@@ -97,12 +97,6 @@ check_PROGRAMS = \
$(FLAT_TESTS)
endif
-if HAVE_MHD
-if HAVE_JSON
-REST_PLUGIN=libgnunet_plugin_rest_namestore.la
-endif
-endif
-
if ENABLE_TEST_RUN
AM_TESTS_ENVIRONMENT=export GNUNET_PREFIX=$${GNUNET_PREFIX:-@libdir@};export PATH=$${GNUNET_PREFIX:-@prefix@}/bin:$$PATH;unset XDG_DATA_HOME;unset XDG_CONFIG_HOME;
TESTS = \
@@ -186,8 +180,7 @@ gnunet_service_namestore_LDADD = \
plugin_LTLIBRARIES = \
$(SQLITE_PLUGIN) \
$(POSTGRES_PLUGIN) \
- $(FLAT_PLUGIN) \
- $(REST_PLUGIN)
+ $(FLAT_PLUGIN)
@@ -224,20 +217,6 @@ libgnunet_plugin_namestore_postgres_la_LIBADD = \
libgnunet_plugin_namestore_postgres_la_LDFLAGS = \
$(GN_PLUGIN_LDFLAGS) $(POSTGRESQL_LDFLAGS)
-libgnunet_plugin_rest_namestore_la_SOURCES = \
- plugin_rest_namestore.c
-libgnunet_plugin_rest_namestore_la_LIBADD = \
- libgnunetnamestore.la \
- $(top_builddir)/src/rest/libgnunetrest.la \
- $(top_builddir)/src/identity/libgnunetidentity.la \
- $(top_builddir)/src/json/libgnunetjson.la \
- $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lmicrohttpd
-libgnunet_plugin_rest_namestore_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
-
test_namestore_api_store_flat_SOURCES = \
test_namestore_api_store.c
test_namestore_api_store_flat_LDADD = \
diff --git a/src/namestore/test_plugin_rest_namestore.sh b/src/namestore/test_plugin_rest_namestore.sh
deleted file mode 100755
index de02dfafc..000000000
--- a/src/namestore/test_plugin_rest_namestore.sh
+++ /dev/null
@@ -1,208 +0,0 @@
-#!/usr/bin/bash
-
-#First, start gnunet-arm and the rest-service.
-#Exit 0 means success, exit 1 means failed test
-
-namestore_link="http://localhost:7776/namestore"
-wrong_link="http://localhost:7776/namestoreandmore"
-
-
-curl_get () {
- #$1 is link
- #$2 is grep
- cache="$(curl -v "$1" 2>&1 | grep "$2")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-curl_post () {
- #$1 is link
- #$2 is data
- #$3 is grep
- cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-curl_delete () {
- #$1 is link
- #$2 is grep
- cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")"
- #echo $cache
- if [ "" == "$cache" ]
- then
- exit 1
- fi
-}
-
-# curl_put () {
-# #$1 is link
-# #$2 is data
-# #$3 is grep
-# cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")"
-# #echo $cache
-# if [ "" == "$cache" ]
-# then
-# exit 1
-# fi
-# }
-
-#Test subsystem default identity
-
-#Test GET
-gnunet-identity -D "test_plugin_rest_namestore"
-gnunet-identity -C "test_plugin_rest_namestore"
-test="$(gnunet-namestore -D -z "test_plugin_rest_namestore")"
-name="test_plugin_rest_namestore"
-public="$(gnunet-identity -d | grep "test_plugin_rest_namestore" | awk 'NR==1{print $3}')"
-if [ "" == "$test" ]
-then
- #if no entries for test_plugin_rest_namestore
- curl_get "${namestore_link}?name=$name" "error"
- curl_get "${namestore_link}?name=" "error"
- curl_get "${namestore_link}?name=$public" "error"
-
- curl_get "${namestore_link}?pubkey=$public" "error"
- curl_get "${namestore_link}?pubkey=$name" "error"
- curl_get "${namestore_link}?pubkey=" "error"
-else
- #if entries exists (that should not be possible)
- curl_get "${namestore_link}" "HTTP/1.1 200 OK"
- curl_get "${namestore_link}?name=$name" "HTTP/1.1 200 OK"
- curl_get "${namestore_link}?name=" "error"
- curl_get "${namestore_link}?name=$public" "error"
-
- curl_get "${namestore_link}?pubkey=$public" "HTTP/1.1 200 OK"
- curl_get "${namestore_link}?pubkey=$name" "error"
- curl_get "${namestore_link}?pubkey=" "error"
-fi
-gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
-curl_get "${namestore_link}" "HTTP/1.1 200 OK"
-curl_get "${namestore_link}?name=$name" "HTTP/1.1 200 OK"
-curl_get "${namestore_link}?name=" "error"
-curl_get "${namestore_link}?name=$public" "error"
-curl_get "${namestore_link}?pubkey=$public" "HTTP/1.1 200 OK"
-curl_get "${namestore_link}?pubkey=$name" "error"
-curl_get "${namestore_link}?pubkey=" "error"
-gnunet-namestore -z $name -d -n "test_entry"
-
-#Test POST with NAME
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#value
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#time
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"0d","flag":0,"label":"test_entry"}' "HTTP/1.1 204"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"10000d","flag":0,"label":"test_entry"}' "HTTP/1.1 204"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"now","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time_missing":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#flag
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":2,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":8,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":16,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":-1,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":"Test","label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag_missing":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#label
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 409"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":""}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?name=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label_missing":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-
-#Test POST with PUBKEY
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#value
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#time
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"0d","flag":0,"label":"test_entry"}' "HTTP/1.1 204"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"10000d","flag":0,"label":"test_entry"}' "HTTP/1.1 204"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"now","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time_missing":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#flag
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":2,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":8,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":16,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":-1,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":"Test","label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag_missing":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-#label
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 204 No Content"
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "HTTP/1.1 409"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":""}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label_missing":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-
-#wrong zone
-curl_post "${namestore_link}?name=$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-curl_post "${namestore_link}?pubkey=$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "type":"PKEY", "expiration_time":"1d","flag":0,"label":"test_entry"}' "error"
-gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
-
-#Test DELETE
-gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
-curl_delete "${namestore_link}?label=test_entry&name=$name" "HTTP/1.1 204"
-gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
-curl_delete "${namestore_link}?label=test_entry&pubkey=$public" "HTTP/1.1 204"
-gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
-curl_delete "${namestore_link}?label=test_entry&pubkey=$name" "HTTP/1.1 404"
-
-
-#Test default identity
-#not possible without defining
-
-exit 0;
-
diff --git a/src/peerinfo-tool/Makefile.am b/src/peerinfo-tool/Makefile.am
index 6f9a3360c..429224650 100644
--- a/src/peerinfo-tool/Makefile.am
+++ b/src/peerinfo-tool/Makefile.am
@@ -26,27 +26,6 @@ gnunet_peerinfo_LDADD = \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/util/libgnunetutil.la
-if HAVE_MHD
-if HAVE_JSON
-plugin_LTLIBRARIES = \
- libgnunet_plugin_rest_peerinfo.la
-endif
-endif
-
-
-libgnunet_plugin_rest_peerinfo_la_SOURCES = \
- plugin_rest_peerinfo.c
-libgnunet_plugin_rest_peerinfo_la_LIBADD = \
- $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
- $(top_builddir)/src/transport/libgnunettransport.la \
- $(top_builddir)/src/rest/libgnunetrest.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lmicrohttpd
-libgnunet_plugin_rest_peerinfo_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
-
-
if HAVE_PYTHON
check_SCRIPTS = \
test_gnunet_peerinfo.py
diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am
index 926b9ae94..ef79d6720 100644
--- a/src/peerinfo/Makefile.am
+++ b/src/peerinfo/Makefile.am
@@ -25,7 +25,6 @@ libgnunetpeerinfo_la_SOURCES = \
libgnunetpeerinfo_la_LIBADD = \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/util/libgnunetutil.la \
- $(top_builddir)/src/json/libgnunetjson.la \
$(XLIB) \
$(LTLIBINTL)
libgnunetpeerinfo_la_LDFLAGS = \
diff --git a/src/reclaim/Makefile.am b/src/reclaim/Makefile.am
index 2ee43d21a..093442181 100644
--- a/src/reclaim/Makefile.am
+++ b/src/reclaim/Makefile.am
@@ -31,8 +31,6 @@ pkgcfg_DATA = \
lib_LTLIBRARIES = \
libgnunetreclaim.la
plugin_LTLIBRARIES = \
- libgnunet_plugin_rest_reclaim.la \
- libgnunet_plugin_rest_openid_connect.la \
libgnunet_plugin_gnsrecord_reclaim.la \
$(SQLITE_PLUGIN)
@@ -88,37 +86,6 @@ libgnunetreclaim_la_LDFLAGS = \
$(GN_LIB_LDFLAGS) $(WINFLAGS) \
-version-info 0:0:0
-libgnunet_plugin_rest_reclaim_la_SOURCES = \
- plugin_rest_reclaim.c
-libgnunet_plugin_rest_reclaim_la_LIBADD = \
- $(top_builddir)/src/identity/libgnunetidentity.la \
- libgnunetreclaim.la \
- $(top_builddir)/src/rest/libgnunetrest.la \
- $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \
- $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \
- $(top_builddir)/src/namestore/libgnunetnamestore.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lmicrohttpd
-libgnunet_plugin_rest_reclaim_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
-libgnunet_plugin_rest_openid_connect_la_SOURCES = \
- plugin_rest_openid_connect.c \
- oidc_helper.c
-libgnunet_plugin_rest_openid_connect_la_LIBADD = \
- $(top_builddir)/src/identity/libgnunetidentity.la \
- libgnunetreclaim.la \
- $(top_builddir)/src/rest/libgnunetrest.la \
- $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \
- $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \
- $(top_builddir)/src/namestore/libgnunetnamestore.la \
- $(top_builddir)/src/gns/libgnunetgns.la \
- $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lmicrohttpd
-libgnunet_plugin_rest_openid_connect_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
gnunet_reclaim_SOURCES = \
gnunet-reclaim.c
gnunet_reclaim_LDADD = \
diff --git a/src/rest-plugins/Makefile.am b/src/rest-plugins/Makefile.am
new file mode 100644
index 000000000..486692b72
--- /dev/null
+++ b/src/rest-plugins/Makefile.am
@@ -0,0 +1,105 @@
+# This Makefile.am is in the public domain
+AM_CPPFLAGS = -I$(top_srcdir)/src/include
+
+plugindir = $(libdir)/gnunet
+
+pkgcfgdir= $(pkgdatadir)/config.d/
+
+libexecdir= $(pkglibdir)/libexec/
+
+
+if MINGW
+ WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
+endif
+
+if USE_COVERAGE
+ AM_CFLAGS = --coverage -O0
+ XLIBS = -lgcov
+endif
+
+plugin_LTLIBRARIES = \
+ libgnunet_plugin_rest_copying.la \
+ libgnunet_plugin_rest_peerinfo.la \
+ libgnunet_plugin_rest_identity.la \
+ libgnunet_plugin_rest_namestore.la \
+ libgnunet_plugin_rest_gns.la
+if HAVE_ABE
+plugin_LTLIBRARIES += libgnunet_plugin_rest_openid_connect.la
+endif
+
+
+libgnunet_plugin_rest_copying_la_SOURCES = \
+ plugin_rest_copying.c
+libgnunet_plugin_rest_copying_la_LIBADD = \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -lmicrohttpd
+libgnunet_plugin_rest_copying_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunet_plugin_rest_peerinfo_la_SOURCES = \
+ plugin_rest_peerinfo.c
+libgnunet_plugin_rest_peerinfo_la_LIBADD = \
+ $(top_builddir)/src/peerinfo/libgnunetpeerinfo.la \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ $(top_builddir)/src/json/libgnunetjson.la \
+ $(top_builddir)/src/transport/libgnunettransport.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson -lmicrohttpd
+libgnunet_plugin_rest_peerinfo_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunet_plugin_rest_identity_la_SOURCES = \
+ plugin_rest_identity.c
+libgnunet_plugin_rest_identity_la_LIBADD = \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson -lmicrohttpd
+libgnunet_plugin_rest_identity_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+
+
+libgnunet_plugin_rest_namestore_la_SOURCES = \
+ plugin_rest_namestore.c
+libgnunet_plugin_rest_namestore_la_LIBADD = \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(top_builddir)/src/json/libgnunetjson.la \
+ $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson -lmicrohttpd
+libgnunet_plugin_rest_namestore_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunet_plugin_rest_gns_la_SOURCES = \
+ plugin_rest_gns.c
+libgnunet_plugin_rest_gns_la_LIBADD = \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(top_builddir)/src/json/libgnunetjson.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson -lmicrohttpd
+libgnunet_plugin_rest_gns_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+libgnunet_plugin_rest_openid_connect_la_SOURCES = \
+ plugin_rest_openid_connect.c \
+ oidc_helper.c
+libgnunet_plugin_rest_openid_connect_la_LIBADD = \
+ $(top_builddir)/src/identity/libgnunetidentity.la \
+ $(top_builddir)/src/reclaim/libgnunetreclaim.la \
+ $(top_builddir)/src/rest/libgnunetrest.la \
+ $(top_builddir)/src/jsonapi/libgnunetjsonapi.la \
+ $(top_builddir)/src/reclaim-attribute/libgnunetreclaimattribute.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+$(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/gnsrecord/libgnunetgnsrecord.la \
+ $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
+ $(LTLIBINTL) -ljansson -lmicrohttpd
+libgnunet_plugin_rest_openid_connect_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
diff --git a/src/reclaim/oidc_helper.c b/src/rest-plugins/oidc_helper.c
index 1e9e64fec..1e9e64fec 100644
--- a/src/reclaim/oidc_helper.c
+++ b/src/rest-plugins/oidc_helper.c
diff --git a/src/reclaim/oidc_helper.h b/src/rest-plugins/oidc_helper.h
index 7a0f45bf9..7a0f45bf9 100644
--- a/src/reclaim/oidc_helper.h
+++ b/src/rest-plugins/oidc_helper.h
diff --git a/src/rest/plugin_rest_copying.c b/src/rest-plugins/plugin_rest_copying.c
index 668dc5d38..668dc5d38 100644
--- a/src/rest/plugin_rest_copying.c
+++ b/src/rest-plugins/plugin_rest_copying.c
diff --git a/src/gns/plugin_rest_gns.c b/src/rest-plugins/plugin_rest_gns.c
index fd2469577..0bf4198fc 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/rest-plugins/plugin_rest_gns.c
@@ -30,15 +30,27 @@
#include "microhttpd.h"
#include <jansson.h>
+/**
+ * Rest API GNS Namespace
+ */
#define GNUNET_REST_API_NS_GNS "/gns"
-
-#define GNUNET_REST_GNS_PARAM_NAME "name"
-
+/**
+ * Rest API GNS Parameter record_type
+ */
#define GNUNET_REST_GNS_PARAM_RECORD_TYPE "record_type"
+
+/**
+ * Rest API GNS ERROR Unknown Error
+ */
#define GNUNET_REST_GNS_ERROR_UNKNOWN "Unknown Error"
/**
+ * Rest API GNS ERROR Record not found
+ */
+#define GNUNET_REST_GNS_NOT_FOUND "Record not found"
+
+/**
* The configuration handle
*/
const struct GNUNET_CONFIGURATION_Handle *cfg;
@@ -56,7 +68,9 @@ struct Plugin
const struct GNUNET_CONFIGURATION_Handle *cfg;
};
-
+/**
+ * The request handle
+ */
struct RequestHandle
{
@@ -116,7 +130,7 @@ struct RequestHandle
char *emsg;
/**
- * Reponse code
+ * Response code
*/
int response_code;
@@ -214,7 +228,8 @@ handle_gns_response (void *cls,
if (GNUNET_NO == was_gns)
{
- handle->emsg = GNUNET_strdup("Name not found in GNS");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -260,21 +275,24 @@ get_gns_cont (struct GNUNET_REST_RequestHandle *con_handle,
char *record_type;
char *name;
- GNUNET_CRYPTO_hash (GNUNET_REST_GNS_PARAM_NAME,
- strlen (GNUNET_REST_GNS_PARAM_NAME),
- &key);
- if ( GNUNET_NO
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
+ name = NULL;
+ handle->name = NULL;
+ if (strlen (GNUNET_REST_API_NS_GNS) < strlen (handle->url))
+ {
+ name = &handle->url[strlen (GNUNET_REST_API_NS_GNS) + 1];
+ }
+
+ if (NULL == name)
{
- handle->emsg = GNUNET_strdup("Parameter name is missing");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- name = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,&key);
- if(0 >= strlen (name))
+ if (0 >= strlen (name))
{
- handle->emsg = GNUNET_strdup("Length of parameter name is zero");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_GNS_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -292,27 +310,17 @@ get_gns_cont (struct GNUNET_REST_RequestHandle *con_handle,
handle->record_type = GNUNET_GNSRECORD_typename_to_number(record_type);
}
-
if(UINT32_MAX == handle->record_type)
{
handle->record_type = GNUNET_GNSRECORD_TYPE_ANY;
}
- handle->gns = GNUNET_GNS_connect (cfg);
- if (NULL == handle->gns)
- {
- handle->emsg = GNUNET_strdup ("GNS not available");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
-
handle->gns_lookup = GNUNET_GNS_lookup_with_tld (handle->gns,
handle->name,
handle->record_type,
GNUNET_NO,
&handle_gns_response,
handle);
- return;
}
@@ -397,7 +405,7 @@ rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
if (handle->url[strlen (handle->url)-1] == '/')
handle->url[strlen (handle->url)-1] = '\0';
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
-
+ handle->gns = GNUNET_GNS_connect (cfg);
init_cont(handle);
handle->timeout_task =
diff --git a/src/identity/plugin_rest_identity.c b/src/rest-plugins/plugin_rest_identity.c
index a518a74cc..9f1765a63 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/rest-plugins/plugin_rest_identity.c
@@ -29,22 +29,79 @@
#include "microhttpd.h"
#include <jansson.h>
+/**
+ * Identity Namespace
+ */
#define GNUNET_REST_API_NS_IDENTITY "/identity"
/**
- * Parameter names
+ * Identity Namespace with public key specifier
+ */
+#define GNUNET_REST_API_NS_IDENTITY_ALL "/identity/all"
+
+/**
+ * Identity Namespace with public key specifier
+ */
+#define GNUNET_REST_API_NS_IDENTITY_PUBKEY "/identity/pubkey"
+
+/**
+ * Identity Namespace with public key specifier
+ */
+#define GNUNET_REST_API_NS_IDENTITY_NAME "/identity/name"
+
+/**
+ * Identity Subsystem Namespace
+ */
+#define GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM "/identity/subsystem"
+
+/**
+ * Parameter public key
+ */
+#define GNUNET_REST_IDENTITY_PARAM_PUBKEY "pubkey"
+
+/**
+ * Parameter subsystem
+ */
+#define GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM "subsystem"
+
+/**
+ * Parameter name
*/
-#define GNUNET_REST_PARAM_PUBKEY "pubkey"
-#define GNUNET_REST_PARAM_SUBSYSTEM "subsystem"
-#define GNUNET_REST_PARAM_NAME "name"
-#define GNUNET_REST_PARAM_NEWNAME "newname"
+#define GNUNET_REST_IDENTITY_PARAM_NAME "name"
/**
- * Error messages
+ * Parameter new name
+ */
+#define GNUNET_REST_IDENTITY_PARAM_NEWNAME "newname"
+
+/**
+ * Error message Unknown Error
*/
#define GNUNET_REST_IDENTITY_ERROR_UNKNOWN "Unknown Error"
-#define GNUNET_REST_ERROR_RESOURCE_INVALID "Resource location invalid"
+
+/**
+ * Error message No identity found
+ */
+#define GNUNET_REST_IDENTITY_NOT_FOUND "No identity found"
+
+/**
+ * Error message Missing identity name
+ */
+#define GNUNET_REST_IDENTITY_MISSING_NAME "Missing identity name"
+
+/**
+ * Error message Missing identity name
+ */
+#define GNUNET_REST_IDENTITY_MISSING_PUBKEY "Missing identity public key"
+
+/**
+ * Error message No data
+ */
#define GNUNET_REST_ERROR_NO_DATA "No data"
+
+/**
+ * Error message Data invalid
+ */
#define GNUNET_REST_ERROR_DATA_INVALID "Data invalid"
/**
@@ -106,6 +163,9 @@ struct EgoEntry
struct GNUNET_IDENTITY_Ego *ego;
};
+/**
+ * The request handle
+ */
struct RequestHandle
{
/**
@@ -123,10 +183,6 @@ struct RequestHandle
*/
size_t data_size;
- /**
- * Requested Subsystem
- */
- char *subsystem;
/**
* Ego list
@@ -189,7 +245,7 @@ struct RequestHandle
char *emsg;
/**
- * Reponse code
+ * Response code
*/
int response_code;
@@ -213,8 +269,6 @@ cleanup_handle (void *cls)
handle->timeout_task = NULL;
}
- if (NULL != handle->subsystem)
- GNUNET_free(handle->subsystem);
if (NULL != handle->url)
GNUNET_free(handle->url);
if (NULL != handle->emsg)
@@ -315,7 +369,9 @@ get_egoentry(struct RequestHandle *handle, char* pubkey, char *name)
* @param name the id of the ego
*/
static void
-ego_get_for_subsystem (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
+ego_get_for_subsystem (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
const char *name)
{
struct RequestHandle *handle = cls;
@@ -327,7 +383,8 @@ ego_get_for_subsystem (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
if(NULL == ego)
{
- handle->emsg = GNUNET_strdup("No identity found for subsystem");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -337,8 +394,12 @@ ego_get_for_subsystem (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
// create json with subsystem identity
json_root = json_object ();
- json_object_set_new (json_root, GNUNET_REST_PARAM_PUBKEY, json_string(public_key_string));
- json_object_set_new (json_root, GNUNET_REST_PARAM_NAME, json_string(name));
+ json_object_set_new (json_root,
+ GNUNET_REST_IDENTITY_PARAM_PUBKEY,
+ json_string(public_key_string));
+ json_object_set_new (json_root,
+ GNUNET_REST_IDENTITY_PARAM_NAME,
+ json_string(name));
result_str = json_dumps (json_root, 0);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
@@ -352,116 +413,76 @@ ego_get_for_subsystem (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
}
/**
- * Handle identity GET request
+ * Handle identity GET request for subsystem
*
* @param con_handle the connection handle
* @param url the url
* @param cls the RequestHandle
*/
void
-ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
- void *cls)
+ego_get_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
{
struct RequestHandle *handle = cls;
- struct EgoEntry *ego_entry;
- struct GNUNET_HashCode key;
- struct MHD_Response *resp;
- char *keystring;
- char *egoname;
- json_t *json_root;
- json_t *json_ego;
- char *result_str;
+ char *subsystem;
- //requested default identity of subsystem
- GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_SUBSYSTEM,
- strlen (GNUNET_REST_PARAM_SUBSYSTEM), &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (
- handle->rest_handle->url_param_map, &key))
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url))
{
- handle->subsystem = GNUNET_strdup(
- GNUNET_CONTAINER_multihashmap_get (handle->rest_handle->url_param_map,
- &key));
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n",
- handle->subsystem);
-
- handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
- handle->subsystem,
- &ego_get_for_subsystem,
- handle);
- if (NULL == handle->op)
- {
- handle->emsg = GNUNET_strdup("No identity found for subsystem");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
+ handle->emsg = GNUNET_strdup("Missing subsystem name");
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- egoname = NULL;
- keystring = NULL;
-
- //one identity requested with key
- GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_PUBKEY,
- strlen (GNUNET_REST_PARAM_PUBKEY),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (
- handle->rest_handle->url_param_map, &key))
- {
- keystring = GNUNET_CONTAINER_multihashmap_get (
- handle->rest_handle->url_param_map, &key);
+ subsystem = &handle->url[strlen (
+ GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) + 1];
+ //requested default identity of subsystem
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Looking for %s's ego\n", subsystem);
- ego_entry = get_egoentry(handle, keystring, NULL);
- if (NULL == ego_entry)
- {
- handle->emsg = GNUNET_strdup("No identity found for public key");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- egoname = ego_entry->identifier;
- }
+ handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
+ subsystem,
+ &ego_get_for_subsystem,
+ handle);
- //one identity requested with name
- if (NULL == egoname)
+ if (NULL == handle->op)
{
- GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_NAME,
- strlen (GNUNET_REST_PARAM_NAME),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (
- handle->rest_handle->url_param_map, &key))
- {
- egoname = GNUNET_CONTAINER_multihashmap_get (
- handle->rest_handle->url_param_map, &key);
- if (0 >= strlen(egoname))
- {
- handle->emsg = GNUNET_strdup("No identity found for name");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
- //LOWERCASE ego names?
- GNUNET_STRINGS_utf8_tolower(egoname, egoname);
- }
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
}
+}
+
+
+/**
+ * Handle identity GET request - responds with all identities
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ struct MHD_Response *resp;
+ json_t *json_root;
+ json_t *json_ego;
+ char *result_str;
json_root = json_array ();
//Return ego/egos
for (ego_entry = handle->ego_head;
NULL != ego_entry; ego_entry = ego_entry->next)
{
- //if only one ego requested
- if ((NULL != egoname)){
- if(0 != strcmp (egoname, ego_entry->identifier)){
- continue;
- }
- }
-
json_ego = json_object ();
json_object_set_new (json_ego,
- GNUNET_REST_PARAM_PUBKEY,
+ GNUNET_REST_IDENTITY_PARAM_PUBKEY,
json_string (ego_entry->keystring));
json_object_set_new (json_ego,
- GNUNET_REST_PARAM_NAME,
+ GNUNET_REST_IDENTITY_PARAM_NAME,
json_string (ego_entry->identifier));
json_array_append (json_root, json_ego);
json_decref (json_ego);
@@ -470,7 +491,8 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
if ((size_t) 0 == json_array_size (json_root))
{
json_decref (json_root);
- handle->emsg = GNUNET_strdup("No identities found!");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -487,6 +509,117 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
/**
+ * Responds with the ego_entry identity
+ *
+ * @param handle the struct RequestHandle
+ * @param ego_entry the struct EgoEntry for the response
+ */
+void
+ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry)
+{
+ struct MHD_Response *resp;
+ json_t *json_ego;
+ char *result_str;
+
+ json_ego = json_object ();
+ json_object_set_new (json_ego,
+ GNUNET_REST_IDENTITY_PARAM_PUBKEY,
+ json_string (ego_entry->keystring));
+ json_object_set_new (json_ego,
+ GNUNET_REST_IDENTITY_PARAM_NAME,
+ json_string (ego_entry->identifier));
+
+ result_str = json_dumps (json_ego, 0);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
+ resp = GNUNET_REST_create_response (result_str);
+ handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
+
+ json_decref (json_ego);
+ GNUNET_free(result_str);
+ GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+}
+
+
+/**
+ * Handle identity GET request with a public key
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ char *keystring;
+
+ keystring = NULL;
+
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY)+1];
+ ego_entry = get_egoentry(handle, keystring, NULL);
+
+ if (NULL == ego_entry)
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
+ ego_get_response(handle, ego_entry);
+}
+
+/**
+ * Handle identity GET request with a name
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ char *egoname;
+
+ egoname = NULL;
+
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME)+1];
+ ego_entry = get_egoentry(handle, NULL, egoname);
+
+ if (NULL == ego_entry)
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
+ ego_get_response(handle, ego_entry);
+}
+
+
+/**
* Processing finished
*
* @param cls request handle
@@ -505,6 +638,10 @@ do_finished (void *cls, const char *emsg)
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
+ if (0 == handle->response_code)
+ {
+ handle->response_code = MHD_HTTP_NO_CONTENT;
+ }
resp = GNUNET_REST_create_response (NULL);
handle->proc (handle->proc_cls, resp, handle->response_code);
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
@@ -512,29 +649,21 @@ do_finished (void *cls, const char *emsg)
/**
- * Handle identity PUT request
+ * Processing edit ego with EgoEntry ego_entry
*
- * @param con_handle the connection handle
- * @param url the url
- * @param cls the RequestHandle
+ * @param handle the struct RequestHandle
+ * @param ego_entry the struct EgoEntry we want to edit
*/
void
-ego_edit (struct GNUNET_REST_RequestHandle *con_handle,
- const char* url,
- void *cls)
+ego_edit (struct RequestHandle *handle, struct EgoEntry *ego_entry)
{
- struct RequestHandle *handle = cls;
- struct EgoEntry *ego_entry;
struct EgoEntry *ego_entry_tmp;
struct MHD_Response *resp;
- int json_state;
json_t *data_js;
json_error_t err;
- char *pubkey;
- char *name;
- char *newsubsys;
char *newname;
char term_data[handle->data_size + 1];
+ int json_state;
//if no data
if (0 >= handle->data_size)
@@ -555,127 +684,252 @@ ego_edit (struct GNUNET_REST_RequestHandle *con_handle,
return;
}
- ego_entry = NULL;
- pubkey = NULL;
- name = NULL;
newname = NULL;
//NEW NAME
json_state = 0;
json_state = json_unpack(data_js,
- "{s:s,s?:s,s?:s}",
- GNUNET_REST_PARAM_NEWNAME,
- &newname,
- GNUNET_REST_PARAM_PUBKEY,
- &pubkey,
- GNUNET_REST_PARAM_NAME,
- &name);
+ "{s:s!}",
+ GNUNET_REST_IDENTITY_PARAM_NEWNAME,
+ &newname);
//Change name with pubkey or name identifier
- if (0 == json_state)
+ if (0 != json_state)
{
- if (NULL == newname)
- {
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
- if (0 >= strlen(newname))
- {
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
- //lower case name
- GNUNET_STRINGS_utf8_tolower(newname,newname);
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ json_decref (data_js);
+ return;
+ }
- ego_entry = get_egoentry(handle,pubkey,name);
+ if (NULL == newname)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ json_decref (data_js);
+ return;
+ }
- if (NULL == ego_entry)
- {
- resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
- json_decref (data_js);
- return;
- }
+ if (0 >= strlen (newname))
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ json_decref (data_js);
+ return;
+ }
- for (ego_entry_tmp = handle->ego_head;
- NULL != ego_entry_tmp; ego_entry_tmp = ego_entry_tmp->next)
- {
- if (0 == strcasecmp (newname, ego_entry_tmp->identifier))
- {
- //Ego with same name not allowed
- resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
- json_decref (data_js);
- return;
- }
- }
- handle->response_code = MHD_HTTP_NO_CONTENT;
- handle->op = GNUNET_IDENTITY_rename (handle->identity_handle,
- ego_entry->identifier, newname,
- &do_finished, handle);
+ ego_entry_tmp = get_egoentry (handle, NULL, newname);
+ if (NULL != ego_entry_tmp)
+ {
+ //Ego with same name not allowed (even if its the ego we change)
+ resp = GNUNET_REST_create_response (NULL);
+ handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
+ GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ json_decref (data_js);
+ return;
+ }
+ handle->op = GNUNET_IDENTITY_rename (handle->identity_handle,
+ ego_entry->identifier,
+ newname,
+ &do_finished,
+ handle);
+ if (NULL == handle->op)
+ {
+ handle->emsg = GNUNET_strdup("Rename failed");
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
+ json_decref (data_js);
+ return;
+
+}
+
+
+/**
+ * Handle identity PUT request with public key
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_edit_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ char *keystring;
+
+ keystring = NULL;
+
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY)+1];
+ ego_entry = get_egoentry(handle, keystring, NULL);
+
+ if (NULL == ego_entry)
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
+ ego_edit(handle,ego_entry);
+}
+
+/**
+ * Handle identity PUT request with name
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_edit_name (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ char *name;
+
+ name = NULL;
+
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME)+1];
+ ego_entry = get_egoentry(handle, NULL, name);
+
+ if (NULL == ego_entry)
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
+ ego_edit(handle,ego_entry);
+}
+
+/**
+ * Handle identity subsystem PUT request with name
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_edit_subsystem (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ json_t *data_js;
+ json_error_t err;
+ char *newsubsys;
+ char *name;
+ char term_data[handle->data_size + 1];
+ int json_state;
+
+ name = NULL;
+
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM) >= strlen (handle->url))
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM)+1];
+ ego_entry = get_egoentry(handle, NULL, name);
+
+ if (NULL == ego_entry)
+ {
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+
+ //if no data
+ if (0 >= handle->data_size)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ //if not json
+ term_data[handle->data_size] = '\0';
+ GNUNET_memcpy(term_data, handle->data, handle->data_size);
+ data_js = json_loads (term_data,JSON_DECODE_ANY,&err);
+
+ if (NULL == data_js)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_NO_DATA);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
newsubsys = NULL;
//SUBSYSTEM
json_state = 0;
json_state = json_unpack(data_js,
- "{s:s,s?:s,s?:s}",
- GNUNET_REST_PARAM_SUBSYSTEM,
- &newsubsys,
- GNUNET_REST_PARAM_PUBKEY,
- &pubkey,
- GNUNET_REST_PARAM_NAME,
- &name);
+ "{s:s!}",
+ GNUNET_REST_IDENTITY_PARAM_SUBSYSTEM,
+ &newsubsys);
//Change subsystem with pubkey or name identifier
- if (0 == json_state)
+ if (0 != json_state)
{
- if (NULL == newsubsys || (NULL == pubkey && NULL == name))
- {
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
-
- if (0 >= strlen(newsubsys))
- {
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
-
- ego_entry = get_egoentry(handle, pubkey, name);
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ json_decref (data_js);
+ return;
+ }
- if (NULL == ego_entry)
- {
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- json_decref (data_js);
- return;
- }
+ if (NULL == newsubsys)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ json_decref (data_js);
+ return;
+ }
- handle->response_code = MHD_HTTP_NO_CONTENT;
- handle->op = GNUNET_IDENTITY_set (handle->identity_handle,
- newsubsys,
- ego_entry->ego,
- &do_finished,
- handle);
+ if (0 >= strlen (newsubsys))
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ handle->response_code = MHD_HTTP_NO_CONTENT;
+ handle->op = GNUNET_IDENTITY_set (handle->identity_handle,
+ newsubsys,
+ ego_entry->ego,
+ &do_finished,
+ handle);
+ if (NULL == handle->op)
+ {
+ handle->emsg = GNUNET_strdup("Setting subsystem failed");
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
json_decref (data_js);
return;
+
}
/**
@@ -686,7 +940,8 @@ ego_edit (struct GNUNET_REST_RequestHandle *con_handle,
* @param cls the RequestHandle
*/
void
-ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
+ego_create (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
void *cls)
{
struct RequestHandle *handle = cls;
@@ -700,7 +955,6 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
if (strlen (GNUNET_REST_API_NS_IDENTITY) != strlen (handle->url))
{
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_RESOURCE_INVALID);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -726,7 +980,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
json_unpack_state = 0;
json_unpack_state = json_unpack(data_js,
"{s:s!}",
- GNUNET_REST_PARAM_NAME,
+ GNUNET_REST_IDENTITY_PARAM_NAME,
&egoname);
if (0 != json_unpack_state)
{
@@ -738,7 +992,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
if (NULL == egoname)
{
- handle->emsg = GNUNET_strdup("No name provided");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
@@ -746,7 +1000,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
if (0 >= strlen (egoname))
{
json_decref (data_js);
- handle->emsg = GNUNET_strdup("No name provided");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_DATA_INVALID);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -771,93 +1025,93 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
}
/**
- * Handle identity DELETE request
+ * Handle identity DELETE request with public key
*
* @param con_handle the connection handle
* @param url the url
* @param cls the RequestHandle
*/
void
-ego_delete (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
- void *cls)
+ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
{
struct RequestHandle *handle = cls;
struct EgoEntry *ego_entry;
- struct GNUNET_HashCode key;
- struct MHD_Response *resp;
- const char *keystring;
- char *egoname;
- int ego_exists = GNUNET_NO;
+ char *keystring;
keystring = NULL;
- egoname = NULL;
- //delete with pubkey
- GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_PUBKEY,
- strlen (GNUNET_REST_PARAM_PUBKEY), &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (
- handle->rest_handle->url_param_map, &key))
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
{
- keystring = GNUNET_CONTAINER_multihashmap_get (
- handle->rest_handle->url_param_map,&key);
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
}
+ keystring = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY)+1];
+ ego_entry = get_egoentry(handle, keystring, NULL);
- GNUNET_CRYPTO_hash (GNUNET_REST_PARAM_NAME,
- strlen (GNUNET_REST_PARAM_NAME), &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (
- handle->rest_handle->url_param_map, &key))
+ if (NULL == ego_entry)
{
- egoname = GNUNET_CONTAINER_multihashmap_get (
- handle->rest_handle->url_param_map, &key);
- //LOWERCASE ego names?
- //GNUNET_STRINGS_utf8_tolower(egoname, egoname);
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
}
- if (NULL != keystring)
- {
- for (ego_entry = handle->ego_head;
- NULL != ego_entry; ego_entry = ego_entry->next)
- {
- if (0 != strcasecmp (keystring, ego_entry->keystring))
- continue;
- ego_exists = GNUNET_YES;
- break;
- }
- }
- else if (NULL != egoname)
- {
- for (ego_entry = handle->ego_head;
- NULL != ego_entry; ego_entry = ego_entry->next)
- {
- if (0 != strcmp (egoname, ego_entry->identifier))
- continue;
- ego_exists = GNUNET_YES;
- break;
- }
- }
- else
+ handle->response_code = MHD_HTTP_NO_CONTENT;
+ handle->op = GNUNET_IDENTITY_delete (handle->identity_handle,
+ ego_entry->identifier,
+ &do_finished,
+ handle);
+}
+
+
+/**
+ * Handle identity DELETE request with name
+ *
+ * @param con_handle the connection handle
+ * @param url the url
+ * @param cls the RequestHandle
+ */
+void
+ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct RequestHandle *handle = cls;
+ struct EgoEntry *ego_entry;
+ char *name;
+
+ name = NULL;
+
+ if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
{
- handle->emsg = GNUNET_strdup("Missing parameter pubkey or name");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
+ name = &handle->url[strlen (GNUNET_REST_API_NS_IDENTITY_NAME)+1];
+ ego_entry = get_egoentry(handle, NULL, name);
- if (GNUNET_NO == ego_exists)
+ if (NULL == ego_entry)
{
- resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
+
handle->response_code = MHD_HTTP_NO_CONTENT;
handle->op = GNUNET_IDENTITY_delete (handle->identity_handle,
- ego_entry->identifier, &do_finished,
+ ego_entry->identifier,
+ &do_finished,
handle);
-
}
+
/**
* Respond to OPTIONS request
*
@@ -890,10 +1144,16 @@ init_cont (struct RequestHandle *handle)
{
struct GNUNET_REST_RequestHandlerError err;
static const struct GNUNET_REST_RequestHandler handlers[] = {
- { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY, &ego_get },
- { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit },
+ { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_ALL, &ego_get_all },
+ { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_get_pubkey },
+ { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_get_name },
+ { MHD_HTTP_METHOD_GET, GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, &ego_get_subsystem },
+ { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_edit_pubkey },
+ { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_edit_name },
+ { MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY_SUBSYSTEM, &ego_edit_subsystem },
{ MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create },
- { MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY, &ego_delete },
+ { MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY_PUBKEY, &ego_delete_pubkey },
+ { MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY_NAME, &ego_delete_name },
{ MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont },
GNUNET_REST_HANDLER_END
};
diff --git a/src/namestore/plugin_rest_namestore.c b/src/rest-plugins/plugin_rest_namestore.c
index f14707cce..2926f4b90 100644
--- a/src/namestore/plugin_rest_namestore.c
+++ b/src/rest-plugins/plugin_rest_namestore.c
@@ -32,22 +32,40 @@
#include "microhttpd.h"
#include <jansson.h>
-
+/**
+ * Namestore Namespace
+ */
#define GNUNET_REST_API_NS_NAMESTORE "/namestore"
-#define GNUNET_REST_SUBSYSTEM_NAMESTORE "namestore"
/**
- * Parameter names
+ * Error message Unknown Error
*/
-#define GNUNET_REST_API_PARAM_PUBKEY "pubkey"
-#define GNUNET_REST_API_PARAM_NAME "name"
+#define GNUNET_REST_NAMESTORE_ERROR_UNKNOWN "Unknown Error"
/**
- * Error messages
+ * Error message No identity found
*/
-#define GNUNET_REST_NAMESTORE_ERROR_UNKNOWN "Unknown Error"
+#define GNUNET_REST_IDENTITY_NOT_FOUND "No identity found"
+
+/**
+ * Error message No default zone specified
+ */
+#define GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE "No default zone specified"
-#define GNUNET_REST_NAMESTORE_RD_COUNT 1
+/**
+ * Error message Failed request
+ */
+#define GNUNET_REST_NAMESTORE_FAILED "Namestore action failed"
+
+/**
+ * Error message invalid data
+ */
+#define GNUNET_REST_NAMESTORE_INVALID_DATA "Data invalid"
+
+/**
+ * Error message No data
+ */
+#define GNUNET_REST_NAMESTORE_NO_DATA "No data"
/**
* State while collecting all egos
@@ -107,13 +125,15 @@ struct EgoEntry
struct GNUNET_IDENTITY_Ego *ego;
};
-
+/**
+ * The request handle
+ */
struct RequestHandle
{
/**
* Records to store
*/
- char *label_name;
+ char *record_name;
/**
* Records to store
@@ -211,7 +231,7 @@ struct RequestHandle
char *emsg;
/**
- * Reponse code
+ * Response code
*/
int response_code;
@@ -235,8 +255,8 @@ cleanup_handle (void *cls)
GNUNET_SCHEDULER_cancel (handle->timeout_task);
handle->timeout_task = NULL;
}
- if (NULL != handle->label_name)
- GNUNET_free(handle->label_name);
+ if (NULL != handle->record_name)
+ GNUNET_free(handle->record_name);
if (NULL != handle->url)
GNUNET_free(handle->url);
if (NULL != handle->emsg)
@@ -318,20 +338,9 @@ do_error (void *cls)
* @return EgoEntry or NULL if not found
*/
struct EgoEntry*
-get_egoentry(struct RequestHandle *handle, char* pubkey, char *name)
+get_egoentry_namestore(struct RequestHandle *handle, char *name)
{
struct EgoEntry *ego_entry;
- if (NULL != pubkey)
- {
- for (ego_entry = handle->ego_head;
- NULL != ego_entry;
- ego_entry = ego_entry->next)
- {
- if (0 != strcasecmp (pubkey, ego_entry->keystring))
- continue;
- return ego_entry;
- }
- }
if (NULL != name)
{
for (ego_entry = handle->ego_head;
@@ -349,17 +358,26 @@ get_egoentry(struct RequestHandle *handle, char* pubkey, char *name)
/**
* Does internal server error when iteration failed.
+ *
+ * @param cls the `struct RequestHandle`
*/
static void
namestore_iteration_error (void *cls)
{
struct RequestHandle *handle = cls;
- struct MHD_Response *resp = GNUNET_REST_create_response (NULL);
- handle->proc (handle->proc_cls, resp, MHD_HTTP_INTERNAL_SERVER_ERROR);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
}
+/**
+ * Create finished callback
+ *
+ * @param cls the `struct RequestHandle`
+ * @param success the success indicating integer, GNUNET_OK on success
+ * @param emsg the error message (can be NULL)
+ */
static void
create_finished (void *cls, int32_t success, const char *emsg)
{
@@ -369,6 +387,12 @@ create_finished (void *cls, int32_t success, const char *emsg)
handle->add_qe = NULL;
if (GNUNET_YES != success)
{
+ if (NULL != emsg)
+ {
+ handle->emsg = GNUNET_strdup(emsg);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
handle->emsg = GNUNET_strdup("Error storing records");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
@@ -379,6 +403,13 @@ create_finished (void *cls, int32_t success, const char *emsg)
}
+/**
+ * Delete finished callback
+ *
+ * @param cls the `struct RequestHandle`
+ * @param success the success indicating integer, GNUNET_OK on success
+ * @param emsg the error message (can be NULL)
+ */
static void
del_finished (void *cls, int32_t success, const char *emsg)
{
@@ -387,12 +418,19 @@ del_finished (void *cls, int32_t success, const char *emsg)
handle->add_qe = NULL;
if (GNUNET_NO == success)
{
- handle->emsg = GNUNET_strdup("Deleting record failed. Record does not exist");
+ handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup("No record found");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
if (GNUNET_SYSERR == success)
{
+ if (NULL != emsg)
+ {
+ handle->emsg = GNUNET_strdup(emsg);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
handle->emsg = GNUNET_strdup("Deleting record failed");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
@@ -420,10 +458,7 @@ namestore_list_finished (void *cls)
handle->list_it = NULL;
if (NULL == handle->resp_object)
- {
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
+ handle->resp_object = json_array();
result_str = json_dumps (handle->resp_object, 0);
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
@@ -452,17 +487,6 @@ namestore_list_iteration (void *cls,
if (NULL == handle->resp_object)
handle->resp_object = json_array();
- /*if ( (NULL != handle->ego_entry->identifier) &&
- (0 != strcmp (handle->ego_entry->identifier,
- rname)) )
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "%s does not match %s\n", rname,
- handle->ego_entry->identifier);
- GNUNET_NAMESTORE_zone_iterator_next (handle->list_it, 1);
- return;
- }*/
-
for (unsigned int i = 0; i < rd_len; i++)
{
if ( (GNUNET_GNSRECORD_TYPE_NICK == rd[i].record_type) &&
@@ -481,6 +505,48 @@ namestore_list_iteration (void *cls,
GNUNET_NAMESTORE_zone_iterator_next (handle->list_it, 1);
}
+/**
+ * @param cls closure
+ * @param ego ego handle
+ * @param ctx context for application to store data for this ego
+ * (during the lifetime of this process, initially NULL)
+ * @param identifier identifier assigned by the user for this ego,
+ * NULL if the user just deleted the ego and it
+ * must thus no longer be used
+ */
+static void
+default_ego_get (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
+{
+ struct RequestHandle *handle = cls;
+ handle->op = NULL;
+
+ if (ego == NULL)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+ handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
+
+ handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
+ handle->zone_pkey,
+ &namestore_iteration_error,
+ handle,
+ &namestore_list_iteration,
+ handle,
+ &namestore_list_finished,
+ handle);
+ if (NULL == handle->list_it)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
+}
+
/**
* Handle namestore GET request
@@ -495,40 +561,22 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
void *cls)
{
struct RequestHandle *handle = cls;
- struct EgoEntry *ego_entry = NULL;
- struct GNUNET_HashCode key;
- char *pubkey = NULL;
- char *name = NULL;
-
- //change zone if pubkey or name specified
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_PUBKEY,
- strlen (GNUNET_REST_API_PARAM_PUBKEY),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
- {
- pubkey = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,
- &key);
- }
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_NAME,
- strlen (GNUNET_REST_API_PARAM_NAME),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
- {
- name = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,
- &key);
- }
+ struct EgoEntry *ego_entry;
+ char *egoname;
+
+ egoname = NULL;
+ ego_entry = NULL;
- ego_entry = get_egoentry(handle,pubkey,name);
- if (NULL == ego_entry)
+ //set zone to name if given
+ if (strlen (GNUNET_REST_API_NS_NAMESTORE) < strlen (handle->url))
{
- if (NULL != pubkey || NULL != name)
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE)+1];
+ ego_entry = get_egoentry_namestore(handle, egoname);
+
+ if (NULL == ego_entry)
{
- handle->emsg = GNUNET_strdup("Invalid identity");
handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -537,6 +585,15 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
{
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
}
+
+ if (NULL == handle->zone_pkey)
+ {
+ handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
+ "namestore",
+ &default_ego_get,
+ handle);
+ return;
+ }
handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle,
handle->zone_pkey,
&namestore_iteration_error,
@@ -545,53 +602,57 @@ namestore_get (struct GNUNET_REST_RequestHandle *con_handle,
handle,
&namestore_list_finished,
handle);
+ if (NULL == handle->list_it)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
}
/**
- * We're storing a new record; this requires
- * that no record already exists
- *
- * @param cls closure, unused
- * @param zone_key private key of the zone
- * @param rec_name name that is being mapped (at most 255 characters long)
- * @param rd_count number of entries in @a rd array
- * @param rd array of records with data to store
+ * @param cls closure
+ * @param ego ego handle
+ * @param ctx context for application to store data for this ego
+ * (during the lifetime of this process, initially NULL)
+ * @param identifier identifier assigned by the user for this ego,
+ * NULL if the user just deleted the ego and it
+ * must thus no longer be used
*/
static void
-create_new_record_cont (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone_key,
- const char *rec_name,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
+default_ego_post (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
struct RequestHandle *handle = cls;
+ handle->op = NULL;
- handle->add_qe = NULL;
- if (0 != strcmp (rec_name, handle->label_name))
+ if (ego == NULL)
{
- GNUNET_break (0);
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
+ handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
- if (0 != rd_count)
+ handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
+ handle->zone_pkey,
+ handle->record_name,
+ 1,
+ handle->rd,
+ &create_finished,
+ handle);
+ if (NULL == handle->add_qe)
{
- handle->proc (handle->proc_cls,
- GNUNET_REST_create_response (NULL),
- MHD_HTTP_CONFLICT);
- GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
- handle->zone_pkey,
- handle->label_name,
- GNUNET_REST_NAMESTORE_RD_COUNT,
- handle->rd,
- &create_finished,
- handle);
}
+
/**
* Handle namestore POST request
*
@@ -606,30 +667,21 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle,
{
struct RequestHandle *handle = cls;
struct GNUNET_GNSRECORD_Data *gns_record;
+ struct EgoEntry *ego_entry;
+ char *egoname;
json_t *data_js;
json_t *name_json;
json_error_t err;
-
- struct EgoEntry *ego_entry = NULL;
- struct GNUNET_HashCode key;
- char *pubkey = NULL;
- char *name = NULL;
-
char term_data[handle->rest_handle->data_size + 1];
+
struct GNUNET_JSON_Specification gnsspec[] = {
GNUNET_JSON_spec_gnsrecord_data(&gns_record),
GNUNET_JSON_spec_end ()
};
- if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url))
- {
- handle->emsg = GNUNET_strdup("Wrong URL");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
- return;
- }
if (0 >= handle->rest_handle->data_size)
{
- handle->emsg = GNUNET_strdup("No data");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -639,7 +691,7 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle,
data_js = json_loads (term_data, JSON_DECODE_ANY, &err);
if (GNUNET_OK != GNUNET_JSON_parse (data_js, gnsspec, NULL, NULL))
{
- handle->emsg = GNUNET_strdup("Invalid data");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
GNUNET_JSON_parse_free(gnsspec);
json_decref (data_js);
@@ -647,109 +699,118 @@ namestore_add (struct GNUNET_REST_RequestHandle *con_handle,
}
handle->rd = gns_record;
- name_json = json_object_get(data_js, "label");
+ name_json = json_object_get(data_js, "record_name");
if (!json_is_string(name_json))
{
- handle->emsg = GNUNET_strdup("Missing name");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
- handle->label_name = GNUNET_strdup(json_string_value(name_json));
- if(NULL == handle->label_name)
+ handle->record_name = GNUNET_strdup(json_string_value(name_json));
+ if(NULL == handle->record_name)
{
- handle->emsg = GNUNET_strdup("Missing name");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
- if (0 >= strlen(handle->label_name))
+ if (0 >= strlen(handle->record_name))
{
- handle->emsg = GNUNET_strdup("Missing name");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
json_decref (data_js);
return;
}
json_decref (data_js);
- //change zone if pubkey or name specified
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_PUBKEY,
- strlen (GNUNET_REST_API_PARAM_PUBKEY),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
- {
- pubkey = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,
- &key);
- }
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_NAME,
- strlen (GNUNET_REST_API_PARAM_NAME),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
- {
- name = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,
- &key);
- }
+ egoname = NULL;
+ ego_entry = NULL;
- ego_entry = get_egoentry(handle,pubkey,name);
- if (NULL == ego_entry)
+ //set zone to name if given
+ if (strlen (GNUNET_REST_API_NS_NAMESTORE) < strlen (handle->url))
{
- if (NULL != pubkey || NULL != name)
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE)+1];
+ ego_entry = get_egoentry_namestore(handle, egoname);
+
+ if (NULL == ego_entry)
{
- handle->emsg = GNUNET_strdup("Invalid identity");
handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
}
- if ( NULL != ego_entry )
+ if (NULL != ego_entry)
{
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
}
if (NULL == handle->zone_pkey)
{
- handle->emsg = GNUNET_strdup("No default identity for namestore");
+ handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
+ "namestore",
+ &default_ego_post,
+ handle);
+ return;
+ }
+ handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
+ handle->zone_pkey,
+ handle->record_name,
+ 1,
+ handle->rd,
+ &create_finished,
+ handle);
+ if (NULL == handle->add_qe)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
- handle->zone_pkey,
- handle->label_name,
- &do_error,
- handle,
- &create_new_record_cont,
- handle);
}
+/**
+ * @param cls closure
+ * @param ego ego handle
+ * @param ctx context for application to store data for this ego
+ * (during the lifetime of this process, initially NULL)
+ * @param identifier identifier assigned by the user for this ego,
+ * NULL if the user just deleted the ego and it
+ * must thus no longer be used
+ */
static void
-del_cont (void *cls,
- const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
- const char *label,
- unsigned int rd_count,
- const struct GNUNET_GNSRECORD_Data *rd)
+default_ego_delete (void *cls,
+ struct GNUNET_IDENTITY_Ego *ego,
+ void **ctx,
+ const char *identifier)
{
struct RequestHandle *handle = cls;
+ handle->op = NULL;
- handle->add_qe = NULL;
- if (0 == rd_count)
+ if (ego == NULL)
{
- handle->emsg = GNUNET_strdup("Record not found");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_NO_DEFAULT_ZONE);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
+ handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
handle->zone_pkey,
- handle->label_name,
- 0, NULL,
+ handle->record_name,
+ 0,
+ NULL,
&del_finished,
handle);
+ if (NULL == handle->add_qe)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
}
+
/**
* Handle namestore DELETE request
*
@@ -764,39 +825,22 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
{
struct RequestHandle *handle = cls;
struct GNUNET_HashCode key;
- struct EgoEntry *ego_entry = NULL;
- char *pubkey = NULL;
- char *name = NULL;
-
- //change zone if pubkey or name specified
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_PUBKEY,
- strlen (GNUNET_REST_API_PARAM_PUBKEY),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
- {
- pubkey = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,
- &key);
- }
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PARAM_NAME,
- strlen (GNUNET_REST_API_PARAM_NAME),
- &key);
- if ( GNUNET_YES
- == GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
- &key))
- {
- name = GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map,
- &key);
- }
+ struct EgoEntry *ego_entry;
+ char *egoname;
+
+ egoname = NULL;
+ ego_entry = NULL;
- ego_entry = get_egoentry(handle,pubkey,name);
- if (NULL == ego_entry)
+ //set zone to name if given
+ if (strlen (GNUNET_REST_API_NS_NAMESTORE) < strlen (handle->url))
{
- if (NULL != pubkey || NULL != name)
+ egoname = &handle->url[strlen (GNUNET_REST_API_NS_NAMESTORE)+1];
+ ego_entry = get_egoentry_namestore(handle, egoname);
+
+ if (NULL == ego_entry)
{
- handle->emsg = GNUNET_strdup("Invalid identity");
handle->response_code = MHD_HTTP_NOT_FOUND;
+ handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
@@ -806,33 +850,40 @@ namestore_delete (struct GNUNET_REST_RequestHandle *con_handle,
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key(ego_entry->ego);
}
- GNUNET_CRYPTO_hash ("label", strlen ("label"), &key);
+ GNUNET_CRYPTO_hash ("record_name", strlen ("record_name"), &key);
if ( GNUNET_NO
== GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
&key))
{
- handle->emsg = GNUNET_strdup("Missing name");
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_INVALID_DATA);
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
}
- handle->label_name = GNUNET_strdup(
+ handle->record_name = GNUNET_strdup(
GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key));
if (NULL == handle->zone_pkey)
{
- handle->emsg = GNUNET_strdup("No default identity for namestore");
- GNUNET_SCHEDULER_add_now (&do_error, handle);
+ handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
+ "namestore",
+ &default_ego_delete,
+ handle);
return;
}
- handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle,
- handle->zone_pkey,
- handle->label_name,
- &do_error,
- handle,
- &del_cont,
- handle);
-
+ handle->add_qe = GNUNET_NAMESTORE_records_store (handle->ns_handle,
+ handle->zone_pkey,
+ handle->record_name,
+ 0,
+ NULL,
+ &del_finished,
+ handle);
+ if (NULL == handle->add_qe)
+ {
+ handle->emsg = GNUNET_strdup(GNUNET_REST_NAMESTORE_FAILED);
+ GNUNET_SCHEDULER_add_now (&do_error, handle);
+ return;
+ }
}
@@ -890,35 +941,39 @@ init_cont (struct RequestHandle *handle)
}
}
+
/**
+ * This function is initially called for all egos and then again
+ * whenever a ego's identifier changes or if it is deleted. At the
+ * end of the initial pass over all egos, the function is once called
+ * with 'NULL' for 'ego'. That does NOT mean that the callback won't
+ * be invoked in the future or that there was an error.
+ *
+ * When used with 'GNUNET_IDENTITY_create' or 'GNUNET_IDENTITY_get',
+ * this function is only called ONCE, and 'NULL' being passed in
+ * 'ego' does indicate an error (i.e. name is taken or no default
+ * value is known). If 'ego' is non-NULL and if '*ctx'
+ * is set in those callbacks, the value WILL be passed to a subsequent
+ * call to the identity callback of 'GNUNET_IDENTITY_connect' (if
+ * that one was not NULL).
+ *
+ * When an identity is renamed, this function is called with the
+ * (known) ego but the NEW identifier.
+ *
+ * When an identity is deleted, this function is called with the
+ * (known) ego and "NULL" for the 'identifier'. In this case,
+ * the 'ego' is henceforth invalid (and the 'ctx' should also be
+ * cleaned up).
+ *
* @param cls closure
* @param ego ego handle
* @param ctx context for application to store data for this ego
* (during the lifetime of this process, initially NULL)
- * @param identifier identifier assigned by the user for this ego,
+ * @param name identifier assigned by the user for this ego,
* NULL if the user just deleted the ego and it
* must thus no longer be used
*/
static void
-default_ego_cb (void *cls,
- struct GNUNET_IDENTITY_Ego *ego,
- void **ctx,
- const char *identifier)
-{
- struct RequestHandle *handle = cls;
- handle->op = NULL;
-
- if (ego != NULL)
- {
- handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego);
- }
-}
-
-
-/**
- * Connect to identity callback
- */
-static void
id_connect_cb (void *cls,
struct GNUNET_IDENTITY_Ego *ego,
void **ctx,
@@ -928,17 +983,10 @@ id_connect_cb (void *cls,
struct EgoEntry *ego_entry;
struct GNUNET_CRYPTO_EcdsaPublicKey pk;
- if ((NULL == ego) && (NULL == handle->zone_pkey))
- {
- handle->op = GNUNET_IDENTITY_get (handle->identity_handle,
- GNUNET_REST_SUBSYSTEM_NAMESTORE,
- &default_ego_cb,
- handle);
- }
if ((NULL == ego) && (ID_REST_STATE_INIT == handle->state))
{
handle->state = ID_REST_STATE_POST_INIT;
- init_cont (handle);
+ init_cont(handle);
return;
}
if (ID_REST_STATE_INIT == handle->state)
@@ -985,8 +1033,8 @@ rest_process_request(struct GNUNET_REST_RequestHandle *rest_handle,
handle->url[strlen (handle->url)-1] = '\0';
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connecting...\n");
- handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, handle);
handle->ns_handle = GNUNET_NAMESTORE_connect (cfg);
+ handle->identity_handle = GNUNET_IDENTITY_connect (cfg, &id_connect_cb, handle);
handle->timeout_task =
GNUNET_SCHEDULER_add_delayed (handle->timeout,
&do_error,
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/rest-plugins/plugin_rest_openid_connect.c
index 24673c692..24673c692 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/rest-plugins/plugin_rest_openid_connect.c
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/rest-plugins/plugin_rest_peerinfo.c
index 97c473e36..29b40088d 100644
--- a/src/peerinfo-tool/plugin_rest_peerinfo.c
+++ b/src/rest-plugins/plugin_rest_peerinfo.c
@@ -31,13 +31,30 @@
#include "microhttpd.h"
#include <jansson.h>
+/**
+ * Peerinfo Namespace
+ */
#define GNUNET_REST_API_NS_PEERINFO "/peerinfo"
-#define GNUNET_REST_API_PEERINFO_PEER "peer"
-#define GNUNET_REST_API_PEERINFO_FRIEND "friend"
-#define GNUNET_REST_API_PEERINFO_ARRAY "array"
+/**
+ * Peerinfo parameter peer
+ */
+#define GNUNET_REST_PEERINFO_PEER "peer"
-#define GNUNET_REST_ERROR_UNKNOWN "Unkown Error"
+/**
+ * Peerinfo parameter friend
+ */
+#define GNUNET_REST_PEERINFO_FRIEND "friend"
+
+/**
+ * Peerinfo parameter array
+ */
+#define GNUNET_REST_PEERINFO_ARRAY "array"
+
+/**
+ * Error message Unknown Error
+ */
+#define GNUNET_REST_PEERINFO_ERROR_UNKNOWN "Unknown Error"
/**
* How long until we time out during address lookup?
@@ -94,7 +111,6 @@ struct AddressRecord
*/
struct PrintContext
{
-
/**
* Kept in DLL.
*/
@@ -152,6 +168,9 @@ static struct PrintContext *pc_head;
*/
static struct PrintContext *pc_tail;
+/**
+ * The request handle
+ */
struct RequestHandle
{
/**
@@ -299,7 +318,7 @@ do_error (void *cls)
char *response;
if (NULL == handle->emsg)
- handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_UNKNOWN);
+ handle->emsg = GNUNET_strdup(GNUNET_REST_PEERINFO_ERROR_UNKNOWN);
json_object_set_new(json_error,"error", json_string(handle->emsg));
@@ -315,7 +334,9 @@ do_error (void *cls)
/**
- * Function that assembles our response.
+ * Function that assembles the response.
+ *
+ * @param cls the `struct RequestHandle`
*/
static void
peerinfo_list_finished (void *cls)
@@ -326,6 +347,7 @@ peerinfo_list_finished (void *cls)
if (NULL == handle->response)
{
+ handle->response_code = MHD_HTTP_NOT_FOUND;
handle->emsg = GNUNET_strdup ("No peers found");
GNUNET_SCHEDULER_add_now (&do_error, handle);
return;
@@ -386,9 +408,6 @@ dump_pc (struct PrintContext *pc)
temp_array = json_array();
response_entry = json_object();
-// printf (_("%sPeer `%s'\n"),
-// (GNUNET_YES == pc->friend_only) ? "F2F: " : "",
-// GNUNET_i2s_full (&pc->peer));
for (i = 0; i < pc->num_addresses; i++)
{
if (NULL != pc->address_list[i].result)
@@ -417,10 +436,10 @@ dump_pc (struct PrintContext *pc)
GNUNET_i2s_full (&pc->peer));
friend_and_peer_json = json_string(friend_and_peer);
json_object_set(response_entry,
- GNUNET_REST_API_PEERINFO_PEER,
+ GNUNET_REST_PEERINFO_PEER,
friend_and_peer_json);
json_object_set(response_entry,
- GNUNET_REST_API_PEERINFO_ARRAY,
+ GNUNET_REST_PEERINFO_ARRAY,
temp_array);
json_array_append(pc->handle->response, response_entry);
json_decref(friend_and_peer_json);
@@ -610,13 +629,13 @@ peerinfo_get (struct GNUNET_REST_RequestHandle *con_handle,
struct RequestHandle *handle = cls;
struct GNUNET_HashCode key;
const struct GNUNET_PeerIdentity *specific_peer;
- GNUNET_PEER_Id peer_id;
+ //GNUNET_PEER_Id peer_id;
int include_friend_only;
char* include_friend_only_str;
include_friend_only = GNUNET_NO;
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PEERINFO_FRIEND,
- strlen (GNUNET_REST_API_PEERINFO_FRIEND),
+ GNUNET_CRYPTO_hash (GNUNET_REST_PEERINFO_FRIEND,
+ strlen (GNUNET_REST_PEERINFO_FRIEND),
&key);
if ( GNUNET_YES
== GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
@@ -631,15 +650,15 @@ peerinfo_get (struct GNUNET_REST_RequestHandle *con_handle,
}
specific_peer = NULL;
- GNUNET_CRYPTO_hash (GNUNET_REST_API_PEERINFO_PEER,
- strlen (GNUNET_REST_API_PEERINFO_PEER),
+ GNUNET_CRYPTO_hash (GNUNET_REST_PEERINFO_PEER,
+ strlen (GNUNET_REST_PEERINFO_PEER),
&key);
if ( GNUNET_YES
== GNUNET_CONTAINER_multihashmap_contains (con_handle->url_param_map,
&key))
{
- peer_id = *(unsigned int*)GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key);
- specific_peer = GNUNET_PEER_resolve2(peer_id);
+ //peer_id = *(unsigned int*)GNUNET_CONTAINER_multihashmap_get (con_handle->url_param_map, &key);
+ //specific_peer = GNUNET_PEER_resolve2(peer_id);
}
handle->list_it = GNUNET_PEERINFO_iterate(handle->peerinfo_handle,
diff --git a/src/gns/test_plugin_rest_gns.sh b/src/rest-plugins/test_plugin_rest_gns.sh
index 7ede44501..ec495a04b 100755
--- a/src/gns/test_plugin_rest_gns.sh
+++ b/src/rest-plugins/test_plugin_rest_gns.sh
@@ -19,32 +19,32 @@ curl_get () {
gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1
-curl_get "$gns_link?name=www.test_plugin_rest_gns" "error"
+curl_get "$gns_link/www.test_plugin_rest_gns" "error"
gnunet-identity -C "test_plugin_rest_gns"
-curl_get "$gns_link?name=www.test_plugin_rest_gns" "\[\]"
+curl_get "$gns_link/www.test_plugin_rest_gns" "\[\]"
gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.1 -t A
-curl_get "$gns_link?name=www.test_plugin_rest_gns" "1.1.1.1"
+curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.1"
gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1::1 -t AAAA
-curl_get "$gns_link?name=www.test_plugin_rest_gns" "1::1.*1.1.1.1"
+curl_get "$gns_link/www.test_plugin_rest_gns" "1::1.*1.1.1.1"
gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www -e 1d -V 1.1.1.2 -t A
-curl_get "$gns_link?name=www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1"
-curl_get "$gns_link?name=www.test_plugin_rest_gns&record_type=A" "1.1.1.2.*1.1.1.1"
-curl_get "$gns_link?name=www.test_plugin_rest_gns&record_type=AAAA" "1::1"
-curl_get "$gns_link?name=www.test_plugin_rest_gns&record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1"
+curl_get "$gns_link/www.test_plugin_rest_gns" "1.1.1.2.*1::1.*1.1.1.1"
+curl_get "$gns_link/www.test_plugin_rest_gns?record_type=A" "1.1.1.2.*1.1.1.1"
+curl_get "$gns_link/www.test_plugin_rest_gns?record_type=AAAA" "1::1"
+curl_get "$gns_link/www.test_plugin_rest_gns?record_type=WRONG_TYPE" "1.1.1.2.*1::1.*1.1.1.1"
gnunet-namestore -z "test_plugin_rest_gns" -p -a -n www1 -e 1d -V 1.1.1.1 -t A
-curl_get "$gns_link?name=www1.test_plugin_rest_gns" "1.1.1.1"
+curl_get "$gns_link/www1.test_plugin_rest_gns" "1.1.1.1"
-gnunet-identity -D "test_plugin_rest_gns"
+gnunet-identity -D "test_plugin_rest_gns" > /dev/null 2>&1
-curl_get "$gns_link?name=www1.test_plugin_rest_gns" "error"
+curl_get "$gns_link/www1.test_plugin_rest_gns" "error"
exit 0
diff --git a/src/rest-plugins/test_plugin_rest_identity.sh b/src/rest-plugins/test_plugin_rest_identity.sh
new file mode 100755
index 000000000..a5879dd7e
--- /dev/null
+++ b/src/rest-plugins/test_plugin_rest_identity.sh
@@ -0,0 +1,157 @@
+#!/usr/bin/bash
+
+#First, start gnunet-arm and the rest-service.
+#Exit 0 means success, exit 1 means failed test
+
+identity_link="http://localhost:7776/identity"
+wrong_link="http://localhost:7776/identityandmore"
+
+
+curl_get () {
+ #$1 is link
+ #$2 is grep
+ cache="$(curl -v "$1" 2>&1 | grep "$2")"
+ #echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+curl_post () {
+ #$1 is link
+ #$2 is data
+ #$3 is grep
+ cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")"
+ #echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+curl_delete () {
+ #$1 is link
+ #$2 is grep
+ cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")"
+ #echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+curl_put () {
+ #$1 is link
+ #$2 is data
+ #$3 is grep
+ cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")"
+ #echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+#Test GET
+test="$(gnunet-identity -d)"
+#if no identity exists
+if [ "" == "$test" ]
+then
+ curl_get "$identity_link/all" "error"
+ gnunet-identity -C "test_plugin_rest_identity"
+ name="$(gnunet-identity -d | awk 'NR==1{print $1}')"
+ public="$(gnunet-identity -d | awk 'NR==1{print $3}')"
+
+ curl_get "${identity_link}/name/$name" "$public"
+ curl_get "${identity_link}/name/$public" "error"
+ curl_get "${identity_link}/name/" "error"
+
+ curl_get "${identity_link}/pubkey/$public" "$name"
+ curl_get "${identity_link}/pubkey/$name" "error"
+ curl_get "${identity_link}/pubkey/" "error"
+
+ gnunet-identity -D "test_plugin_rest_identity"
+else
+ name="$(gnunet-identity -d | awk 'NR==1{print $1}')"
+ public="$(gnunet-identity -d | awk 'NR==1{print $3}')"
+
+ curl_get "${identity_link}/name/$name" "$public"
+ curl_get "${identity_link}/name/$public" "error"
+ curl_get "${identity_link}/name/" "error"
+
+ curl_get "${identity_link}/pubkey/$public" "$name"
+ curl_get "${identity_link}/pubkey/$name" "error"
+ curl_get "${identity_link}/pubkey/" "error"
+fi
+
+#Test POST
+gnunet-identity -D "test_plugin_rest_identity" > /dev/null 2>&1
+gnunet-identity -D "test_plugin_rest_identity1" > /dev/null 2>&1
+
+curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 201 Created"
+curl_post "${identity_link}" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 409"
+curl_post "${identity_link}" '{"name":"Test_plugin_rest_identity"}' "HTTP/1.1 409"
+curl_post "${identity_link}" '{}' "error"
+curl_post "${identity_link}" '' "error"
+curl_post "${identity_link}" '{"name":""}' "error"
+curl_post "${identity_link}" '{"name":123}' "error"
+curl_post "${identity_link}" '{"name":[]}' "error"
+curl_post "${identity_link}" '{"name1":"test_plugin_rest_identity"}' "error"
+curl_post "${identity_link}" '{"other":""}' "error"
+curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1", "other":"test_plugin_rest_identity2"}' "error"
+
+#Test PUT
+name="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $1}')"
+public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
+
+curl_put "${identity_link}/pubkey/$public" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
+curl_put "${identity_link}/pubkey/$public" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
+curl_put "${identity_link}/pubkey/${public}xx" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404"
+curl_put "${identity_link}/pubkey/" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404"
+curl_put "${identity_link}/pubke" '{"newname":"test_plugin_rest_identity1"}' "error"
+curl_put "${identity_link}" '{"newname":"test_plugin_rest_identity1","other":"sdfdsf"}' "error"
+curl_put "${identity_link}/pubkey/$name" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404"
+curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 204"
+curl_put "${identity_link}/pubkey/$public" '{"newnam":"test_plugin_rest_identity"}' "error"
+curl_put "${identity_link}/name/test_plugin_rest_identity" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 204"
+curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"TEST_plugin_rest_identity1"}' "HTTP/1.1 409"
+curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 409"
+curl_put "${identity_link}/name/test_plugin_rest_identityxxx" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 404"
+curl_put "${identity_link}/name/test_plugin_rest_identity1" '{"newname":"test_plugin_rest_identity"}' "HTTP/1.1 204"
+curl_put "${identity_link}/name/test_plugin_rest_identity" '{"newnam":"test_plugin_rest_identityfail"}' "error"
+
+#Test subsystem
+curl_put "${identity_link}/subsystem/test_plugin_rest_identity" '{"subsystem":"namestore"}' "HTTP/1.1 204"
+curl_put "${identity_link}/subsystem/test_plugin_rest_identity" '{"subsystem":"namestore"}' "HTTP/1.1 204"
+curl_get "${identity_link}/subsystem/namestore" "test_plugin_rest_identity"
+public="$(gnunet-identity -d | grep "test_plugin_rest_identity" | awk 'NR==1{print $3}')"
+curl_put "${identity_link}/subsystem/$public" '{"subsystem":"namestore"}' "HTTP/1.1 404"
+curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
+curl_get "${identity_link}/subsystem/test_plugin_rest_identity_no_subsystem" "error"
+curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsystem":"test_plugin_rest_identity_no_subsystem"}' "HTTP/1.1 204"
+curl_get "${identity_link}/subsystem/test_plugin_rest_identity_no_subsystem" "test_plugin_rest_identity1"
+
+curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsyste":"test_plugin_rest_identity_no_subsystem"}' "error"
+curl_put "${identity_link}/subsystem/test_plugin_rest_identity1" '{"subsystem":"test_plugin_rest_identity_no_subsystem"}' "HTTP/1.1 204"
+
+#Test DELETE
+curl_delete "${identity_link}/name/test_plugin_rest_identity" "HTTP/1.1 204"
+curl_get "${identity_link}/name/test_plugin_rest_identity" "error"
+curl_delete "${identity_link}/name/TEST_plugin_rest_identity1" "HTTP/1.1 204"
+curl_delete "${identity_link}/name/test_plugin_rest_identity1" "HTTP/1.1 404"
+curl_get "${identity_link}/name/test_plugin_rest_identity1" "error"
+curl_delete "${identity_link}/name/test_plugin_rest_identity_not_found" "HTTP/1.1 404"
+curl_post "${identity_link}" '{"name":"test_plugin_rest_identity1"}' "HTTP/1.1 201 Created"
+public="$(gnunet-identity -d | grep "test_plugin_rest_identity1" | awk 'NR==1{print $3}')"
+curl_delete "${identity_link}/pubkey/$public" "HTTP/1.1 204"
+curl_delete "${identity_link}/pubke/$public" "error"
+curl_delete "${identity_link}/pubkey/${public}other=232" "HTTP/1.1 404"
+
+#Test wrong_link
+curl_get "$wrong_link" "HTTP/1.1 404"
+curl_post "$wrong_link" '{"name":"test_plugin_rest_identity"}' "HTTP/1.1 404"
+curl_put "$wrong_link/name/test_plugin_rest_identity" '{"newname":"test_plugin_rest_identity1"}' "HTTP/1.1 404"
+curl_delete "$wrong_link/name/test_plugin_rest_identity1" "HTTP/1.1 404"
+
+exit 0;
diff --git a/src/rest-plugins/test_plugin_rest_namestore.sh b/src/rest-plugins/test_plugin_rest_namestore.sh
new file mode 100755
index 000000000..532c7caae
--- /dev/null
+++ b/src/rest-plugins/test_plugin_rest_namestore.sh
@@ -0,0 +1,147 @@
+#!/usr/bin/bash
+
+#First, start gnunet-arm and the rest-service.
+#Exit 0 means success, exit 1 means failed test
+
+namestore_link="http://localhost:7776/namestore"
+wrong_link="http://localhost:7776/namestoreandmore"
+
+
+curl_get () {
+ #$1 is link
+ #$2 is grep
+ cache="$(curl -v "$1" 2>&1 | grep "$2")"
+ echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+curl_post () {
+ #$1 is link
+ #$2 is data
+ #$3 is grep
+ cache="$(curl -v -X "POST" "$1" --data "$2" 2>&1 | grep "$3")"
+ echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+curl_delete () {
+ #$1 is link
+ #$2 is grep
+ cache="$(curl -v -X "DELETE" "$1" 2>&1 | grep "$2")"
+ echo $cache
+ if [ "" == "$cache" ]
+ then
+ exit 1
+ fi
+}
+
+# curl_put () {
+# #$1 is link
+# #$2 is data
+# #$3 is grep
+# cache="$(curl -v -X "PUT" "$1" --data "$2" 2>&1 | grep "$3")"
+# #echo $cache
+# if [ "" == "$cache" ]
+# then
+# exit 1
+# fi
+# }
+
+#Test subsystem default identity
+
+#Test GET
+gnunet-identity -D "test_plugin_rest_namestore"
+gnunet-identity -C "test_plugin_rest_namestore"
+test="$(gnunet-namestore -D -z "test_plugin_rest_namestore")"
+name="test_plugin_rest_namestore"
+public="$(gnunet-identity -d | grep "test_plugin_rest_namestore" | awk 'NR==1{print $3}')"
+if [ "" == "$test" ]
+then
+ #if no entries for test_plugin_rest_namestore
+ curl_get "${namestore_link}/$name" "error"
+ curl_get "${namestore_link}/" "error"
+ curl_get "${namestore_link}/$public" "error"
+else
+ #if entries exists (that should not be possible)
+ curl_get "${namestore_link}" "HTTP/1.1 200 OK"
+ curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK"
+ curl_get "${namestore_link}/" "error"
+ curl_get "${namestore_link}/$public" "error"
+fi
+gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
+curl_get "${namestore_link}" "HTTP/1.1 200 OK"
+curl_get "${namestore_link}/$name" "HTTP/1.1 200 OK"
+curl_get "${namestore_link}/" "error"
+curl_get "${namestore_link}/$public" "error"
+gnunet-namestore -z $name -d -n "test_entry"
+
+#Test POST with NAME
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+#value
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value_missing":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRGxxx", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+#time
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"0d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"10000d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"now","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time_missing":"1d","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+#flag
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":2,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":8,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":16,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":-1,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":"Test","record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag_missing":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+#record_name
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "HTTP/1.1 204 No Content"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":""}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+curl_post "${namestore_link}/$name" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name_missing":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+
+#wrong zone
+curl_post "${namestore_link}/$public" '{"value":"HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG", "record_type":"PKEY", "expiration_time":"1d","flag":0,"record_name":"test_entry"}' "error"
+gnunet-namestore -z $name -d -n "test_entry" > /dev/null 2>&1
+
+#Test DELETE
+gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
+curl_delete "${namestore_link}/$name?record_name=test_entry" "HTTP/1.1 204"
+curl_delete "${namestore_link}/$name?record_name=test_entry" "error"
+gnunet-namestore -z $name -p -a -n "test_entry" -e "1d" -V "HVX38H2CB7WJM0WCPWT9CFX6GASMYJVR65RN75SJSSKAYVYXHMRG" -t "PKEY"
+curl_delete "${namestore_link}/$public?record_name=test_entry" "error"
+
+
+#Test default identity
+#not possible without defining
+
+exit 0;
+
diff --git a/src/rest/Makefile.am b/src/rest/Makefile.am
index f87335152..6c23ad2a6 100644
--- a/src/rest/Makefile.am
+++ b/src/rest/Makefile.am
@@ -10,7 +10,6 @@ libexecdir= $(pkglibdir)/libexec/
pkgcfg_DATA = \
rest.conf
-
if MINGW
WINFLAGS = -Wl,--no-undefined -Wl,--export-all-symbols
endif
@@ -29,18 +28,6 @@ libexec_PROGRAMS = \
EXTRA_DIST = \
rest.conf
-plugin_LTLIBRARIES = libgnunet_plugin_rest_copying.la
-
-libgnunet_plugin_rest_copying_la_SOURCES = \
- plugin_rest_copying.c
-libgnunet_plugin_rest_copying_la_LIBADD = \
- libgnunetrest.la \
- $(top_builddir)/src/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -lmicrohttpd
-libgnunet_plugin_rest_copying_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-
-
gnunet_rest_server_SOURCES = \
gnunet-rest-server.c
diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c
index 49714872f..277688b56 100644
--- a/src/rps/gnunet-rps-profiler.c
+++ b/src/rps/gnunet-rps-profiler.c
@@ -2311,14 +2311,14 @@ void write_final_stats (void){
for (uint32_t i = 0; i < num_peers; i++)
{
- to_file ("/tmp/rps/final_stats.dat",
- "%" PRIu32 " " /* index */
- "%s %" /* id */
- PRIu64 " %" /* rounds */
- PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" /* blocking */
- PRIu64 " %" PRIu64 " %" PRIu64 " %" /* issued */
- PRIu64 " %" PRIu64 " %" PRIu64 " %" /* sent */
- PRIu64 " %" PRIu64 " %" PRIu64 /* recv */,
+ to_file ("/tmp/rps/final_stats.csv",
+ ", %" PRIu32 ", " /* index */
+ "%s, %" /* id */
+ PRIu64 ", %" /* rounds */
+ PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* blocking */
+ PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* issued */
+ PRIu64 ", %" PRIu64 ", %" PRIu64 ", %" /* sent */
+ PRIu64 ", %" PRIu64 ", %" PRIu64 /* recv */,
i,
GNUNET_i2s (rps_peers[i].peer_id),
rps_peers[i].stats[STAT_TYPE_ROUNDS],
@@ -2407,10 +2407,10 @@ post_test_shutdown_ready_cb (void *cls,
GNUNET_TESTBED_operation_done (rps_peer->stat_op);
}
- write_final_stats ();
+ //write_final_stats ();
if (GNUNET_YES == check_statistics_collect_completed())
{
- //write_final_stats ();
+ write_final_stats ();
GNUNET_free (stat_cls);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Shutting down\n");
diff --git a/src/rps/gnunet-service-rps.c b/src/rps/gnunet-service-rps.c
index 6b0ecc58c..1f155b14f 100644
--- a/src/rps/gnunet-service-rps.c
+++ b/src/rps/gnunet-service-rps.c
@@ -84,7 +84,7 @@ static struct GNUNET_HashCode port;
/**
* Set a peer flag of given peer context.
*/
-#define set_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask))
+#define SET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) |= (mask))
/**
* Get peer flag of given peer context.
@@ -95,7 +95,7 @@ static struct GNUNET_HashCode port;
/**
* Unset flag of given peer context.
*/
-#define unset_peer_flag(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
+#define UNSET_PEER_FLAG(peer_ctx, mask) ((peer_ctx->peer_flags) &= ~(mask))
/**
* Get channel flag of given channel context.
@@ -233,11 +233,6 @@ struct PeerContext
struct PendingMessage *pending_messages_tail;
/**
- * @brief Task to destroy this context.
- */
- struct GNUNET_SCHEDULER_Task *destruction_task;
-
- /**
* This is pobably followed by 'statistical' data (when we first saw
* it, how did we get its ID, how many pushes (in a timeinterval),
* ...)
@@ -282,7 +277,9 @@ struct ChannelCtx
struct PeerContext *peer_ctx;
/**
- * @brief Scheduled task that will destroy this context
+ * @brief When channel destruction needs to be delayed (because it is called
+ * from within the cadet routine of another channel destruction) this task
+ * refers to the respective _SCHEDULER_Task.
*/
struct GNUNET_SCHEDULER_Task *destruction_task;
};
@@ -314,7 +311,6 @@ static struct GNUNET_CONTAINER_MultiPeerMap *peer_map;
static struct GNUNET_CADET_Handle *cadet_handle;
-
/**
* @brief Get the #PeerContext associated with a peer
*
@@ -335,8 +331,28 @@ get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
return ctx;
}
-int
-Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer);
+/**
+ * @brief Check whether we have information about the given peer.
+ *
+ * FIXME probably deprecated. Make this the new _online.
+ *
+ * @param peer peer in question
+ *
+ * @return #GNUNET_YES if peer is known
+ * #GNUNET_NO if peer is not knwon
+ */
+static int
+check_peer_known (const struct GNUNET_PeerIdentity *peer)
+{
+ if (NULL != peer_map)
+ {
+ return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
+ } else
+ {
+ return GNUNET_NO;
+ }
+}
+
/**
* @brief Create a new #PeerContext and insert it into the peer map
@@ -351,7 +367,7 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer)
struct PeerContext *ctx;
int ret;
- GNUNET_assert (GNUNET_NO == Peers_check_peer_known (peer));
+ GNUNET_assert (GNUNET_NO == check_peer_known (peer));
ctx = GNUNET_new (struct PeerContext);
ctx->peer_id = *peer;
@@ -372,18 +388,13 @@ create_peer_ctx (const struct GNUNET_PeerIdentity *peer)
static struct PeerContext *
create_or_get_peer_ctx (const struct GNUNET_PeerIdentity *peer)
{
- if (GNUNET_NO == Peers_check_peer_known (peer))
+ if (GNUNET_NO == check_peer_known (peer))
{
return create_peer_ctx (peer);
}
return get_peer_ctx (peer);
}
-void
-Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags);
-
-void
-Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags);
/**
* @brief Check whether we have a connection to this @a peer
@@ -395,13 +406,13 @@ Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlag
* @return #GNUNET_YES if we are connected
* #GNUNET_NO otherwise
*/
-int
-Peers_check_connected (const struct GNUNET_PeerIdentity *peer)
+static int
+check_connected (const struct GNUNET_PeerIdentity *peer)
{
- const struct PeerContext *peer_ctx;
+ struct PeerContext *peer_ctx;
/* If we don't know about this peer we don't know whether it's online */
- if (GNUNET_NO == Peers_check_peer_known (peer))
+ if (GNUNET_NO == check_peer_known (peer))
{
return GNUNET_NO;
}
@@ -411,11 +422,11 @@ Peers_check_connected (const struct GNUNET_PeerIdentity *peer)
if ( (NULL == peer_ctx->send_channel_ctx) &&
(NULL == peer_ctx->recv_channel_ctx) )
{
- Peers_unset_peer_flag (peer, Peers_ONLINE);
+ UNSET_PEER_FLAG (peer_ctx, Peers_ONLINE);
return GNUNET_NO;
}
/* Otherwise (if we have a channel, we know that it's online */
- Peers_set_peer_flag (peer, Peers_ONLINE);
+ SET_PEER_FLAG (peer_ctx, Peers_ONLINE);
return GNUNET_YES;
}
@@ -559,7 +570,7 @@ set_peer_live (struct PeerContext *peer_ctx)
}
(void) add_valid_peer (peer);
- set_peer_flag (peer_ctx, Peers_ONLINE);
+ SET_PEER_FLAG (peer_ctx, Peers_ONLINE);
/* Call pending operations */
for (i = 0; i < peer_ctx->num_pending_ops; i++)
@@ -604,15 +615,37 @@ handle_peer_pull_reply (void *cls,
* @return The channel context
*/
static struct ChannelCtx *
-add_channel_ctx (struct PeerContext *peer_ctx);
+add_channel_ctx (struct PeerContext *peer_ctx)
+{
+ struct ChannelCtx *channel_ctx;
+ channel_ctx = GNUNET_new (struct ChannelCtx);
+ channel_ctx->peer_ctx = peer_ctx;
+ return channel_ctx;
+}
+
/**
- * @brief Remove the channel context from the DLL and free the memory.
+ * @brief Free memory and NULL pointers.
*
* @param channel_ctx The channel context.
*/
static void
-remove_channel_ctx (struct ChannelCtx *channel_ctx);
+remove_channel_ctx (struct ChannelCtx *channel_ctx)
+{
+ struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
+
+ if (channel_ctx == peer_ctx->send_channel_ctx)
+ {
+ GNUNET_free (channel_ctx);
+ peer_ctx->send_channel_ctx = NULL;
+ peer_ctx->mq = NULL;
+ }
+ else if (channel_ctx == peer_ctx->recv_channel_ctx)
+ {
+ GNUNET_free (channel_ctx);
+ peer_ctx->recv_channel_ctx = NULL;
+ }
+}
/**
@@ -664,7 +697,7 @@ get_channel (const struct GNUNET_PeerIdentity *peer)
&port,
GNUNET_CADET_OPTION_RELIABLE,
NULL, /* WindowSize handler */
- cleanup_destroyed_channel, /* Disconnect handler */
+ &cleanup_destroyed_channel, /* Disconnect handler */
cadet_handlers);
}
GNUNET_assert (NULL != peer_ctx->send_channel_ctx);
@@ -823,8 +856,155 @@ check_operation_scheduled (const struct GNUNET_PeerIdentity *peer,
return GNUNET_NO;
}
+
+/**
+ * @brief Callback for scheduler to destroy a channel
+ *
+ * @param cls Context of the channel
+ */
+static void
+destroy_channel (struct ChannelCtx *channel_ctx)
+{
+ struct GNUNET_CADET_Channel *channel;
+
+ if (NULL != channel_ctx->destruction_task)
+ {
+ GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task);
+ channel_ctx->destruction_task = NULL;
+ }
+ GNUNET_assert (channel_ctx->channel != NULL);
+ channel = channel_ctx->channel;
+ channel_ctx->channel = NULL;
+ GNUNET_CADET_channel_destroy (channel);
+ remove_channel_ctx (channel_ctx);
+}
+
+
+/**
+ * @brief Destroy a cadet channel.
+ *
+ * This satisfies the function signature of #GNUNET_SCHEDULER_TaskCallback.
+ *
+ * @param cls
+ */
+static void
+destroy_channel_cb (void *cls)
+{
+ struct ChannelCtx *channel_ctx = cls;
+
+ channel_ctx->destruction_task = NULL;
+ destroy_channel (channel_ctx);
+}
+
+
+/**
+ * @brief Schedule the destruction of a channel for immediately afterwards.
+ *
+ * In case a channel is to be destroyed from within the callback to the
+ * destruction of another channel (send channel), we cannot call
+ * GNUNET_CADET_channel_destroy directly, but need to use this scheduling
+ * construction.
+ *
+ * @param channel_ctx channel to be destroyed.
+ */
+static void
+schedule_channel_destruction (struct ChannelCtx *channel_ctx)
+{
+ GNUNET_assert (NULL ==
+ channel_ctx->destruction_task);
+ GNUNET_assert (NULL !=
+ channel_ctx->channel);
+ channel_ctx->destruction_task =
+ GNUNET_SCHEDULER_add_now (&destroy_channel_cb,
+ channel_ctx);
+}
+
+
+/**
+ * @brief Remove peer
+ *
+ * @param peer the peer to clean
+ * @return #GNUNET_YES if peer was removed
+ * #GNUNET_NO otherwise
+ */
static int
-Peers_remove_peer (const struct GNUNET_PeerIdentity *peer);
+destroy_peer (struct PeerContext *peer_ctx)
+{
+ GNUNET_assert (NULL != peer_ctx);
+ GNUNET_assert (NULL != peer_map);
+ if (GNUNET_NO ==
+ GNUNET_CONTAINER_multipeermap_contains (peer_map,
+ &peer_ctx->peer_id))
+ {
+ return GNUNET_NO;
+ }
+ SET_PEER_FLAG (peer_ctx, Peers_TO_DESTROY);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Going to remove peer %s\n",
+ GNUNET_i2s (&peer_ctx->peer_id));
+ UNSET_PEER_FLAG (peer_ctx, Peers_ONLINE);
+
+ /* Clear list of pending operations */
+ // TODO this probably leaks memory
+ // ('only' the cls to the function. Not sure what to do with it)
+ GNUNET_array_grow (peer_ctx->pending_ops,
+ peer_ctx->num_pending_ops,
+ 0);
+ /* Remove all pending messages */
+ while (NULL != peer_ctx->pending_messages_head)
+ {
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Removing unsent %s\n",
+ peer_ctx->pending_messages_head->type);
+ /* Cancle pending message, too */
+ if ( (NULL != peer_ctx->liveliness_check_pending) &&
+ (0 == memcmp (peer_ctx->pending_messages_head,
+ peer_ctx->liveliness_check_pending,
+ sizeof (struct PendingMessage))) )
+ {
+ // TODO this may leak memory
+ peer_ctx->liveliness_check_pending = NULL;
+ }
+ remove_pending_message (peer_ctx->pending_messages_head,
+ GNUNET_YES);
+ }
+
+ /* If we are still waiting for notification whether this peer is live
+ * cancel the according task */
+ if (NULL != peer_ctx->liveliness_check_pending)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Removing pending liveliness check for peer %s\n",
+ GNUNET_i2s (&peer_ctx->peer_id));
+ // TODO wait until cadet sets mq->cancel_impl
+ //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
+ remove_pending_message (peer_ctx->liveliness_check_pending,
+ GNUNET_YES);
+ peer_ctx->liveliness_check_pending = NULL;
+ }
+
+ if (NULL != peer_ctx->send_channel_ctx)
+ {
+ /* This is possibly called from within channel destruction */
+ schedule_channel_destruction (peer_ctx->send_channel_ctx);
+ }
+ if (NULL != peer_ctx->recv_channel_ctx)
+ {
+ /* This is possibly called from within channel destruction */
+ schedule_channel_destruction (peer_ctx->recv_channel_ctx);
+ }
+
+ if (GNUNET_YES !=
+ GNUNET_CONTAINER_multipeermap_remove_all (peer_map,
+ &peer_ctx->peer_id))
+ {
+ LOG (GNUNET_ERROR_TYPE_WARNING,
+ "removing peer from peer_map failed\n");
+ }
+ GNUNET_free (peer_ctx);
+ return GNUNET_YES;
+}
+
/**
* Iterator over hash map entries. Deletes all contexts of peers.
@@ -840,7 +1020,7 @@ peermap_clear_iterator (void *cls,
const struct GNUNET_PeerIdentity *key,
void *value)
{
- Peers_remove_peer (key);
+ destroy_peer (get_peer_ctx (key));
return GNUNET_YES;
}
@@ -1084,8 +1264,8 @@ restore_valid_peers ()
* @param cadet_h cadet handle
* @param own_id own peer identity
*/
-void
-Peers_initialise (char* fn_valid_peers,
+static void
+initialise_peers (char* fn_valid_peers,
struct GNUNET_CADET_Handle *cadet_h)
{
filename_valid_peers = GNUNET_strdup (fn_valid_peers);
@@ -1097,7 +1277,7 @@ Peers_initialise (char* fn_valid_peers,
/**
- * @brief Delete storage of peers that was created with #Peers_initialise ()
+ * @brief Delete storage of peers that was created with #initialise_peers ()
*/
static void
peers_terminate ()
@@ -1150,9 +1330,9 @@ valid_peer_iterator (void *cls,
* @return the number of key value pairs processed,
* #GNUNET_SYSERR if it aborted iteration
*/
-int
-Peers_get_valid_peers (PeersIterator iterator,
- void *it_cls)
+static int
+get_valid_peers (PeersIterator iterator,
+ void *it_cls)
{
struct PeersIteratorCls *cls;
int ret;
@@ -1179,10 +1359,10 @@ Peers_get_valid_peers (PeersIterator iterator,
* @return #GNUNET_YES if peer was inserted
* #GNUNET_NO otherwise
*/
-int
-Peers_insert_peer (const struct GNUNET_PeerIdentity *peer)
+static int
+insert_peer (const struct GNUNET_PeerIdentity *peer)
{
- if (GNUNET_YES == Peers_check_peer_known (peer))
+ if (GNUNET_YES == check_peer_known (peer))
{
return GNUNET_NO; /* We already know this peer - nothing to do */
}
@@ -1190,8 +1370,30 @@ Peers_insert_peer (const struct GNUNET_PeerIdentity *peer)
return GNUNET_YES;
}
-int
-Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags);
+
+/**
+ * @brief Check whether flags on a peer are set.
+ *
+ * @param peer the peer to check the flag of
+ * @param flags the flags to check
+ *
+ * @return #GNUNET_SYSERR if peer is not known
+ * #GNUNET_YES if all given flags are set
+ * #GNUNET_NO otherwise
+ */
+static int
+check_peer_flag (const struct GNUNET_PeerIdentity *peer,
+ enum Peers_PeerFlags flags)
+{
+ struct PeerContext *peer_ctx;
+
+ if (GNUNET_NO == check_peer_known (peer))
+ {
+ return GNUNET_SYSERR;
+ }
+ peer_ctx = get_peer_ctx (peer);
+ return check_peer_flag_set (peer_ctx, flags);
+}
/**
* @brief Try connecting to a peer to see whether it is online
@@ -1202,15 +1404,15 @@ Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFl
* @return #GNUNET_YES if peer had to be inserted
* #GNUNET_NO otherwise
*/
-int
-Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
+static int
+issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *peer_ctx;
int ret;
- ret = Peers_insert_peer (peer);
+ ret = insert_peer (peer);
peer_ctx = get_peer_ctx (peer);
- if ( (GNUNET_NO == Peers_check_peer_flag (peer, Peers_ONLINE)) &&
+ if ( (GNUNET_NO == check_peer_flag (peer, Peers_ONLINE)) &&
(NULL == peer_ctx->liveliness_check_pending) )
{
check_peer_live (peer_ctx);
@@ -1232,8 +1434,8 @@ Peers_issue_peer_liveliness_check (const struct GNUNET_PeerIdentity *peer)
* #GNUNET_NO if peer is NOT removable
* #GNUNET_SYSERR if peer is not known
*/
-int
-Peers_check_removable (const struct GNUNET_PeerIdentity *peer)
+static int
+check_removable (const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *peer_ctx;
@@ -1252,262 +1454,6 @@ Peers_check_removable (const struct GNUNET_PeerIdentity *peer)
return GNUNET_YES;
}
-uint32_t *
-Peers_get_channel_flag (const struct GNUNET_PeerIdentity *peer,
- enum Peers_ChannelRole role);
-
-int
-Peers_check_channel_flag (uint32_t *channel_flags, enum Peers_ChannelFlags flags);
-
-/**
- * @brief Callback for the scheduler to destroy the knowledge of a peer.
- *
- * @param cls Context of the peer
- */
-static void
-destroy_peer (void *cls)
-{
- struct PeerContext *peer_ctx = cls;
-
- GNUNET_assert (NULL != peer_ctx);
- peer_ctx->destruction_task = NULL;
- Peers_remove_peer (&peer_ctx->peer_id);
-}
-
-
-static void
-destroy_channel (void *cls);
-
-
-/**
- * @brief Schedule the destruction of the given channel.
- *
- * Do so only if it was not already scheduled and not during shutdown.
- *
- * @param channel_ctx The context of the channel to destroy.
- */
-static void
-schedule_channel_destruction (struct ChannelCtx *channel_ctx)
-{
- GNUNET_assert (NULL != channel_ctx);
- if (NULL != channel_ctx->destruction_task &&
- GNUNET_NO == in_shutdown)
- {
- channel_ctx->destruction_task =
- GNUNET_SCHEDULER_add_now (&destroy_channel,
- channel_ctx);
- }
-}
-
-
-/**
- * @brief Schedule the destruction of the given peer.
- *
- * Do so only if it was not already scheduled and not during shutdown.
- *
- * @param peer_ctx The context of the peer to destroy.
- */
-static void
-schedule_peer_destruction (struct PeerContext *peer_ctx)
-{
- GNUNET_assert (NULL != peer_ctx);
- if (NULL != peer_ctx->destruction_task &&
- GNUNET_NO == in_shutdown)
- {
- peer_ctx->destruction_task =
- GNUNET_SCHEDULER_add_now (&destroy_peer,
- peer_ctx);
- }
-}
-
-
-/**
- * @brief Remove peer
- *
- * @param peer the peer to clean
- * @return #GNUNET_YES if peer was removed
- * #GNUNET_NO otherwise
- */
-static int
-Peers_remove_peer (const struct GNUNET_PeerIdentity *peer)
-{
- struct PeerContext *peer_ctx;
-
- GNUNET_assert (NULL != peer_map);
- if (GNUNET_NO ==
- GNUNET_CONTAINER_multipeermap_contains (peer_map,
- peer))
- {
- return GNUNET_NO;
- }
- peer_ctx = get_peer_ctx (peer);
- set_peer_flag (peer_ctx, Peers_TO_DESTROY);
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Going to remove peer %s\n",
- GNUNET_i2s (&peer_ctx->peer_id));
- Peers_unset_peer_flag (peer, Peers_ONLINE);
-
- /* Clear list of pending operations */
- // TODO this probably leaks memory
- // ('only' the cls to the function. Not sure what to do with it)
- GNUNET_array_grow (peer_ctx->pending_ops,
- peer_ctx->num_pending_ops,
- 0);
- /* Remove all pending messages */
- while (NULL != peer_ctx->pending_messages_head)
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Removing unsent %s\n",
- peer_ctx->pending_messages_head->type);
- /* Cancle pending message, too */
- if ( (NULL != peer_ctx->liveliness_check_pending) &&
- (0 == memcmp (peer_ctx->pending_messages_head,
- peer_ctx->liveliness_check_pending,
- sizeof (struct PendingMessage))) )
- {
- // TODO this may leak memory
- peer_ctx->liveliness_check_pending = NULL;
- }
- remove_pending_message (peer_ctx->pending_messages_head,
- GNUNET_YES);
- }
-
- /* If we are still waiting for notification whether this peer is live
- * cancel the according task */
- if (NULL != peer_ctx->liveliness_check_pending)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Removing pending liveliness check for peer %s\n",
- GNUNET_i2s (&peer_ctx->peer_id));
- // TODO wait until cadet sets mq->cancel_impl
- //GNUNET_MQ_send_cancel (peer_ctx->liveliness_check_pending->ev);
- remove_pending_message (peer_ctx->liveliness_check_pending,
- GNUNET_YES);
- peer_ctx->liveliness_check_pending = NULL;
- }
-
-
- /* Do we still have to wait for destruction of channels
- * or issue the destruction? */
- if (NULL != peer_ctx->send_channel_ctx &&
- NULL != peer_ctx->send_channel_ctx->destruction_task)
- {
- schedule_peer_destruction (peer_ctx);
- return GNUNET_NO;
- }
- if (NULL != peer_ctx->recv_channel_ctx &&
- NULL != peer_ctx->recv_channel_ctx->destruction_task)
- {
- schedule_peer_destruction (peer_ctx);
- return GNUNET_NO;
- }
- if (NULL != peer_ctx->recv_channel_ctx)
- {
- schedule_channel_destruction (peer_ctx->recv_channel_ctx);
- schedule_peer_destruction (peer_ctx);
- return GNUNET_NO;
- }
- if (NULL != peer_ctx->send_channel_ctx)
- {
- schedule_channel_destruction (peer_ctx->send_channel_ctx);
- schedule_peer_destruction (peer_ctx);
- return GNUNET_NO;
- }
-
- if (NULL != peer_ctx->destruction_task)
- {
- GNUNET_SCHEDULER_cancel (peer_ctx->destruction_task);
- }
-
- if (GNUNET_YES !=
- GNUNET_CONTAINER_multipeermap_remove_all (peer_map,
- &peer_ctx->peer_id))
- {
- LOG (GNUNET_ERROR_TYPE_WARNING,
- "removing peer from peer_map failed\n");
- }
- GNUNET_free (peer_ctx);
- return GNUNET_YES;
-}
-
-
-/**
- * @brief set flags on a given peer.
- *
- * @param peer the peer to set flags on
- * @param flags the flags
- */
-void
-Peers_set_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags)
-{
- struct PeerContext *peer_ctx;
-
- peer_ctx = get_peer_ctx (peer);
- set_peer_flag (peer_ctx, flags);
-}
-
-
-/**
- * @brief unset flags on a given peer.
- *
- * @param peer the peer to unset flags on
- * @param flags the flags
- */
-void
-Peers_unset_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags)
-{
- struct PeerContext *peer_ctx;
-
- peer_ctx = get_peer_ctx (peer);
- unset_peer_flag (peer_ctx, flags);
-}
-
-
-/**
- * @brief Check whether flags on a peer are set.
- *
- * @param peer the peer to check the flag of
- * @param flags the flags to check
- *
- * @return #GNUNET_SYSERR if peer is not known
- * #GNUNET_YES if all given flags are set
- * #GNUNET_NO otherwise
- */
-int
-Peers_check_peer_flag (const struct GNUNET_PeerIdentity *peer, enum Peers_PeerFlags flags)
-{
- struct PeerContext *peer_ctx;
-
- if (GNUNET_NO == Peers_check_peer_known (peer))
- {
- return GNUNET_SYSERR;
- }
- peer_ctx = get_peer_ctx (peer);
- return check_peer_flag_set (peer_ctx, flags);
-}
-
-/**
- * @brief Check whether we have information about the given peer.
- *
- * FIXME probably deprecated. Make this the new _online.
- *
- * @param peer peer in question
- *
- * @return #GNUNET_YES if peer is known
- * #GNUNET_NO if peer is not knwon
- */
-int
-Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer)
-{
- if (NULL != peer_map)
- {
- return GNUNET_CONTAINER_multipeermap_contains (peer_map, peer);
- } else
- {
- return GNUNET_NO;
- }
-}
-
/**
* @brief Check whether @a peer is actually a peer.
@@ -1519,8 +1465,8 @@ Peers_check_peer_known (const struct GNUNET_PeerIdentity *peer)
* @return #GNUNET_YES if peer is valid
* #GNUNET_NO if peer is not valid
*/
-int
-Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer)
+static int
+check_peer_valid (const struct GNUNET_PeerIdentity *peer)
{
return GNUNET_CONTAINER_multipeermap_contains (valid_peers, peer);
}
@@ -1533,10 +1479,10 @@ Peers_check_peer_valid (const struct GNUNET_PeerIdentity *peer)
*
* @param peer the peer to establish channel to
*/
-void
-Peers_indicate_sending_intention (const struct GNUNET_PeerIdentity *peer)
+static void
+indicate_sending_intention (const struct GNUNET_PeerIdentity *peer)
{
- GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer));
+ GNUNET_assert (GNUNET_YES == check_peer_known (peer));
(void) get_channel (peer);
}
@@ -1550,8 +1496,8 @@ Peers_indicate_sending_intention (const struct GNUNET_PeerIdentity *peer)
* @return #GNUNET_YES if peer has the intention to send
* #GNUNET_NO otherwise
*/
-int
-Peers_check_peer_send_intention (const struct GNUNET_PeerIdentity *peer)
+static int
+check_peer_send_intention (const struct GNUNET_PeerIdentity *peer)
{
const struct PeerContext *peer_ctx;
@@ -1574,10 +1520,10 @@ Peers_check_peer_send_intention (const struct GNUNET_PeerIdentity *peer)
* @return initial channel context for the channel
* (can be NULL -- that's not an error)
*/
-void *
-Peers_handle_inbound_channel (void *cls,
- struct GNUNET_CADET_Channel *channel,
- const struct GNUNET_PeerIdentity *initiator)
+static void *
+handle_inbound_channel (void *cls,
+ struct GNUNET_CADET_Channel *channel,
+ const struct GNUNET_PeerIdentity *initiator)
{
struct PeerContext *peer_ctx;
struct GNUNET_PeerIdentity *ctx_peer;
@@ -1595,14 +1541,12 @@ Peers_handle_inbound_channel (void *cls,
channel_ctx = add_channel_ctx (peer_ctx);
channel_ctx->channel = channel;
/* We only accept one incoming channel per peer */
- if (GNUNET_YES == Peers_check_peer_send_intention (initiator))
+ if (GNUNET_YES == check_peer_send_intention (initiator))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Already got one receive channel. Destroying old one.\n");
GNUNET_break_op (0);
- GNUNET_CADET_channel_destroy (peer_ctx->recv_channel_ctx->channel);
- peer_ctx->recv_channel_ctx->channel = NULL;
- remove_channel_ctx (peer_ctx->recv_channel_ctx);
+ destroy_channel (peer_ctx->recv_channel_ctx);
peer_ctx->recv_channel_ctx = channel_ctx;
/* return the channel context */
return channel_ctx;
@@ -1620,12 +1564,12 @@ Peers_handle_inbound_channel (void *cls,
* @return #GNUNET_YES if a sending channel towards that peer exists
* #GNUNET_NO otherwise
*/
-int
-Peers_check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer)
+static int
+check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *peer_ctx;
- if (GNUNET_NO == Peers_check_peer_known (peer))
+ if (GNUNET_NO == check_peer_known (peer))
{ /* If no such peer exists, there is no channel */
return GNUNET_NO;
}
@@ -1639,46 +1583,6 @@ Peers_check_sending_channel_exists (const struct GNUNET_PeerIdentity *peer)
/**
- * @brief check whether the given channel is the sending channel of the given
- * peer
- *
- * @param peer the peer in question
- * @param channel the channel to check for
- * @param role either #Peers_CHANNEL_ROLE_SENDING, or
- * #Peers_CHANNEL_ROLE_RECEIVING
- *
- * @return #GNUNET_YES if the given chennel is the sending channel of the peer
- * #GNUNET_NO otherwise
- */
-int
-Peers_check_channel_role (const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_CADET_Channel *channel,
- enum Peers_ChannelRole role)
-{
- const struct PeerContext *peer_ctx;
-
- if (GNUNET_NO == Peers_check_peer_known (peer))
- {
- return GNUNET_NO;
- }
- peer_ctx = get_peer_ctx (peer);
- if ( (Peers_CHANNEL_ROLE_SENDING == role) &&
- (NULL != peer_ctx->send_channel_ctx) &&
- (channel == peer_ctx->send_channel_ctx->channel) )
- {
- return GNUNET_YES;
- }
- if ( (Peers_CHANNEL_ROLE_RECEIVING == role) &&
- (NULL != peer_ctx->recv_channel_ctx) &&
- (channel == peer_ctx->recv_channel_ctx->channel) )
- {
- return GNUNET_YES;
- }
- return GNUNET_NO;
-}
-
-
-/**
* @brief Destroy the send channel of a peer e.g. stop indicating a sending
* intention to another peer
*
@@ -1690,46 +1594,26 @@ Peers_check_channel_role (const struct GNUNET_PeerIdentity *peer,
* @return #GNUNET_YES if channel was destroyed
* #GNUNET_NO otherwise
*/
-int
-Peers_destroy_sending_channel (const struct GNUNET_PeerIdentity *peer)
+static int
+destroy_sending_channel (const struct GNUNET_PeerIdentity *peer)
{
struct PeerContext *peer_ctx;
- if (GNUNET_NO == Peers_check_peer_known (peer))
+ if (GNUNET_NO == check_peer_known (peer))
{
return GNUNET_NO;
}
peer_ctx = get_peer_ctx (peer);
if (NULL != peer_ctx->send_channel_ctx)
{
- schedule_channel_destruction (peer_ctx->send_channel_ctx);
- (void) Peers_check_connected (peer);
+ destroy_channel (peer_ctx->send_channel_ctx);
+ (void) check_connected (peer);
return GNUNET_YES;
}
return GNUNET_NO;
}
/**
- * @brief Callback for scheduler to destroy a channel
- *
- * @param cls Context of the channel
- */
-static void
-destroy_channel (void *cls)
-{
- struct ChannelCtx *channel_ctx = cls;
- struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
-
- GNUNET_assert (channel_ctx == peer_ctx->send_channel_ctx ||
- channel_ctx == peer_ctx->recv_channel_ctx);
-
- channel_ctx->destruction_task = NULL;
- GNUNET_CADET_channel_destroy (channel_ctx->channel);
- remove_channel_ctx (peer_ctx->send_channel_ctx);
-}
-
-
-/**
* @brief Send a message to another peer.
*
* Keeps track about pending messages so they can be properly removed when the
@@ -1739,10 +1623,10 @@ destroy_channel (void *cls)
* @param ev envelope of the message
* @param type type of the message
*/
-void
-Peers_send_message (const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_MQ_Envelope *ev,
- const char *type)
+static void
+send_message (const struct GNUNET_PeerIdentity *peer,
+ struct GNUNET_MQ_Envelope *ev,
+ const char *type)
{
struct PendingMessage *pending_msg;
struct GNUNET_MQ_Handle *mq;
@@ -1769,14 +1653,14 @@ Peers_send_message (const struct GNUNET_PeerIdentity *peer,
* @return #GNUNET_YES if the operation was scheduled
* #GNUNET_NO otherwise
*/
-int
-Peers_schedule_operation (const struct GNUNET_PeerIdentity *peer,
+static int
+schedule_operation (const struct GNUNET_PeerIdentity *peer,
const PeerOp peer_op)
{
struct PeerPendingOp pending_op;
struct PeerContext *peer_ctx;
- GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer));
+ GNUNET_assert (GNUNET_YES == check_peer_known (peer));
//TODO if LIVE/ONLINE execute immediately
@@ -1793,24 +1677,6 @@ Peers_schedule_operation (const struct GNUNET_PeerIdentity *peer,
return GNUNET_NO;
}
-/**
- * @brief Get the recv_channel of @a peer.
- * Needed to correctly handle (call #GNUNET_CADET_receive_done()) incoming
- * messages.
- *
- * @param peer The peer to get the recv_channel from.
- *
- * @return The recv_channel.
- */
-struct GNUNET_CADET_Channel *
-Peers_get_recv_channel (const struct GNUNET_PeerIdentity *peer)
-{
- struct PeerContext *peer_ctx;
-
- GNUNET_assert (GNUNET_YES == Peers_check_peer_known (peer));
- peer_ctx = get_peer_ctx (peer);
- return peer_ctx->recv_channel_ctx->channel;
-}
/***********************************************************************
* /Old gnunet-service-rps_peers.c
***********************************************************************/
@@ -2266,16 +2132,16 @@ insert_in_view (const struct GNUNET_PeerIdentity *peer)
{
int online;
- online = Peers_check_peer_flag (peer, Peers_ONLINE);
+ online = check_peer_flag (peer, Peers_ONLINE);
if ( (GNUNET_NO == online) ||
(GNUNET_SYSERR == online) ) /* peer is not even known */
{
- (void) Peers_issue_peer_liveliness_check (peer);
- (void) Peers_schedule_operation (peer, insert_in_view_op);
+ (void) issue_peer_liveliness_check (peer);
+ (void) schedule_operation (peer, insert_in_view_op);
return GNUNET_NO;
}
/* Open channel towards peer to keep connection open */
- Peers_indicate_sending_intention (peer);
+ indicate_sending_intention (peer);
return View_put (peer);
}
@@ -2468,7 +2334,7 @@ send_pull_reply (const struct GNUNET_PeerIdentity *peer_id,
GNUNET_memcpy (&out_msg[1], peer_ids,
send_size * sizeof (struct GNUNET_PeerIdentity));
- Peers_send_message (peer_id, ev, "PULL REPLY");
+ send_message (peer_id, ev, "PULL REPLY");
GNUNET_STATISTICS_update(stats, "# pull reply send issued", 1, GNUNET_NO);
// TODO check with send intention: as send_channel is used/opened we indicate
// a sending intention without intending it.
@@ -2519,10 +2385,10 @@ insert_in_sampler (void *cls,
if (0 < RPS_sampler_count_id (prot_sampler, peer))
{
/* Make sure we 'know' about this peer */
- (void) Peers_issue_peer_liveliness_check (peer);
+ (void) issue_peer_liveliness_check (peer);
/* Establish a channel towards that peer to indicate we are going to send
* messages to it */
- //Peers_indicate_sending_intention (peer);
+ //indicate_sending_intention (peer);
}
#ifdef TO_FILE
num_observed_peers++;
@@ -2554,10 +2420,10 @@ static void
got_peer (const struct GNUNET_PeerIdentity *peer)
{
/* If we did not know this peer already, insert it into sampler and view */
- if (GNUNET_YES == Peers_issue_peer_liveliness_check (peer))
+ if (GNUNET_YES == issue_peer_liveliness_check (peer))
{
- Peers_schedule_operation (peer, insert_in_sampler);
- Peers_schedule_operation (peer, insert_in_view_op);
+ schedule_operation (peer, insert_in_sampler);
+ schedule_operation (peer, insert_in_view_op);
}
}
@@ -2572,17 +2438,17 @@ static int
check_sending_channel_needed (const struct GNUNET_PeerIdentity *peer)
{
/* struct GNUNET_CADET_Channel *channel; */
- if (GNUNET_NO == Peers_check_peer_known (peer))
+ if (GNUNET_NO == check_peer_known (peer))
{
return GNUNET_NO;
}
- if (GNUNET_YES == Peers_check_sending_channel_exists (peer))
+ if (GNUNET_YES == check_sending_channel_exists (peer))
{
if ( (0 < RPS_sampler_count_id (prot_sampler, peer)) ||
(GNUNET_YES == View_contains_peer (peer)) ||
(GNUNET_YES == CustomPeerMap_contains_peer (push_map, peer)) ||
(GNUNET_YES == CustomPeerMap_contains_peer (pull_map, peer)) ||
- (GNUNET_YES == Peers_check_peer_flag (peer, Peers_PULL_REPLY_PENDING)))
+ (GNUNET_YES == check_peer_flag (peer, Peers_PULL_REPLY_PENDING)))
{ /* If we want to keep the connection to peer open */
return GNUNET_YES;
}
@@ -2605,7 +2471,7 @@ remove_peer (const struct GNUNET_PeerIdentity *peer)
CustomPeerMap_remove_peer (push_map, peer);
RPS_sampler_reinitialise_by_value (prot_sampler, peer);
RPS_sampler_reinitialise_by_value (client_sampler, peer);
- schedule_peer_destruction (get_peer_ctx (peer));
+ destroy_peer (get_peer_ctx (peer));
}
@@ -2626,19 +2492,19 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
GNUNET_i2s (peer));
#ifdef ENABLE_MALICIOUS
if (0 != GNUNET_CRYPTO_cmp_peer_identity (&attacked_peer, peer))
- (void) Peers_destroy_sending_channel (peer);
+ (void) destroy_sending_channel (peer);
#else /* ENABLE_MALICIOUS */
- (void) Peers_destroy_sending_channel (peer);
+ (void) destroy_sending_channel (peer);
#endif /* ENABLE_MALICIOUS */
}
- if ( (GNUNET_NO == Peers_check_peer_send_intention (peer)) &&
+ if ( (GNUNET_NO == check_peer_send_intention (peer)) &&
(GNUNET_NO == View_contains_peer (peer)) &&
(GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
(GNUNET_NO == CustomPeerMap_contains_peer (push_map, peer)) &&
(0 == RPS_sampler_count_id (prot_sampler, peer)) &&
(0 == RPS_sampler_count_id (client_sampler, peer)) &&
- (GNUNET_NO != Peers_check_removable (peer)) )
+ (GNUNET_NO != check_removable (peer)) )
{ /* We can safely remove this peer */
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Going to remove peer %s\n",
@@ -2648,53 +2514,6 @@ clean_peer (const struct GNUNET_PeerIdentity *peer)
}
}
-/**
- * @brief Allocate memory for a new channel context and insert it into DLL
- *
- * @param peer_ctx context of the according peer
- *
- * @return The channel context
- */
-static struct ChannelCtx *
-add_channel_ctx (struct PeerContext *peer_ctx)
-{
- struct ChannelCtx *channel_ctx;
- channel_ctx = GNUNET_new (struct ChannelCtx);
- channel_ctx->peer_ctx = peer_ctx;
- return channel_ctx;
-}
-
-
-/**
- * @brief Remove the channel context from the DLL and free the memory.
- *
- * @param channel_ctx The channel context.
- */
-static void
-remove_channel_ctx (struct ChannelCtx *channel_ctx)
-{
- struct PeerContext *peer_ctx = channel_ctx->peer_ctx;
-
- if (NULL != channel_ctx->destruction_task)
- {
- GNUNET_SCHEDULER_cancel (channel_ctx->destruction_task);
- }
- GNUNET_free (channel_ctx);
- if (channel_ctx == peer_ctx->send_channel_ctx)
- {
- peer_ctx->send_channel_ctx = NULL;
- peer_ctx->mq = NULL;
- }
- else if (channel_ctx == peer_ctx->recv_channel_ctx)
- {
- peer_ctx->recv_channel_ctx = NULL;
- }
- else
- {
- GNUNET_assert (0);
- }
-}
-
/**
* @brief This is called when a channel is destroyed.
@@ -2719,7 +2538,7 @@ cleanup_destroyed_channel (void *cls,
// * cleanup everything related to the channel
// * memory
// * remove peer if necessary
-
+ channel_ctx->channel = NULL;
if (peer_ctx->recv_channel_ctx == channel_ctx)
{
remove_channel_ctx (channel_ctx);
@@ -3184,7 +3003,7 @@ handle_peer_push (void *cls,
/* Add the sending peer to the push_map */
CustomPeerMap_put (push_map, peer);
- GNUNET_break_op (Peers_check_peer_known (peer));
+ GNUNET_break_op (check_peer_known (peer));
GNUNET_CADET_receive_done (channel_ctx->channel);
}
@@ -3224,7 +3043,7 @@ handle_peer_pull_request (void *cls,
}
#endif /* ENABLE_MALICIOUS */
- GNUNET_break_op (Peers_check_peer_known (peer));
+ GNUNET_break_op (check_peer_known (peer));
GNUNET_CADET_receive_done (channel_ctx->channel);
view_array = View_get_as_array ();
send_pull_reply (peer, view_array, View_size ());
@@ -3262,7 +3081,7 @@ check_peer_pull_reply (void *cls,
return GNUNET_SYSERR;
}
- if (GNUNET_YES != Peers_check_peer_flag (sender, Peers_PULL_REPLY_PENDING))
+ if (GNUNET_YES != check_peer_flag (sender, Peers_PULL_REPLY_PENDING))
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Received a pull reply from a peer (%s) we didn't request one from!\n",
@@ -3336,23 +3155,23 @@ handle_peer_pull_reply (void *cls,
}
#endif /* ENABLE_MALICIOUS */
/* Make sure we 'know' about this peer */
- (void) Peers_insert_peer (&peers[i]);
+ (void) insert_peer (&peers[i]);
- if (GNUNET_YES == Peers_check_peer_valid (&peers[i]))
+ if (GNUNET_YES == check_peer_valid (&peers[i]))
{
CustomPeerMap_put (pull_map, &peers[i]);
}
else
{
- Peers_schedule_operation (&peers[i], insert_in_pull_map);
- (void) Peers_issue_peer_liveliness_check (&peers[i]);
+ schedule_operation (&peers[i], insert_in_pull_map);
+ (void) issue_peer_liveliness_check (&peers[i]);
}
}
- Peers_unset_peer_flag (sender, Peers_PULL_REPLY_PENDING);
+ UNSET_PEER_FLAG (get_peer_ctx (sender), Peers_PULL_REPLY_PENDING);
clean_peer (sender);
- GNUNET_break_op (Peers_check_peer_known (sender));
+ GNUNET_break_op (check_peer_known (sender));
GNUNET_CADET_receive_done (channel_ctx->channel);
}
@@ -3416,16 +3235,16 @@ send_pull_request (const struct GNUNET_PeerIdentity *peer)
{
struct GNUNET_MQ_Envelope *ev;
- GNUNET_assert (GNUNET_NO == Peers_check_peer_flag (peer,
+ GNUNET_assert (GNUNET_NO == check_peer_flag (peer,
Peers_PULL_REPLY_PENDING));
- Peers_set_peer_flag (peer, Peers_PULL_REPLY_PENDING);
+ SET_PEER_FLAG (get_peer_ctx (peer), Peers_PULL_REPLY_PENDING);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Going to send PULL REQUEST to peer %s.\n",
GNUNET_i2s (peer));
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PULL_REQUEST);
- Peers_send_message (peer, ev, "PULL REQUEST");
+ send_message (peer, ev, "PULL REQUEST");
GNUNET_STATISTICS_update(stats, "# pull request send issued", 1, GNUNET_NO);
}
@@ -3445,7 +3264,7 @@ send_push (const struct GNUNET_PeerIdentity *peer_id)
GNUNET_i2s (peer_id));
ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_RPS_PP_PUSH);
- Peers_send_message (peer_id, ev, "PUSH");
+ send_message (peer_id, ev, "PUSH");
GNUNET_STATISTICS_update(stats, "# push send issued", 1, GNUNET_NO);
}
@@ -3569,9 +3388,9 @@ handle_client_act_malicious (void *cls,
&msg->attacked_peer,
sizeof (struct GNUNET_PeerIdentity));
/* Set the flag of the attacked peer to valid to avoid problems */
- if (GNUNET_NO == Peers_check_peer_known (&attacked_peer))
+ if (GNUNET_NO == check_peer_known (&attacked_peer))
{
- (void) Peers_issue_peer_liveliness_check (&attacked_peer);
+ (void) issue_peer_liveliness_check (&attacked_peer);
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -3661,8 +3480,8 @@ do_mal_round (void *cls)
* Send as many pushes to the attacked peer as possible
* That is one push per round as it will ignore more.
*/
- (void) Peers_issue_peer_liveliness_check (&attacked_peer);
- if (GNUNET_YES == Peers_check_peer_flag (&attacked_peer, Peers_ONLINE))
+ (void) issue_peer_liveliness_check (&attacked_peer);
+ if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
send_push (&attacked_peer);
}
@@ -3671,10 +3490,10 @@ do_mal_round (void *cls)
{ /* Combined attack */
/* Send PUSH to attacked peers */
- if (GNUNET_YES == Peers_check_peer_known (&attacked_peer))
+ if (GNUNET_YES == check_peer_known (&attacked_peer))
{
- (void) Peers_issue_peer_liveliness_check (&attacked_peer);
- if (GNUNET_YES == Peers_check_peer_flag (&attacked_peer, Peers_ONLINE))
+ (void) issue_peer_liveliness_check (&attacked_peer);
+ if (GNUNET_YES == check_peer_flag (&attacked_peer, Peers_ONLINE))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Goding to send push to attacked peer (%s)\n",
@@ -3682,7 +3501,7 @@ do_mal_round (void *cls)
send_push (&attacked_peer);
}
}
- (void) Peers_issue_peer_liveliness_check (&attacked_peer);
+ (void) issue_peer_liveliness_check (&attacked_peer);
/* The maximum of pushes we're going to send this round */
num_pushes = GNUNET_MIN (GNUNET_MIN (push_limit - 1,
@@ -3799,7 +3618,7 @@ do_round (void *cls)
for (i = first_border; i < second_border; i++)
{
peer = view_array[permut[i]];
- if ( GNUNET_NO == Peers_check_peer_flag (&peer, Peers_PULL_REPLY_PENDING))
+ if ( GNUNET_NO == check_peer_flag (&peer, Peers_PULL_REPLY_PENDING))
{ // FIXME if this fails schedule/loop this for later
send_pull_request (&peer);
}
@@ -4098,13 +3917,14 @@ shutdown_task (void *cls)
do_round_task = NULL;
}
- Peers_terminate ();
+ peers_terminate ();
GNUNET_NSE_disconnect (nse);
RPS_sampler_destroy (prot_sampler);
RPS_sampler_destroy (client_sampler);
GNUNET_CADET_close_port (cadet_port);
GNUNET_CADET_disconnect (cadet_handle);
+ cadet_handle = NULL;
View_destroy ();
CustomPeerMap_destroy (push_map);
CustomPeerMap_destroy (pull_map);
@@ -4315,7 +4135,7 @@ run (void *cls,
&port);
cadet_port = GNUNET_CADET_open_port (cadet_handle,
&port,
- &Peers_handle_inbound_channel, /* Connect handler */
+ &handle_inbound_channel, /* Connect handler */
NULL, /* cls */
NULL, /* WindowSize handler */
&cleanup_destroyed_channel, /* Disconnect handler */
@@ -4330,7 +4150,7 @@ run (void *cls,
peerinfo_handle = GNUNET_PEERINFO_connect (cfg);
- Peers_initialise (fn_valid_peers, cadet_handle);
+ initialise_peers (fn_valid_peers, cadet_handle);
GNUNET_free (fn_valid_peers);
/* Initialise sampler */
@@ -4353,7 +4173,7 @@ run (void *cls,
// TODO send push/pull to each of those peers?
// TODO read stored valid peers from last run
LOG (GNUNET_ERROR_TYPE_DEBUG, "Requesting stored valid peers\n");
- Peers_get_valid_peers (valid_peers_iterator, NULL);
+ get_valid_peers (valid_peers_iterator, NULL);
peerinfo_notify_handle = GNUNET_PEERINFO_notify (cfg,
GNUNET_NO,
diff --git a/src/rps/gnunet-service-rps_custommap.c b/src/rps/gnunet-service-rps_custommap.c
index 9e003eb39..3513ff8da 100644
--- a/src/rps/gnunet-service-rps_custommap.c
+++ b/src/rps/gnunet-service-rps_custommap.c
@@ -202,6 +202,7 @@ CustomPeerMap_remove_peer (const struct CustomPeerMap *c_peer_map,
p = GNUNET_CONTAINER_multihashmap32_get (c_peer_map->hash_map, *index);
GNUNET_assert (NULL != p);
GNUNET_CONTAINER_multihashmap32_remove_all (c_peer_map->hash_map, *index);
+ // TODO wrong peerid?
GNUNET_CONTAINER_multipeermap_remove_all (c_peer_map->peer_map, peer);
if (*index != CustomPeerMap_size (c_peer_map))
{ /* fill 'gap' with peer at last index */
diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c
index 08fe96097..ed682c251 100644
--- a/src/rps/rps-test_util.c
+++ b/src/rps/rps-test_util.c
@@ -239,7 +239,7 @@ to_file_raw_unaligned (const char *file_name,
/* needed bits of the input byte that have not been moved */
char byte_input_leftover;
unsigned num_bits_leftover;
- unsigned num_bits_discard;
+ //unsigned num_bits_discard;
char byte_unaligned_new;
if ( (bits_needed - (i * 8)) <= 8)
diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 08424022f..92d8c12ea 100644
--- a/src/rps/test_rps.c
+++ b/src/rps/test_rps.c
@@ -2850,7 +2850,7 @@ main (int argc, char *argv[])
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "This is the profiler\n");
cur_test_run.name = "test-rps-profiler";
- num_peers = 100;
+ num_peers = 16;
mal_type = 3;
cur_test_run.init_peer = profiler_init_peer;
//cur_test_run.pre_test = mal_pre;
diff --git a/src/rps/test_rps.conf b/src/rps/test_rps.conf
index 05bb9f444..84e0e5049 100644
--- a/src/rps/test_rps.conf
+++ b/src/rps/test_rps.conf
@@ -1,6 +1,7 @@
[rps]
#PREFIX = valgrind --leak-check=full --show-leak-kinds=all --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p
-#BINARY = gnunet-service-rps
+#PREFIX = valgrind --log-file=/tmp/rps/valgrind!gnunet-service-rps!%p
+#PREFIX = valgrind
UNIXPATH = $GNUNET_TMP/gnunet-service-rps.sock
HOME = $SERVICEHOME
# PORT = 2106