[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: REST: Remove plugins. Hardcode features
From: |
gnunet |
Subject: |
[gnunet] branch master updated: REST: Remove plugins. Hardcode features |
Date: |
Fri, 20 Oct 2023 00:07:05 +0200 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 711d2d431 REST: Remove plugins. Hardcode features
711d2d431 is described below
commit 711d2d431b27b7232de735c6f96b39cd94dd23c6
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Fri Oct 20 00:06:56 2023 +0200
REST: Remove plugins. Hardcode features
---
src/Makefile.am | 1 -
src/include/gnunet_rest_plugin.h | 21 +--
src/meson.build | 1 -
src/rest-plugin/Makefile.am | 6 -
src/rest-plugin/gns/Makefile.am | 61 ---------
src/rest-plugin/gns/meson.build | 13 --
src/rest-plugin/gns/test_plugin_rest_gns.sh | 76 -----------
src/rest-plugin/identity/Makefile.am | 26 ----
src/rest-plugin/identity/meson.build | 11 --
src/rest-plugin/meson.build | 7 -
src/rest-plugin/namestore/Makefile.am | 53 --------
src/rest-plugin/namestore/meson.build | 14 --
src/rest-plugin/reclaim/Makefile.am | 81 ------------
src/rest-plugin/reclaim/meson.build | 29 -----
src/rest-plugin/rest/Makefile.am | 37 ------
src/rest-plugin/rest/meson.build | 18 ---
src/service/Makefile.am | 4 +-
src/service/meson.build | 4 +-
src/service/rest/Makefile.am | 18 ++-
.../rest/config_plugin.c} | 69 ++++------
src/service/rest/config_plugin.h | 37 ++++++
.../rest/copying_plugin.c} | 23 ++--
src/service/rest/copying_plugin.h | 36 +++++
.../rest/gns_plugin.c} | 27 ++--
src/service/rest/gns_plugin.h | 36 +++++
src/service/rest/gnunet-rest-server.c | 145 +++++++++++++++------
.../rest/identity_plugin.c} | 39 +++---
src/service/rest/identity_plugin.h | 36 +++++
.../reclaim => service/rest}/json_reclaim.c | 0
.../reclaim => service/rest}/json_reclaim.h | 0
src/service/rest/meson.build | 26 +++-
.../rest/namestore_plugin.c} | 34 ++---
src/service/rest/namestore_plugin.h | 37 ++++++
.../reclaim => service/rest}/oidc_helper.c | 0
.../reclaim => service/rest}/oidc_helper.h | 0
.../rest/openid_plugin.c} | 61 +++++----
src/service/rest/openid_plugin.h | 36 +++++
.../rest/pabc_plugin.c} | 0
.../rest/reclaim_plugin.c} | 31 ++---
src/service/rest/reclaim_plugin.h | 36 +++++
40 files changed, 549 insertions(+), 641 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am
index c0c5309b2..524b989c1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,5 @@ SUBDIRS = \
lib \
plugin \
service \
- rest-plugin \
cli \
contrib
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index 45b391ca1..3a8af5389 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -63,24 +63,13 @@ struct GNUNET_REST_Plugin
* e.g. http://hostname:port/name
*/
char *name;
-
- /**
- * Function to process a REST call
- *
- * @param method the HTTP method called
- * @param url the relative url accessed
- * @param data the REST data (can be NULL)
- * @param data_size the length of the data
- * @param proc the callback for result
- * @param proc_cls closure for callback
- * @return GNUNET_YES if the request was processed
- */
- enum GNUNET_GenericReturnValue (*process_request)(
- struct GNUNET_REST_RequestHandle *handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls);
};
+typedef enum GNUNET_GenericReturnValue (*GNUNET_REST_ProcessingFunction)(
+ void *plugin,
+ struct GNUNET_REST_RequestHandle *handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
#if 0 /* keep Emacsens' auto-indent happy */
{
diff --git a/src/meson.build b/src/meson.build
index 0a2dab664..8f8342a4d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -6,6 +6,5 @@ subdir('include')
subdir('lib')
subdir('plugin')
subdir('service')
-subdir('rest-plugin')
subdir('cli')
subdir('contrib')
diff --git a/src/rest-plugin/Makefile.am b/src/rest-plugin/Makefile.am
deleted file mode 100644
index 3379cb24e..000000000
--- a/src/rest-plugin/Makefile.am
+++ /dev/null
@@ -1,6 +0,0 @@
-SUBDIRS = \
- rest \
- identity \
- namestore \
- gns \
- reclaim
diff --git a/src/rest-plugin/gns/Makefile.am b/src/rest-plugin/gns/Makefile.am
deleted file mode 100644
index 48b278df6..000000000
--- a/src/rest-plugin/gns/Makefile.am
+++ /dev/null
@@ -1,61 +0,0 @@
-# This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include
-
-if HAVE_LIBIDN
- LIBIDN= -lidn
-else
- LIBIDN=
-endif
-
-if HAVE_LIBIDN2
- LIBIDN2= -lidn2
-else
- LIBIDN2=
-endif
-
-USE_VPN = $(top_builddir)/src/service/vpn/libgnunetvpn.la
-
-if USE_COVERAGE
- AM_CFLAGS = --coverage -O0
-endif
-
-pkgcfgdir = $(pkgdatadir)/config.d/
-
-libexecdir= $(pkglibdir)/libexec/
-
-plugindir = $(libdir)/gnunet
-
-REST_PLUGIN = libgnunet_plugin_rest_gns.la
-
-plugin_LTLIBRARIES = \
- $(REST_PLUGIN)
-
-
-libgnunet_plugin_rest_gns_la_SOURCES = \
- plugin_rest_gns.c
-libgnunet_plugin_rest_gns_la_LIBADD = \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecordjson.la \
- $(top_builddir)/src/service/gns/libgnunetgns.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
- $(top_builddir)/src/lib/json/libgnunetjson.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson $(MHD_LIBS)
-libgnunet_plugin_rest_gns_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_gns_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
-
-
-check_SCRIPTS = \
- test_plugin_rest_gns.sh
-
-EXTRA_DIST = \
- test_plugin_rest_gns.sh
-
-if ENABLE_TEST_RUN
-if HAVE_SQLITE
- 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 = $(check_SCRIPTS)
-endif
-endif
diff --git a/src/rest-plugin/gns/meson.build b/src/rest-plugin/gns/meson.build
deleted file mode 100644
index 7a4deffed..000000000
--- a/src/rest-plugin/gns/meson.build
+++ /dev/null
@@ -1,13 +0,0 @@
-shared_module('gnunet_plugin_rest_gns',
- ['plugin_rest_gns.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetgnsrecord_dep,
- libgnunetgnsrecordjson_dep,
- libgnunetgns_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-
diff --git a/src/rest-plugin/gns/test_plugin_rest_gns.sh
b/src/rest-plugin/gns/test_plugin_rest_gns.sh
deleted file mode 100755
index 3bcfb5a08..000000000
--- a/src/rest-plugin/gns/test_plugin_rest_gns.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/bin/sh
-# This file is in the public domain.
-trap "gnunet-arm -e -c test_gns_lookup.conf" INT
-LOCATION=$(which gnunet-config)
-if [ -z $LOCATION ]
-then
- LOCATION="gnunet-config"
-fi
-$LOCATION --version 1> /dev/null
-if test $? != 0
-then
- echo "GNUnet command line tools cannot be found, check environmental
variables PATH and GNUNET_PREFIX"
- exit 77
-fi
-
-rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
-
-gns_link="http://localhost:7776/gns"
-wrong_link="http://localhost:7776/gnsandmore"
-
-curl_get () {
- #$1 is link
- #$2 is grep
- XURL=`which curl`
- if [ "" = "$XURL" ]
- then
- echo "HTTP client (curl) not found, exiting"
- exit 77
- fi
- sleep 0.5
- cache="$(${XURL} -v "$1" 2>&1 | grep "$2")"
- #echo "$cache"
- if [ "" = "$cache" ]
- then
- gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
- gnunet-arm -e -c test_gns_lookup.conf
- echo "Download of $1 using $XURL failed, expected $2"
- exit 1
- fi
-}
-TEST_TLD="testtld"
-
-gnunet-arm -s -c test_gns_lookup.conf
-
-curl_get "$gns_link/www.$TEST_TLD" "error"
-
-gnunet-identity -C "$TEST_TLD" -c test_gns_lookup.conf
-sleep 0.5
-curl_get "$gns_link/www.$TEST_TLD" "\[\]"
-
-gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.1 -t A -c
test_gns_lookup.conf
-
-curl_get "$gns_link/www.$TEST_TLD" "1.1.1.1"
-
-gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1::1 -t AAAA -c
test_gns_lookup.conf
-
-curl_get "$gns_link/www.$TEST_TLD" "1::1.*1.1.1.1"
-
-gnunet-namestore -z "$TEST_TLD" -p -a -n www -e 1d -V 1.1.1.2 -t A -c
test_gns_lookup.conf
-
-curl_get "$gns_link/www.$TEST_TLD" "1.1.1.2.*1::1.*1.1.1.1"
-curl_get "$gns_link/www.$TEST_TLD?record_type=A" "1.1.1.2.*1.1.1.1"
-curl_get "$gns_link/www.$TEST_TLD?record_type=AAAA" "1::1"
-curl_get "$gns_link/www.$TEST_TLD?record_type=WRONG_TYPE"
"1.1.1.2.*1::1.*1.1.1.1"
-
-gnunet-namestore -z "$TEST_TLD" -p -a -n www1 -e 1d -V 1.1.1.1 -t A -c
test_gns_lookup.conf
-curl_get "$gns_link/www1.$TEST_TLD" "1.1.1.1"
-
-gnunet-namestore -z "$TEST_TLD" -d -n www1 -c test_gns_lookup.conf
-gnunet-namestore -z "$TEST_TLD" -d -n www -c test_gns_lookup.conf
-
-gnunet-identity -D "$TEST_TLD" -c test_gns_lookup.conf > /dev/null 2>&1
-
-curl_get "$gns_link/www1.$TEST_TLD" "error"
-gnunet-arm -e -c test_gns_lookup.conf
-exit 0
diff --git a/src/rest-plugin/identity/Makefile.am
b/src/rest-plugin/identity/Makefile.am
deleted file mode 100644
index bcad0c2dd..000000000
--- a/src/rest-plugin/identity/Makefile.am
+++ /dev/null
@@ -1,26 +0,0 @@
-# This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include
-
-plugindir = $(libdir)/gnunet
-
-if USE_COVERAGE
- AM_CFLAGS = --coverage -O0
- XLIB = -lgcov
-endif
-
-plugin_LTLIBRARIES = libgnunet_plugin_rest_identity.la
-
-pkgcfgdir= $(pkgdatadir)/config.d/
-
-libexecdir= $(pkglibdir)/libexec/
-
-libgnunet_plugin_rest_identity_la_SOURCES = \
- plugin_rest_identity.c
-libgnunet_plugin_rest_identity_la_LIBADD = \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson $(MHD_LIBS)
-libgnunet_plugin_rest_identity_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_identity_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
diff --git a/src/rest-plugin/identity/meson.build
b/src/rest-plugin/identity/meson.build
deleted file mode 100644
index f459918db..000000000
--- a/src/rest-plugin/identity/meson.build
+++ /dev/null
@@ -1,11 +0,0 @@
-shared_module('gnunet_plugin_rest_identity',
- ['plugin_rest_identity.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetidentity_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-
diff --git a/src/rest-plugin/meson.build b/src/rest-plugin/meson.build
deleted file mode 100644
index 09cd2ad8c..000000000
--- a/src/rest-plugin/meson.build
+++ /dev/null
@@ -1,7 +0,0 @@
-if get_option('monolith') == false
- subdir('rest')
-endif
-subdir('identity')
-subdir('namestore')
-subdir('gns')
-subdir('reclaim')
diff --git a/src/rest-plugin/namestore/Makefile.am
b/src/rest-plugin/namestore/Makefile.am
deleted file mode 100644
index 93da51dbc..000000000
--- a/src/rest-plugin/namestore/Makefile.am
+++ /dev/null
@@ -1,53 +0,0 @@
-# This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include $(POSTGRESQL_CPPFLAGS)
-
-plugindir = $(libdir)/gnunet
-
-pkgcfgdir= $(pkgdatadir)/config.d/
-
-libexecdir= $(pkglibdir)/libexec/
-
-sqldir = $(prefix)/share/gnunet/sql/
-
-if USE_COVERAGE
- AM_CFLAGS = --coverage -O0
- XLIBS = -lgcov
-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 = \
- $(check_PROGRAMS) \
- $(check_SCRIPTS)
-endif
-
-REST_PLUGIN = libgnunet_plugin_rest_namestore.la
-
-plugin_LTLIBRARIES = \
- $(SQLITE_PLUGIN) \
- $(POSTGRES_PLUGIN) \
- $(REST_PLUGIN)
-
-
-libgnunet_plugin_rest_namestore_la_SOURCES = \
- plugin_rest_namestore.c
-libgnunet_plugin_rest_namestore_la_LIBADD = \
- $(top_builddir)/src/service/namestore/libgnunetnamestore.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
- $(top_builddir)/src/lib/json/libgnunetjson.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecordjson.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson $(MHD_LIBS)
-libgnunet_plugin_rest_namestore_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_namestore_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
-
-
-check_SCRIPTS = \
- test_plugin_rest_namestore.sh
-
-EXTRA_DIST = \
- $(check_SCRIPTS)
diff --git a/src/rest-plugin/namestore/meson.build
b/src/rest-plugin/namestore/meson.build
deleted file mode 100644
index f96e7cd44..000000000
--- a/src/rest-plugin/namestore/meson.build
+++ /dev/null
@@ -1,14 +0,0 @@
-shared_module('gnunet_plugin_rest_namestore',
- ['plugin_rest_namestore.c'],
- dependencies: [
- libgnunetrest_dep,
- libgnunetgnsrecordjson_dep,
- libgnunetgnsrecord_dep,
- libgnunetjson_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-
diff --git a/src/rest-plugin/reclaim/Makefile.am
b/src/rest-plugin/reclaim/Makefile.am
deleted file mode 100644
index 7bc305bef..000000000
--- a/src/rest-plugin/reclaim/Makefile.am
+++ /dev/null
@@ -1,81 +0,0 @@
-# This Makefile.am is in the public domain
-AM_CPPFLAGS = -I$(top_srcdir)/src/include
-
- plugindir = $(libdir)/gnunet
-
-if USE_COVERAGE
- AM_CFLAGS = --coverage -O0
- XLIB = -lgcov
-endif
-
-
-REST_PLUGIN = \
- libgnunet_plugin_rest_reclaim.la
-
-if HAVE_JOSE
-REST_PLUGIN += libgnunet_plugin_rest_openid_connect.la
-endif
-
-if HAVE_PABC
- REST_PLUGIN += libgnunet_plugin_rest_pabc.la
-endif
-
-pkgcfgdir= $(pkgdatadir)/config.d/
-
-libexecdir= $(pkglibdir)/libexec/
-
-plugin_LTLIBRARIES = \
- $(REST_PLUGIN)
-
-libgnunet_plugin_rest_reclaim_la_SOURCES = \
- plugin_rest_reclaim.c \
- json_reclaim.h \
- json_reclaim.c
-libgnunet_plugin_rest_reclaim_la_LIBADD = \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
- $(top_builddir)/src/service/reclaim/libgnunetreclaim.la \
- $(top_builddir)/src/lib/json/libgnunetjson.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/service/namestore/libgnunetnamestore.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson $(MHD_LIBS)
-libgnunet_plugin_rest_reclaim_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_reclaim_la_CFLAGS = \
- $(MHD_CFLAGS) $(AM_CFLAGS)
-
-if HAVE_JOSE
-libgnunet_plugin_rest_openid_connect_la_SOURCES = \
- plugin_rest_openid_connect.c \
- oidc_helper.h \
- oidc_helper.c
-libgnunet_plugin_rest_openid_connect_la_LIBADD = \
- $(top_builddir)/src/service/identity/libgnunetidentity.la \
- $(top_builddir)/src/service/reclaim/libgnunetreclaim.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/service/namestore/libgnunetnamestore.la \
- $(top_builddir)/src/service/gns/libgnunetgns.la \
- $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecord.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -ljose $(MHD_LIBS) \
- $(LIBGCRYPT_LIBS)
-libgnunet_plugin_rest_openid_connect_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_openid_connect_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
-endif
-
-if HAVE_PABC
-libgnunet_plugin_rest_pabc_la_SOURCES = \
- plugin_rest_pabc.c \
- $(top_builddir)/src/plugin/reclaim/pabc_helper.c
-libgnunet_plugin_rest_pabc_la_LIBADD = \
- $(top_builddir)/src/service/reclaim/libgnunetreclaim.la \
- $(top_builddir)/src/lib/json/libgnunetjson.la \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) -ljansson -lpabc $(MHD_LIBS)
-libgnunet_plugin_rest_pabc_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_pabc_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
-endif
diff --git a/src/rest-plugin/reclaim/meson.build
b/src/rest-plugin/reclaim/meson.build
deleted file mode 100644
index da4406850..000000000
--- a/src/rest-plugin/reclaim/meson.build
+++ /dev/null
@@ -1,29 +0,0 @@
-shared_module('gnunet_plugin_rest_reclaim',
- ['plugin_rest_reclaim.c', 'json_reclaim.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetidentity_dep,
- libgnunetreclaim_dep,
- libgnunetjson_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-
-shared_module('gnunet_plugin_rest_openid_connect',
- ['plugin_rest_openid_connect.c', 'oidc_helper.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetreclaim_dep,
- libgnunetidentity_dep,
- libgnunetgns_dep,
- libgnunetutil_dep,
- jose_dep,
- gcrypt_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-
-
diff --git a/src/rest-plugin/rest/Makefile.am b/src/rest-plugin/rest/Makefile.am
deleted file mode 100644
index 4f7f834fb..000000000
--- a/src/rest-plugin/rest/Makefile.am
+++ /dev/null
@@ -1,37 +0,0 @@
-# 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 USE_COVERAGE
- AM_CFLAGS = --coverage -O0
- XLIBS = -lgcov
-endif
-
-plugin_LTLIBRARIES = \
- libgnunet_plugin_rest_copying.la \
- libgnunet_plugin_rest_config.la
-
-libgnunet_plugin_rest_copying_la_SOURCES = \
- plugin_rest_copying.c
-libgnunet_plugin_rest_copying_la_LIBADD = \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) $(MHD_LIBS)
-libgnunet_plugin_rest_copying_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_copying_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
-
-libgnunet_plugin_rest_config_la_SOURCES = \
- plugin_rest_config.c
-libgnunet_plugin_rest_config_la_LIBADD = \
- $(top_builddir)/src/service/rest/libgnunetrest.la \
- $(top_builddir)/src/lib/util/libgnunetutil.la $(XLIBS) \
- $(LTLIBINTL) $(MHD_LIBS) -ljansson
-libgnunet_plugin_rest_config_la_LDFLAGS = \
- $(GN_PLUGIN_LDFLAGS)
-libgnunet_plugin_rest_config_la_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
diff --git a/src/rest-plugin/rest/meson.build b/src/rest-plugin/rest/meson.build
deleted file mode 100644
index 0c7219327..000000000
--- a/src/rest-plugin/rest/meson.build
+++ /dev/null
@@ -1,18 +0,0 @@
-shared_module('gnunet_plugin_rest_config',
- ['plugin_rest_config.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
-shared_module('gnunet_plugin_rest_copying',
- ['plugin_rest_copying.c'],
- dependencies: [libgnunetrest_dep,
- libgnunetutil_dep,
- json_dep,
- mhd_dep],
- include_directories: [incdir, configuration_inc],
- install: true,
- install_dir: get_option('libdir') / 'gnunet')
diff --git a/src/service/Makefile.am b/src/service/Makefile.am
index 809f83a0a..041442725 100644
--- a/src/service/Makefile.am
+++ b/src/service/Makefile.am
@@ -13,7 +13,6 @@ SUBDIRS = \
topology \
dns \
identity \
- rest \
datacache \
datastore \
dhtu \
@@ -32,5 +31,6 @@ SUBDIRS = \
exit \
pt \
reclaim \
- messenger
+ messenger \
+ rest
diff --git a/src/service/meson.build b/src/service/meson.build
index 5923fc8a1..34dd997e2 100644
--- a/src/service/meson.build
+++ b/src/service/meson.build
@@ -2,7 +2,6 @@ subdir('util')
subdir('arm')
subdir('statistics')
subdir('testing')
-subdir('rest')
subdir('datacache')
subdir('datastore')
subdir('peerstore')
@@ -31,6 +30,7 @@ subdir('exit')
subdir('pt')
subdir('reclaim')
subdir('messenger')
+subdir('rest')
if not get_option('monolith')
subdir_done()
@@ -44,6 +44,8 @@ libgnunet = library('gnunet',
libgnunetblock_dep,
libgnunetblockgroup_dep,
libgnunetgnsrecord_dep,
+ libgnunetgnsrecordjson_dep,
+ jose_dep,
libgnunetcurl_dep],
c_args: ['-DHAVE_GNUNET_MONOLITH=1'],
include_directories: [incdir, configuration_inc, exitdir])
diff --git a/src/service/rest/Makefile.am b/src/service/rest/Makefile.am
index 401be36f4..072f0a787 100644
--- a/src/service/rest/Makefile.am
+++ b/src/service/rest/Makefile.am
@@ -25,9 +25,25 @@ EXTRA_DIST = \
rest.conf
gnunet_rest_server_SOURCES = \
- gnunet-rest-server.c
+ gnunet-rest-server.c \
+ config_plugin.c \
+ copying_plugin.c \
+ identity_plugin.c \
+ namestore_plugin.c \
+ gns_plugin.c \
+ openid_plugin.c \
+ oidc_helper.c \
+ reclaim_plugin.c json_reclaim.c
gnunet_rest_server_LDADD = \
$(top_builddir)/src/lib/util/libgnunetutil.la \
+ $(top_builddir)/src/lib/json/libgnunetjson.la \
+ $(top_builddir)/src/lib/gnsrecord/libgnunetgnsrecordjson.la \
+ $(top_builddir)/src/service/identity/libgnunetidentity.la \
+ $(top_builddir)/src/service/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/service/gns/libgnunetgns.la \
+ $(top_builddir)/src/service/reclaim/libgnunetreclaim.la \
+ libgnunetrest.la \
+ -ljose \
$(GN_LIBINTL) $(MHD_LIBS)
gnunet_rest_server_CFLAGS = $(MHD_CFLAGS) $(AM_CFLAGS)
diff --git a/src/rest-plugin/rest/plugin_rest_config.c
b/src/service/rest/config_plugin.c
similarity index 91%
rename from src/rest-plugin/rest/plugin_rest_config.c
rename to src/service/rest/config_plugin.c
index 826188702..fd0ac011a 100644
--- a/src/rest-plugin/rest/plugin_rest_config.c
+++ b/src/service/rest/config_plugin.c
@@ -40,7 +40,7 @@ struct Plugin
const struct GNUNET_CONFIGURATION_Handle *cfg;
};
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *config_cfg;
struct RequestHandle
{
@@ -78,6 +78,7 @@ struct RequestHandle
* The URL
*/
char *url;
+
};
/**
@@ -184,13 +185,13 @@ get_cont (struct GNUNET_REST_RequestHandle *con_handle,
if (strlen (GNUNET_REST_API_NS_CONFIG) == strlen (handle->url))
{
result = json_object ();
- GNUNET_CONFIGURATION_iterate (cfg, &add_sections, result);
+ GNUNET_CONFIGURATION_iterate (config_cfg, &add_sections, result);
}
else
{
result = json_object ();
section = &handle->url[strlen (GNUNET_REST_API_NS_CONFIG) + 1];
- GNUNET_CONFIGURATION_iterate_section_values (cfg,
+ GNUNET_CONFIGURATION_iterate_section_values (config_cfg,
section,
&add_section_contents,
result);
@@ -243,7 +244,7 @@ set_cont (struct GNUNET_REST_RequestHandle *con_handle,
{
struct RequestHandle *handle = cls;
char term_data[handle->rest_handle->data_size + 1];
- struct GNUNET_CONFIGURATION_Handle *out = GNUNET_CONFIGURATION_dup (cfg);
+ struct GNUNET_CONFIGURATION_Handle *out = GNUNET_CONFIGURATION_dup
(config_cfg);
json_error_t err;
json_t *data_json;
@@ -330,7 +331,7 @@ set_cont (struct GNUNET_REST_RequestHandle *con_handle,
cfg_fn = GNUNET_strdup (GNUNET_OS_project_data_get ()->user_config_file);
GNUNET_CONFIGURATION_write (out, cfg_fn);
- cfg = out;
+ config_cfg = out;
handle->proc (handle->proc_cls,
GNUNET_REST_create_response (NULL),
MHD_HTTP_OK);
@@ -361,19 +362,9 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle,
}
-/**
- * Function processing the REST call
- *
- * @param method HTTP method
- * @param url URL of the HTTP request
- * @param data body of the HTTP request (optional)
- * @param data_size length of the body
- * @param proc callback function for the result
- * @param proc_cls closure for @a proc
- * @return #GNUNET_OK if request accepted
- */
-static enum GNUNET_GenericReturnValue
-rest_config_process_request (struct GNUNET_REST_RequestHandle *conndata_handle,
+enum GNUNET_GenericReturnValue
+REST_config_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *conndata_handle,
GNUNET_REST_ResultProcessor proc,
void *proc_cls)
{
@@ -383,6 +374,7 @@ rest_config_process_request (struct
GNUNET_REST_RequestHandle *conndata_handle,
{ MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_CONFIG, &options_cont },
GNUNET_REST_HANDLER_END
};
+ (void) plugin;
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
struct GNUNET_REST_RequestHandlerError err;
@@ -404,6 +396,19 @@ rest_config_process_request (struct
GNUNET_REST_RequestHandle *conndata_handle,
return GNUNET_YES;
}
+void
+REST_config_done (struct GNUNET_REST_Plugin *api)
+{
+ struct Plugin *plugin;
+
+ while (NULL != requests_head)
+ cleanup_handle (requests_head);
+ plugin = api->cls;
+ plugin->cfg = NULL;
+ GNUNET_free (api);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONFIG REST plugin is finished\n");
+}
+
/**
* Entry point for the plugin.
@@ -412,44 +417,22 @@ rest_config_process_request (struct
GNUNET_REST_RequestHandle *conndata_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_config_init (void *cls)
+REST_config_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
- cfg = cls;
+ config_cfg = c;
struct GNUNET_REST_Plugin *api;
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = c;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_CONFIG;
- api->process_request = &rest_config_process_request;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("CONFIG REST API initialized\n"));
return api;
}
-/**
- * Exit point from the plugin.
- *
- * @param cls the plugin context (as returned by "init")
- * @return always NULL
- */
-void *
-libgnunet_plugin_rest_config_done (void *cls)
-{
- struct GNUNET_REST_Plugin *api = cls;
- struct Plugin *plugin;
-
- while (NULL != requests_head)
- cleanup_handle (requests_head);
- plugin = api->cls;
- plugin->cfg = NULL;
- GNUNET_free (api);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "CONFIG REST plugin is finished\n");
- return NULL;
-}
-
/* end of plugin_rest_config.c */
diff --git a/src/service/rest/config_plugin.h b/src/service/rest/config_plugin.h
new file mode 100644
index 000000000..c959a94f2
--- /dev/null
+++ b/src/service/rest/config_plugin.h
@@ -0,0 +1,37 @@
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_rest_plugin.h"
+
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_config_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ */
+void *
+REST_config_init (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_config_done (struct GNUNET_REST_Plugin *api);
+
diff --git a/src/rest-plugin/rest/plugin_rest_copying.c
b/src/service/rest/copying_plugin.c
similarity index 91%
rename from src/rest-plugin/rest/plugin_rest_copying.c
rename to src/service/rest/copying_plugin.c
index 52783a81a..d907f6729 100644
--- a/src/rest-plugin/rest/plugin_rest_copying.c
+++ b/src/service/rest/copying_plugin.c
@@ -31,7 +31,7 @@
#define GNUNET_REST_API_NS_COPYING "/copying"
#define GNUNET_REST_COPYING_TEXT \
- "GNU Affero General Public License version 3 or later. See also:
<http://www.gnu.org/licenses/>"
+ "GNU Affero General Public License version 3 or later. See also:
<http://www.gnu.org/licenses/>"
/**
* @brief struct returned by the initialization function of the plugin
@@ -41,8 +41,6 @@ struct Plugin
const struct GNUNET_CONFIGURATION_Handle *cfg;
};
-const struct GNUNET_CONFIGURATION_Handle *cfg;
-
struct RequestHandle
{
/**
@@ -159,8 +157,9 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle,
* @param proc_cls closure for @a proc
* @return #GNUNET_OK if request accepted
*/
-static enum GNUNET_GenericReturnValue
-rest_copying_process_request (struct GNUNET_REST_RequestHandle
*conndata_handle,
+enum GNUNET_GenericReturnValue
+REST_copying_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle
*conndata_handle,
GNUNET_REST_ResultProcessor proc,
void *proc_cls)
{
@@ -191,22 +190,20 @@ rest_copying_process_request (struct
GNUNET_REST_RequestHandle *conndata_handle,
* @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
* @return NULL on error, otherwise the plugin context
*/
-void *
-libgnunet_plugin_rest_copying_init (void *cls)
+void*
+REST_copying_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
- cfg = cls;
struct GNUNET_REST_Plugin *api;
if (NULL != plugin.cfg)
return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = c;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_COPYING;
- api->process_request = &rest_copying_process_request;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_ ("COPYING REST API initialized\n"));
return api;
@@ -219,10 +216,9 @@ libgnunet_plugin_rest_copying_init (void *cls)
* @param cls the plugin context (as returned by "init")
* @return always NULL
*/
-void *
-libgnunet_plugin_rest_copying_done (void *cls)
+void
+REST_copying_done (struct GNUNET_REST_Plugin *api)
{
- struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
while (NULL != requests_head)
@@ -231,7 +227,6 @@ libgnunet_plugin_rest_copying_done (void *cls)
GNUNET_free (api);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"COPYING REST plugin is finished\n");
- return NULL;
}
diff --git a/src/service/rest/copying_plugin.h
b/src/service/rest/copying_plugin.h
new file mode 100644
index 000000000..4ba1a2e36
--- /dev/null
+++ b/src/service/rest/copying_plugin.h
@@ -0,0 +1,36 @@
+#include "gnunet_rest_plugin.h"
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_copying_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle
*conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
+ * @return NULL on error, otherwise the plugin context
+ */
+void*
+REST_copying_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_copying_done (struct GNUNET_REST_Plugin *api);
diff --git a/src/rest-plugin/gns/plugin_rest_gns.c
b/src/service/rest/gns_plugin.c
similarity index 95%
rename from src/rest-plugin/gns/plugin_rest_gns.c
rename to src/service/rest/gns_plugin.c
index 659b77493..0ea89d0cd 100644
--- a/src/rest-plugin/gns/plugin_rest_gns.c
+++ b/src/service/rest/gns_plugin.c
@@ -56,7 +56,7 @@
/**
* The configuration handle
*/
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *gns_cfg;
/**
* HTTP methods allows for this plugin
@@ -221,7 +221,7 @@ do_error (void *cls)
handle->proc (handle->proc_cls, resp, handle->response_code);
json_decref (json_error);
GNUNET_free (response);
- cleanup_handle(handle);
+ cleanup_handle (handle);
}
@@ -265,7 +265,8 @@ handle_gns_response (void *cls,
return;
}
- result_obj = GNUNET_GNSRECORD_JSON_from_gnsrecord (handle->name, rd,
rd_count);
+ result_obj = GNUNET_GNSRECORD_JSON_from_gnsrecord (handle->name, rd,
+ rd_count);
result = json_dumps (result_obj, 0);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
@@ -381,10 +382,11 @@ options_cont (struct GNUNET_REST_RequestHandle
*con_handle,
* @param proc_cls closure for callback function
* @return GNUNET_OK if request accepted
*/
-static enum GNUNET_GenericReturnValue
-rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls)
+enum GNUNET_GenericReturnValue
+REST_gns_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *rest_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
struct GNUNET_REST_RequestHandlerError err;
@@ -426,18 +428,17 @@ rest_process_request (struct GNUNET_REST_RequestHandle
*rest_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_gns_init (void *cls)
+REST_gns_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
struct GNUNET_REST_Plugin *api;
- cfg = cls;
+ gns_cfg = c;
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = gns_cfg;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_GNS;
- api->process_request = &rest_process_request;
GNUNET_asprintf (&allow_methods,
"%s, %s, %s, %s, %s",
MHD_HTTP_METHOD_GET,
@@ -445,7 +446,7 @@ libgnunet_plugin_rest_gns_init (void *cls)
MHD_HTTP_METHOD_PUT,
MHD_HTTP_METHOD_DELETE,
MHD_HTTP_METHOD_OPTIONS);
- gns = GNUNET_GNS_connect (cfg);
+ gns = GNUNET_GNS_connect (gns_cfg);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Gns REST API initialized\n"));
return api;
@@ -459,7 +460,7 @@ libgnunet_plugin_rest_gns_init (void *cls)
* @return always NULL
*/
void *
-libgnunet_plugin_rest_gns_done (void *cls)
+REST_gns_done (void *cls)
{
struct GNUNET_REST_Plugin *api = cls;
struct RequestHandle *request;
diff --git a/src/service/rest/gns_plugin.h b/src/service/rest/gns_plugin.h
new file mode 100644
index 000000000..13878c139
--- /dev/null
+++ b/src/service/rest/gns_plugin.h
@@ -0,0 +1,36 @@
+#include "gnunet_rest_plugin.h"
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_gns_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
+ * @return NULL on error, otherwise the plugin context
+ */
+void*
+REST_gns_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_gns_done (struct GNUNET_REST_Plugin *api);
diff --git a/src/service/rest/gnunet-rest-server.c
b/src/service/rest/gnunet-rest-server.c
index 5163c2271..59b997efd 100644
--- a/src/service/rest/gnunet-rest-server.c
+++ b/src/service/rest/gnunet-rest-server.c
@@ -29,6 +29,14 @@
#include "gnunet_rest_plugin.h"
#include "gnunet_mhd_compat.h"
+#include "config_plugin.h"
+#include "copying_plugin.h"
+#include "identity_plugin.h"
+#include "namestore_plugin.h"
+#include "gns_plugin.h"
+#include "openid_plugin.h"
+#include "reclaim_plugin.h"
+
/**
* Default Socks5 listen port.
*/
@@ -54,7 +62,7 @@
* After how long do we clean up unused MHD SSL/TLS instances?
*/
#define MHD_CACHE_TIMEOUT \
- GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
#define GN_REST_STATE_INIT 0
#define GN_REST_STATE_PROCESSING 1
@@ -178,7 +186,12 @@ struct PluginListEntry
/**
* The plugin
*/
- struct GNUNET_REST_Plugin *plugin;
+ void *plugin;
+
+ /**
+ * Request function
+ */
+ GNUNET_REST_ProcessingFunction process_request;
};
/**
@@ -240,6 +253,19 @@ static struct AcceptedRequest *req_list_head;
*/
static struct AcceptedRequest *req_list_tail;
+
+/**
+ * plugins
+ */
+
+struct GNUNET_REST_Plugin *config_plugin;
+struct GNUNET_REST_Plugin *copying_plugin;
+struct GNUNET_REST_Plugin *identity_plugin;
+struct GNUNET_REST_Plugin *namestore_plugin;
+struct GNUNET_REST_Plugin *gns_plugin;
+struct GNUNET_REST_Plugin *openid_plugin;
+struct GNUNET_REST_Plugin *reclaim_plugin;
+
/* ************************* Global helpers ********************* */
@@ -294,6 +320,7 @@ cleanup_url_map (void *cls, const struct GNUNET_HashCode
*key, void *value)
return GNUNET_YES;
}
+
static void
cleanup_handle (struct MhdConnectionHandle *handle)
{
@@ -323,6 +350,7 @@ cleanup_handle (struct MhdConnectionHandle *handle)
GNUNET_free (handle);
}
+
static void
cleanup_ar (struct AcceptedRequest *ar)
{
@@ -334,7 +362,8 @@ cleanup_ar (struct AcceptedRequest *ar)
{
GNUNET_NETWORK_socket_free_memory_only_ (ar->sock);
}
- else {
+ else
+ {
GNUNET_NETWORK_socket_close (ar->sock);
}
ar->sock = NULL;
@@ -344,6 +373,7 @@ cleanup_ar (struct AcceptedRequest *ar)
GNUNET_free (ar);
}
+
static int
header_iterator (void *cls,
enum MHD_ValueKind kind,
@@ -561,9 +591,10 @@ create_response (void *cls,
con_handle->state = GN_REST_STATE_PROCESSING;
for (ple = plugins_head; NULL != ple; ple = ple->next)
{
- if (GNUNET_YES == ple->plugin->process_request (rest_conndata_handle,
- &plugin_callback,
- con_handle))
+ if (GNUNET_YES == ple->process_request (ple->plugin,
+ rest_conndata_handle,
+ &plugin_callback,
+ con_handle))
break; /* Request handled */
}
if (NULL == ple)
@@ -603,8 +634,8 @@ create_response (void *cls,
strlen ("chrome-extension://"))))
{
GNUNET_assert (MHD_NO != MHD_add_response_header (con_handle->response,
- MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
- origin));
+
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
+ origin));
}
}
if (NULL != allow_origins)
@@ -615,9 +646,10 @@ create_response (void *cls,
{
if (0 == strncmp (allow_origin, origin, strlen (allow_origin)))
{
- GNUNET_assert (MHD_NO != MHD_add_response_header
(con_handle->response,
- MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
- allow_origin));
+ GNUNET_assert (MHD_NO != MHD_add_response_header (
+ con_handle->response,
+ MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
+ allow_origin));
break;
}
allow_origin = strtok (NULL, ",");
@@ -628,14 +660,14 @@ create_response (void *cls,
if (NULL != allow_credentials)
{
GNUNET_assert (MHD_NO != MHD_add_response_header (con_handle->response,
- "Access-Control-Allow-Credentials",
- allow_credentials));
+
"Access-Control-Allow-Credentials",
+ allow_credentials));
}
if (NULL != allow_headers)
{
GNUNET_assert (MHD_NO != MHD_add_response_header (con_handle->response,
- "Access-Control-Allow-Headers",
- allow_headers));
+
"Access-Control-Allow-Headers",
+ allow_headers));
}
run_mhd_now ();
{
@@ -757,6 +789,7 @@ schedule_httpd ()
GNUNET_NETWORK_fdset_destroy (wws);
}
+
/**
* Function called when MHD first processes an incoming connection.
* Gives us the respective URI information.
@@ -791,7 +824,6 @@ mhd_log_callback (void *cls,
}
-
/**
* Function called when MHD decides that we are done with a connection.
*
@@ -823,6 +855,7 @@ mhd_completed_cb (void *cls,
*con_cls = NULL;
}
+
/**
* Function called when MHD connection is opened or closed.
*
@@ -886,7 +919,6 @@ mhd_connection_cb (void *cls,
}
-
/**
* Task run whenever HTTP server operations are pending.
*
@@ -977,10 +1009,15 @@ do_shutdown (void *cls)
GNUNET_CONTAINER_DLL_remove (plugins_head,
plugins_tail,
ple);
- GNUNET_PLUGIN_unload (ple->libname, ple->plugin);
GNUNET_free (ple->libname);
GNUNET_free (ple);
}
+ REST_config_done (config_plugin);
+ REST_copying_done (copying_plugin);
+ REST_identity_done (identity_plugin);
+ REST_gns_done (gns_plugin);
+ REST_openid_done (openid_plugin);
+ REST_reclaim_done (reclaim_plugin);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down...\n");
kill_httpd ();
GNUNET_free (allow_credentials);
@@ -1065,28 +1102,30 @@ bind_v6 ()
* @param libname the name of the library loaded
* @param lib_ret the object returned by the plugin initializer
*/
-static void
-load_plugin (void *cls, const char *libname, void *lib_ret)
+static enum GNUNET_GenericReturnValue
+setup_plugin (const char *name,
+ GNUNET_REST_ProcessingFunction proc,
+ void *plugin_cls)
{
- struct GNUNET_REST_Plugin *plugin = lib_ret;
struct PluginListEntry *ple;
- if (NULL == lib_ret)
+ if (NULL == plugin_cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Could not load plugin `%s'\n",
- libname);
- return;
+ "Could not load plugin\n");
+ return GNUNET_SYSERR;
}
- GNUNET_assert (1 < strlen (plugin->name));
- GNUNET_assert ('/' == *plugin->name);
+ GNUNET_assert (1 < strlen (name));
+ GNUNET_assert ('/' == *name);
ple = GNUNET_new (struct PluginListEntry);
- ple->libname = GNUNET_strdup (libname);
- ple->plugin = plugin;
+ ple->libname = GNUNET_strdup (name);
+ ple->plugin = plugin_cls;
+ ple->process_request = proc;
GNUNET_CONTAINER_DLL_insert (plugins_head,
plugins_tail,
ple);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded plugin `%s'\n", libname);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loaded plugin `%s'\n", name);
+ return GNUNET_OK;
}
@@ -1201,7 +1240,8 @@ run (void *cls,
memset (basic_auth_secret_tmp, 0, 16);
if (GNUNET_SYSERR == GNUNET_DISK_fn_read (basic_auth_file,
basic_auth_secret_tmp,
- sizeof (basic_auth_secret_tmp)
- 1))
+ sizeof (basic_auth_secret_tmp)
+ - 1))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unable to read basic auth secret file.\n");
@@ -1330,12 +1370,43 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
-/* Load plugins */
- GNUNET_PLUGIN_load_all_in_context (GNUNET_OS_project_data_default (),
- "libgnunet_plugin_rest",
- (void *) cfg,
- &load_plugin,
- NULL);
+ /* Load plugins */
+ // FIXME: Use per-plugin rest plugin structs
+ struct GNUNET_REST_Plugin *config_plugin = REST_config_init (cfg);
+ if (GNUNET_OK != setup_plugin (config_plugin->name,
&REST_config_process_request, config_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ struct GNUNET_REST_Plugin *copying_plugin = REST_copying_init (cfg);
+ if (GNUNET_OK != setup_plugin (copying_plugin->name,
&REST_copying_process_request, copying_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ struct GNUNET_REST_Plugin *identity_plugin = REST_identity_init (cfg);
+ if (GNUNET_OK != setup_plugin (identity_plugin->name,
&REST_identity_process_request, identity_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ struct GNUNET_REST_Plugin *namestore_plugin = REST_namestore_init (cfg);
+ if (GNUNET_OK != setup_plugin (namestore_plugin->name,
&REST_namestore_process_request, namestore_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ struct GNUNET_REST_Plugin *gns_plugin = REST_gns_init (cfg);
+ if (GNUNET_OK != setup_plugin (gns_plugin->name, &REST_gns_process_request,
gns_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ struct GNUNET_REST_Plugin *openid_plugin = REST_openid_init (cfg);
+ if (GNUNET_OK != setup_plugin (openid_plugin->name,
&REST_openid_process_request, openid_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
+ struct GNUNET_REST_Plugin *reclaim_plugin = REST_reclaim_init (cfg);
+ if (GNUNET_OK != setup_plugin (reclaim_plugin->name,
&REST_reclaim_process_request, reclaim_plugin))
+ {
+ GNUNET_SCHEDULER_shutdown ();
+ }
GNUNET_SCHEDULER_add_shutdown (&do_shutdown, NULL);
}
diff --git a/src/rest-plugin/identity/plugin_rest_identity.c
b/src/service/rest/identity_plugin.c
similarity index 97%
rename from src/rest-plugin/identity/plugin_rest_identity.c
rename to src/service/rest/identity_plugin.c
index e7b7f8a9c..f6c9dd792 100644
--- a/src/rest-plugin/identity/plugin_rest_identity.c
+++ b/src/service/rest/identity_plugin.c
@@ -106,7 +106,7 @@
/**
* The configuration handle
*/
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *id_cfg;
/**
* HTTP methods allows for this plugin
@@ -921,6 +921,7 @@ ego_delete_name (struct GNUNET_REST_RequestHandle
*con_handle,
handle);
}
+
struct ego_sign_data_cls
{
void *data;
@@ -952,10 +953,10 @@ ego_sign_data_cb (void *cls, struct GNUNET_IDENTITY_Ego
*ego)
return;
}
- if ( GNUNET_OK != GNUNET_CRYPTO_eddsa_sign_raw (&(ego->pk.eddsa_key),
- (void *) data,
- strlen ( (char*) data),
- &sig))
+ if (GNUNET_OK != GNUNET_CRYPTO_eddsa_sign_raw (&(ego->pk.eddsa_key),
+ (void *) data,
+ strlen ( (char*) data),
+ &sig))
{
handle->ec = GNUNET_EC_UNKNOWN;
GNUNET_SCHEDULER_add_now (&do_error, handle);
@@ -980,6 +981,7 @@ ego_sign_data_cb (void *cls, struct GNUNET_IDENTITY_Ego
*ego)
GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
}
+
/**
*
* @param con_handle the connection handle
@@ -1030,12 +1032,13 @@ ego_sign_data (struct GNUNET_REST_RequestHandle
*con_handle,
cls2->data = (void *) GNUNET_strdup (data);
cls2->handle = handle;
- GNUNET_IDENTITY_ego_lookup (cfg,
+ GNUNET_IDENTITY_ego_lookup (id_cfg,
username,
ego_sign_data_cb,
cls2);
}
+
/**
* Respond to OPTIONS request
*
@@ -1155,10 +1158,11 @@ list_ego (void *cls,
* @param proc_cls closure for callback function
* @return GNUNET_OK if request accepted
*/
-static enum GNUNET_GenericReturnValue
-rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls)
+enum GNUNET_GenericReturnValue
+REST_identity_process_request (void* plugin,
+ struct GNUNET_REST_RequestHandle *rest_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
struct GNUNET_REST_RequestHandlerError err;
@@ -1218,20 +1222,19 @@ rest_process_request (struct GNUNET_REST_RequestHandle
*rest_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_identity_init (void *cls)
+REST_identity_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
struct GNUNET_REST_Plugin *api;
- cfg = cls;
+ id_cfg = c;
if (NULL != plugin.cfg)
return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = c;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_IDENTITY;
- api->process_request = &rest_process_request;
GNUNET_asprintf (&allow_methods,
"%s, %s, %s, %s, %s",
MHD_HTTP_METHOD_GET,
@@ -1240,7 +1243,7 @@ libgnunet_plugin_rest_identity_init (void *cls)
MHD_HTTP_METHOD_DELETE,
MHD_HTTP_METHOD_OPTIONS);
state = ID_REST_STATE_INIT;
- identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL);
+ identity_handle = GNUNET_IDENTITY_connect (id_cfg, &list_ego, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ ("Identity REST API initialized\n"));
return api;
@@ -1253,10 +1256,9 @@ libgnunet_plugin_rest_identity_init (void *cls)
* @param cls the plugin context (as returned by "init")
* @return always NULL
*/
-void *
-libgnunet_plugin_rest_identity_done (void *cls)
+void
+REST_identity_done (struct GNUNET_REST_Plugin *api)
{
- struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
struct EgoEntry *ego_entry;
struct EgoEntry *ego_tmp;
@@ -1279,7 +1281,6 @@ libgnunet_plugin_rest_identity_done (void *cls)
GNUNET_free (allow_methods);
GNUNET_free (api);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Identity REST plugin is finished\n");
- return NULL;
}
diff --git a/src/service/rest/identity_plugin.h
b/src/service/rest/identity_plugin.h
new file mode 100644
index 000000000..0886156c1
--- /dev/null
+++ b/src/service/rest/identity_plugin.h
@@ -0,0 +1,36 @@
+#include "gnunet_rest_plugin.h"
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_identity_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle
*conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
+ * @return NULL on error, otherwise the plugin context
+ */
+void*
+REST_identity_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_identity_done (struct GNUNET_REST_Plugin *api);
diff --git a/src/rest-plugin/reclaim/json_reclaim.c
b/src/service/rest/json_reclaim.c
similarity index 100%
rename from src/rest-plugin/reclaim/json_reclaim.c
rename to src/service/rest/json_reclaim.c
diff --git a/src/rest-plugin/reclaim/json_reclaim.h
b/src/service/rest/json_reclaim.h
similarity index 100%
rename from src/rest-plugin/reclaim/json_reclaim.h
rename to src/service/rest/json_reclaim.h
diff --git a/src/service/rest/meson.build b/src/service/rest/meson.build
index 316724fdb..347cbb852 100644
--- a/src/service/rest/meson.build
+++ b/src/service/rest/meson.build
@@ -1,6 +1,16 @@
libgnunetrest_src = ['rest.c']
-gnunetservicerest_src = ['gnunet-rest-server.c']
+gnunetservicerest_src = ['gnunet-rest-server.c',
+ 'config_plugin.c',
+ 'copying_plugin.c',
+ 'identity_plugin.c',
+ 'namestore_plugin.c',
+ 'gns_plugin.c',
+ 'openid_plugin.c',
+ 'oidc_helper.c',
+ 'json_reclaim.c',
+ 'reclaim_plugin.c',
+ ]
configure_file(input : 'rest.conf',
output : 'rest.conf',
@@ -30,7 +40,19 @@ libgnunetrest_dep = declare_dependency(link_with :
libgnunetrest)
executable ('gnunet-rest-server',
gnunetservicerest_src,
- dependencies: [libgnunetrest_dep, libgnunetutil_dep, mhd_dep],
+ dependencies: [libgnunetrest_dep,
+ libgnunetutil_dep,
+ libgnunetidentity_dep,
+ libgnunetgns_dep,
+ libgnunetreclaim_dep,
+ libgnunetnamestore_dep,
+ libgnunetjson_dep,
+ libgnunetgnsrecord_dep,
+ libgnunetgnsrecordjson_dep,
+ json_dep,
+ jose_dep,
+ gcrypt_dep,
+ mhd_dep],
include_directories: [incdir, configuration_inc],
install: true,
install_dir: get_option('libdir') / 'gnunet' / 'libexec')
diff --git a/src/rest-plugin/namestore/plugin_rest_namestore.c
b/src/service/rest/namestore_plugin.c
similarity index 98%
rename from src/rest-plugin/namestore/plugin_rest_namestore.c
rename to src/service/rest/namestore_plugin.c
index 31e78e6dd..8c5b8b824 100644
--- a/src/rest-plugin/namestore/plugin_rest_namestore.c
+++ b/src/service/rest/namestore_plugin.c
@@ -57,7 +57,7 @@
/**
* The configuration handle
*/
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *ns_cfg;
/**
* HTTP methods allows for this plugin
@@ -333,7 +333,7 @@ do_error (void *cls)
struct MHD_Response *resp;
json_t *json_error = json_object ();
char *response;
- const char* emsg;
+ const char*emsg;
int response_code;
emsg = GNUNET_ErrorCode_get_hint (handle->ec);
@@ -788,6 +788,7 @@ import_next_cb (void *cls, enum GNUNET_ErrorCode ec)
handle->rd_set_pos += sent_rds;
}
+
static void
bulk_tx_start (void *cls, enum GNUNET_ErrorCode ec)
{
@@ -920,7 +921,7 @@ namestore_import (struct GNUNET_REST_RequestHandle
*con_handle,
handle->zone_pkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
// We need a per-client connection for a transactional bulk import
- handle->nc = GNUNET_NAMESTORE_connect (cfg);
+ handle->nc = GNUNET_NAMESTORE_connect (ns_cfg);
if (NULL == handle->nc)
{
handle->ec = GNUNET_EC_NAMESTORE_UNKNOWN;
@@ -932,6 +933,7 @@ namestore_import (struct GNUNET_REST_RequestHandle
*con_handle,
handle);
}
+
/**
* Handle namestore POST/PUT request
*
@@ -1238,10 +1240,11 @@ list_ego (void *cls,
* @param proc_cls closure for callback function
* @return GNUNET_OK if request accepted
*/
-static enum GNUNET_GenericReturnValue
-rest_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls)
+enum GNUNET_GenericReturnValue
+REST_namestore_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *rest_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
struct GNUNET_REST_RequestHandlerError err;
@@ -1291,20 +1294,19 @@ rest_process_request (struct GNUNET_REST_RequestHandle
*rest_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_namestore_init (void *cls)
+REST_namestore_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
struct GNUNET_REST_Plugin *api;
- cfg = cls;
+ ns_cfg = c;
if (NULL != plugin.cfg)
return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = c;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_NAMESTORE;
- api->process_request = &rest_process_request;
state = ID_REST_STATE_INIT;
GNUNET_asprintf (&allow_methods,
"%s, %s, %s, %s, %s",
@@ -1313,8 +1315,8 @@ libgnunet_plugin_rest_namestore_init (void *cls)
MHD_HTTP_METHOD_PUT,
MHD_HTTP_METHOD_DELETE,
MHD_HTTP_METHOD_OPTIONS);
- ns_handle = GNUNET_NAMESTORE_connect (cfg);
- identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL);
+ ns_handle = GNUNET_NAMESTORE_connect (ns_cfg);
+ identity_handle = GNUNET_IDENTITY_connect (ns_cfg, &list_ego, NULL);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _ (
"Namestore REST API initialized\n"));
@@ -1328,10 +1330,9 @@ libgnunet_plugin_rest_namestore_init (void *cls)
* @param cls the plugin context (as returned by "init")
* @return always NULL
*/
-void *
-libgnunet_plugin_rest_namestore_done (void *cls)
+void
+REST_namestore_done (struct GNUNET_REST_Plugin *api)
{
- struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
struct RequestHandle *request;
struct EgoEntry *ego_entry;
@@ -1357,7 +1358,6 @@ libgnunet_plugin_rest_namestore_done (void *cls)
GNUNET_free (allow_methods);
GNUNET_free (api);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Namestore REST plugin is finished\n");
- return NULL;
}
diff --git a/src/service/rest/namestore_plugin.h
b/src/service/rest/namestore_plugin.h
new file mode 100644
index 000000000..2bdf77546
--- /dev/null
+++ b/src/service/rest/namestore_plugin.h
@@ -0,0 +1,37 @@
+#include "gnunet_rest_plugin.h"
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_namestore_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *
+ conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
+ * @return NULL on error, otherwise the plugin context
+ */
+void*
+REST_namestore_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_namestore_done (struct GNUNET_REST_Plugin *api);
diff --git a/src/rest-plugin/reclaim/oidc_helper.c
b/src/service/rest/oidc_helper.c
similarity index 100%
rename from src/rest-plugin/reclaim/oidc_helper.c
rename to src/service/rest/oidc_helper.c
diff --git a/src/rest-plugin/reclaim/oidc_helper.h
b/src/service/rest/oidc_helper.h
similarity index 100%
rename from src/rest-plugin/reclaim/oidc_helper.h
rename to src/service/rest/oidc_helper.h
diff --git a/src/rest-plugin/reclaim/plugin_rest_openid_connect.c
b/src/service/rest/openid_plugin.c
similarity index 98%
rename from src/rest-plugin/reclaim/plugin_rest_openid_connect.c
rename to src/service/rest/openid_plugin.c
index d0aee043e..a4f082d2a 100644
--- a/src/rest-plugin/reclaim/plugin_rest_openid_connect.c
+++ b/src/service/rest/openid_plugin.c
@@ -242,7 +242,7 @@
* How long to wait for a consume in userinfo endpoint
*/
#define CONSUME_TIMEOUT GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_SECONDS,2)
+ GNUNET_TIME_UNIT_SECONDS,2)
/**
* OIDC ignored parameter array
@@ -268,7 +268,7 @@ struct GNUNET_CONTAINER_MultiHashMap *OIDC_cookie_jar_map;
/**
* The configuration handle
*/
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *oid_cfg;
/**
* HTTP methods allows for this plugin
@@ -905,6 +905,7 @@ read_jwk_from_file (const char *filename)
return jwk;
}
+
/**
* @brief Write the JWK to file. If unsuccessful emit warning
*
@@ -927,6 +928,7 @@ write_jwk_to_file (const char *filename,
return GNUNET_OK;
}
+
/**
* @brief Generate a new RSA JSON Web Key
*
@@ -942,6 +944,7 @@ generate_jwk ()
return jwk;
}
+
/**
* Return the path to the oidc directory path
*
@@ -954,7 +957,7 @@ get_oidc_dir_path (void *cls)
struct RequestHandle *handle = cls;
// Read OIDC directory from config
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg,
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (oid_cfg,
"reclaim-rest-plugin",
"oidc_dir",
&oidc_directory))
@@ -970,6 +973,7 @@ get_oidc_dir_path (void *cls)
return oidc_directory;
}
+
/**
* Return the path to the RSA JWK key file
*
@@ -1004,7 +1008,7 @@ login_redirect (void *cls)
struct GNUNET_Buffer buf = { 0 };
struct RequestHandle *handle = cls;
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (oid_cfg,
"reclaim-rest-plugin",
"address",
&login_base_url))
@@ -1451,8 +1455,8 @@ code_redirect (void *cls)
{
if (GNUNET_OK !=
GNUNET_CRYPTO_public_key_from_string (handle->oidc
- ->login_identity,
- &pubkey))
+ ->login_identity,
+ &pubkey))
{
handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_INVALID_COOKIE);
handle->edesc =
@@ -1833,7 +1837,7 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
if (GNUNET_OK !=
GNUNET_CRYPTO_public_key_from_string (handle->oidc->client_id,
- &handle->oidc->client_pkey))
+ &handle->oidc->client_pkey))
{
handle->emsg = GNUNET_strdup (OIDC_ERROR_KEY_UNAUTHORIZED_CLIENT);
handle->edesc = GNUNET_strdup ("The client is not authorized to request an
"
@@ -1856,7 +1860,8 @@ authorize_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
}
}
if (NULL == handle->tld)
- GNUNET_CONFIGURATION_iterate_section_values (cfg, "gns", tld_iter, handle);
+ GNUNET_CONFIGURATION_iterate_section_values (oid_cfg, "gns", tld_iter,
+ handle);
if (NULL == handle->tld)
handle->tld = GNUNET_strdup (handle->oidc->client_id);
GNUNET_SCHEDULER_add_now (&build_authz_response, handle);
@@ -2085,7 +2090,7 @@ check_authorization (struct RequestHandle *handle,
}
// check client password
- if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (oid_cfg,
"reclaim-rest-plugin",
"OIDC_CLIENT_HMAC_SECRET",
&expected_pass))
@@ -2277,7 +2282,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
GNUNET_free (code_verifier);
// create jwt
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg,
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (oid_cfg,
"reclaim-rest-plugin",
"expiration_time",
&expiration_time))
@@ -2295,7 +2300,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
}
// Check if HMAC or RSA should be used
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (oid_cfg,
"reclaim-rest-plugin",
"oidc_json_web_algorithm",
&jwa))
@@ -2306,7 +2311,7 @@ token_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
jwa = JWT_ALG_VALUE_RSA;
}
- if ( ! strcmp (jwa, JWT_ALG_VALUE_RSA))
+ if (! strcmp (jwa, JWT_ALG_VALUE_RSA))
{
// Replace for now
oidc_jwk_path = get_oidc_jwk_path (cls);
@@ -2341,10 +2346,10 @@ token_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
(NULL != nonce) ? nonce : NULL,
oidc_jwk);
}
- else if ( ! strcmp (jwa, JWT_ALG_VALUE_HMAC))
+ else if (! strcmp (jwa, JWT_ALG_VALUE_HMAC))
{
// TODO OPTIONAL acr,amr,azp
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg,
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (oid_cfg,
"reclaim-rest-plugin",
"jwt_secret",
&jwt_secret))
@@ -2708,6 +2713,7 @@ userinfo_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
GNUNET_free (authorization);
}
+
/**
* Responds to /jwks.json
*
@@ -2763,6 +2769,7 @@ jwks_endpoint (struct GNUNET_REST_RequestHandle
*con_handle,
cleanup_handle (handle);
}
+
/**
* If listing is enabled, prints information about the egos.
*
@@ -2997,10 +3004,11 @@ oidc_config_cors (struct GNUNET_REST_RequestHandle
*con_handle,
}
-static enum GNUNET_GenericReturnValue
-rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls)
+enum GNUNET_GenericReturnValue
+REST_openid_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *rest_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
struct GNUNET_REST_RequestHandlerError err;
@@ -3056,24 +3064,23 @@ rest_identity_process_request (struct
GNUNET_REST_RequestHandle *rest_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_openid_connect_init (void *cls)
+REST_openid_init (const struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
struct GNUNET_REST_Plugin *api;
- cfg = cls;
+ oid_cfg = c;
if (NULL != plugin.cfg)
return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = oid_cfg;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_OIDC;
- api->process_request = &rest_identity_process_request;
- identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL);
- gns_handle = GNUNET_GNS_connect (cfg);
- idp = GNUNET_RECLAIM_connect (cfg);
- if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (cfg,
+ identity_handle = GNUNET_IDENTITY_connect (oid_cfg, &list_ego, NULL);
+ gns_handle = GNUNET_GNS_connect (oid_cfg);
+ idp = GNUNET_RECLAIM_connect (oid_cfg);
+ if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (oid_cfg,
"reclaim-rest-plugin",
"OIDC_USERINFO_CONSUME_TIMEOUT",
&consume_timeout))
@@ -3112,7 +3119,7 @@ cleanup_hashmap (void *cls, const struct GNUNET_HashCode
*key, void *value)
* @return always NULL
*/
void *
-libgnunet_plugin_rest_openid_connect_done (void *cls)
+REST_openid_done (void *cls)
{
struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
diff --git a/src/service/rest/openid_plugin.h b/src/service/rest/openid_plugin.h
new file mode 100644
index 000000000..65545ac66
--- /dev/null
+++ b/src/service/rest/openid_plugin.h
@@ -0,0 +1,36 @@
+#include "gnunet_rest_plugin.h"
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_openid_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle *conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
+ * @return NULL on error, otherwise the plugin context
+ */
+void*
+REST_openid_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_openid_done (struct GNUNET_REST_Plugin *api);
diff --git a/src/rest-plugin/reclaim/plugin_rest_pabc.c
b/src/service/rest/pabc_plugin.c
similarity index 100%
rename from src/rest-plugin/reclaim/plugin_rest_pabc.c
rename to src/service/rest/pabc_plugin.c
diff --git a/src/rest-plugin/reclaim/plugin_rest_reclaim.c
b/src/service/rest/reclaim_plugin.c
similarity index 98%
rename from src/rest-plugin/reclaim/plugin_rest_reclaim.c
rename to src/service/rest/reclaim_plugin.c
index b2586109a..677a6a676 100644
--- a/src/rest-plugin/reclaim/plugin_rest_reclaim.c
+++ b/src/service/rest/reclaim_plugin.c
@@ -80,7 +80,7 @@
/**
* The configuration handle
*/
-const struct GNUNET_CONFIGURATION_Handle *cfg;
+const struct GNUNET_CONFIGURATION_Handle *rcfg;
/**
* HTTP methods allows for this plugin
@@ -317,7 +317,8 @@ do_error (void *cls)
handle->response_code = MHD_HTTP_BAD_REQUEST;
}
resp = GNUNET_REST_create_response (json_error);
- GNUNET_assert (MHD_NO != MHD_add_response_header (resp, "Content-Type",
"application/json"));
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp, "Content-Type",
+ "application/json"));
handle->proc (handle->proc_cls, resp, handle->response_code);
cleanup_handle (handle);
GNUNET_free (json_error);
@@ -1316,7 +1317,9 @@ options_cont (struct GNUNET_REST_RequestHandle
*con_handle,
// For now, independent of path return all options
resp = GNUNET_REST_create_response (NULL);
- GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
"Access-Control-Allow-Methods", allow_methods));
+ GNUNET_assert (MHD_NO != MHD_add_response_header (resp,
+
"Access-Control-Allow-Methods",
+ allow_methods));
handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
cleanup_handle (handle);
return;
@@ -1431,10 +1434,10 @@ list_ego (void *cls,
}
-static enum GNUNET_GenericReturnValue
-rest_identity_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
- GNUNET_REST_ResultProcessor proc,
- void *proc_cls)
+enum GNUNET_GenericReturnValue
+REST_reclaim_process_request (struct GNUNET_REST_RequestHandle *rest_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls)
{
struct RequestHandle *handle = GNUNET_new (struct RequestHandle);
struct GNUNET_REST_RequestHandlerError err;
@@ -1492,20 +1495,19 @@ rest_identity_process_request (struct
GNUNET_REST_RequestHandle *rest_handle,
* @return NULL on error, otherwise the plugin context
*/
void *
-libgnunet_plugin_rest_reclaim_init (void *cls)
+REST_reclaim_init (struct GNUNET_CONFIGURATION_Handle *c)
{
static struct Plugin plugin;
struct GNUNET_REST_Plugin *api;
- cfg = cls;
+ rcfg = c;
if (NULL != plugin.cfg)
return NULL; /* can only initialize once! */
memset (&plugin, 0, sizeof(struct Plugin));
- plugin.cfg = cfg;
+ plugin.cfg = rcfg;
api = GNUNET_new (struct GNUNET_REST_Plugin);
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_RECLAIM;
- api->process_request = &rest_identity_process_request;
GNUNET_asprintf (&allow_methods,
"%s, %s, %s, %s, %s",
MHD_HTTP_METHOD_GET,
@@ -1513,9 +1515,9 @@ libgnunet_plugin_rest_reclaim_init (void *cls)
MHD_HTTP_METHOD_PUT,
MHD_HTTP_METHOD_DELETE,
MHD_HTTP_METHOD_OPTIONS);
- identity_handle = GNUNET_IDENTITY_connect (cfg, &list_ego, NULL);
+ identity_handle = GNUNET_IDENTITY_connect (rcfg, &list_ego, NULL);
state = ID_REST_STATE_INIT;
- idp = GNUNET_RECLAIM_connect (cfg);
+ idp = GNUNET_RECLAIM_connect (rcfg);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_ ("Identity Provider REST API initialized\n"));
return api;
@@ -1529,9 +1531,8 @@ libgnunet_plugin_rest_reclaim_init (void *cls)
* @return always NULL
*/
void *
-libgnunet_plugin_rest_reclaim_done (void *cls)
+REST_reclaim_done (struct GNUNET_REST_Plugin *api)
{
- struct GNUNET_REST_Plugin *api = cls;
struct Plugin *plugin = api->cls;
struct RequestHandle *request;
struct EgoEntry *ego_entry;
diff --git a/src/service/rest/reclaim_plugin.h
b/src/service/rest/reclaim_plugin.h
new file mode 100644
index 000000000..102fd827e
--- /dev/null
+++ b/src/service/rest/reclaim_plugin.h
@@ -0,0 +1,36 @@
+#include "gnunet_rest_plugin.h"
+/**
+ * Function processing the REST call
+ *
+ * @param method HTTP method
+ * @param url URL of the HTTP request
+ * @param data body of the HTTP request (optional)
+ * @param data_size length of the body
+ * @param proc callback function for the result
+ * @param proc_cls closure for @a proc
+ * @return #GNUNET_OK if request accepted
+ */
+enum GNUNET_GenericReturnValue
+REST_reclaim_process_request (void *plugin,
+ struct GNUNET_REST_RequestHandle
*conndata_handle,
+ GNUNET_REST_ResultProcessor proc,
+ void *proc_cls);
+
+/**
+ * Entry point for the plugin.
+ *
+ * @param cls the "struct GNUNET_NAMESTORE_PluginEnvironment*"
+ * @return NULL on error, otherwise the plugin context
+ */
+void*
+REST_reclaim_init (const struct GNUNET_CONFIGURATION_Handle *c);
+
+
+/**
+ * Exit point from the plugin.
+ *
+ * @param cls the plugin context (as returned by "init")
+ * @return always NULL
+ */
+void
+REST_reclaim_done (struct GNUNET_REST_Plugin *api);
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: REST: Remove plugins. Hardcode features,
gnunet <=