[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: eliminate redundant /salt respo
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: eliminate redundant /salt response, fix /terms and /privacy replies, expose more information in /config |
Date: |
Tue, 16 Feb 2021 12:28:00 +0100 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 4d3cb74 eliminate redundant /salt response, fix /terms and /privacy
replies, expose more information in /config
4d3cb74 is described below
commit 4d3cb745af5d410cd8f2c5abd79b33ac7db2e503
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Tue Feb 16 12:27:56 2021 +0100
eliminate redundant /salt response, fix /terms and /privacy replies, expose
more information in /config
---
src/backend/Makefile.am | 1 -
src/backend/anastasis-httpd.c | 36 +++--
src/backend/anastasis-httpd.h | 11 +-
src/backend/anastasis-httpd_config.c | 26 +++-
src/backend/anastasis-httpd_config.h | 2 +-
src/backend/anastasis-httpd_mhd.c | 4 +-
src/backend/anastasis-httpd_mhd.h | 4 +-
src/backend/anastasis-httpd_salt.c | 37 -----
src/backend/anastasis-httpd_salt.h | 38 -----
src/backend/anastasis-httpd_terms.c | 68 +++++++--
src/backend/anastasis-httpd_terms.h | 25 ++-
src/include/anastasis_service.h | 151 +++++++++++-------
src/include/anastasis_testing_lib.h | 10 +-
src/reducer/anastasis_api_redux.c | 169 +++++++++++++--------
src/restclient/Makefile.am | 1 -
src/restclient/anastasis_api_config.c | 156 +++++++++++--------
src/restclient/anastasis_api_salt.c | 153 -------------------
src/testing/Makefile.am | 2 +-
...ing_api_cmd_salt.c => testing_api_cmd_config.c} | 94 ++++++------
19 files changed, 483 insertions(+), 505 deletions(-)
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 143bfaf..966747e 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -19,7 +19,6 @@ anastasis_httpd_SOURCES = \
anastasis-httpd_mhd.c anastasis-httpd_mhd.h \
anastasis-httpd_policy.c anastasis-httpd_policy.h \
anastasis-httpd_policy_upload.c \
- anastasis-httpd_salt.c anastasis-httpd_salt.h \
anastasis-httpd_truth.c anastasis-httpd_truth.h \
anastasis-httpd_terms.c anastasis-httpd_terms.h \
anastasis-httpd_config.c anastasis-httpd_config.h \
diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c
index 35b5825..1dda270 100644
--- a/src/backend/anastasis-httpd.c
+++ b/src/backend/anastasis-httpd.c
@@ -27,7 +27,6 @@
#include "anastasis_database_lib.h"
#include "anastasis-httpd_policy.h"
#include "anastasis-httpd_truth.h"
-#include "anastasis-httpd_salt.h"
#include "anastasis-httpd_terms.h"
#include "anastasis-httpd_config.h"
@@ -82,6 +81,11 @@ char *AH_currency;
*/
char *AH_fulfillment_url;
+/**
+ * Our business name.
+ */
+char *AH_business_name;
+
/**
* Standard time range the truth expires.
*/
@@ -275,7 +279,7 @@ url_handler (void *cls,
size_t *upload_data_size,
void **con_cls)
{
- static struct TMH_RequestHandler handlers[] = {
+ static struct AH_RequestHandler handlers[] = {
/* Landing page, tell humans to go away. */
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
"Hello, I'm Anastasis. This HTTP server is not for humans.\n", 0,
@@ -283,18 +287,18 @@ url_handler (void *cls,
{ "/agpl", MHD_HTTP_METHOD_GET, "text/plain",
NULL, 0,
&TMH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND },
- { "/terms", MHD_HTTP_METHOD_GET, "text/plain",
+ { "/terms", MHD_HTTP_METHOD_GET, NULL,
NULL, 0,
&AH_handler_terms, MHD_HTTP_OK },
- { "/config", MHD_HTTP_METHOD_GET, "text/plain",
+ { "/privacy", MHD_HTTP_METHOD_GET, NULL,
NULL, 0,
- &AH_handler_config, MHD_HTTP_OK },
- { "/salt", MHD_HTTP_METHOD_GET, "text/plain",
+ &AH_handler_terms, MHD_HTTP_OK },
+ { "/config", MHD_HTTP_METHOD_GET, "text/json",
NULL, 0,
- &AH_handler_salt, MHD_HTTP_OK },
+ &AH_handler_config, MHD_HTTP_OK },
{NULL, NULL, NULL, NULL, 0, 0 }
};
- static struct TMH_RequestHandler h404 = {
+ static struct AH_RequestHandler h404 = {
"", NULL, "text/html",
"<html><title>404: not found</title></html>", 0,
&TMH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND
@@ -403,7 +407,6 @@ url_handler (void *cls,
if (0 == strcmp (method,
MHD_HTTP_METHOD_POST))
{
- // FIXME: need to accumulate upload_data first!
return AH_handler_truth_post (connection,
hc,
&tu,
@@ -413,7 +416,7 @@ url_handler (void *cls,
}
for (unsigned int i = 0; NULL != handlers[i].url; i++)
{
- struct TMH_RequestHandler *rh = &handlers[i];
+ struct AH_RequestHandler *rh = &handlers[i];
if (0 == strcmp (url,
rh->url))
@@ -592,6 +595,7 @@ run (void *cls,
go = TALER_MHD_GO_NONE;
if (AH_connection_close)
go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;
+ AH_load_terms (config);
TALER_MHD_setup (go);
AH_cfg = config;
global_result = GNUNET_SYSERR;
@@ -742,6 +746,18 @@ run (void *cls,
GNUNET_SCHEDULER_shutdown ();
return;
}
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (config,
+ "anastasis",
+ "BUSINESS_NAME",
+ &AH_business_name))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "anastasis",
+ "BUSINESS_NAME");
+ GNUNET_SCHEDULER_shutdown ();
+ return;
+ }
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_time (config,
"anastasis",
diff --git a/src/backend/anastasis-httpd.h b/src/backend/anastasis-httpd.h
index 7384fe1..58c57fe 100644
--- a/src/backend/anastasis-httpd.h
+++ b/src/backend/anastasis-httpd.h
@@ -31,7 +31,7 @@
/**
* @brief Struct describing an URL and the handler for it.
*/
-struct TMH_RequestHandler
+struct AH_RequestHandler
{
/**
@@ -67,7 +67,7 @@ struct TMH_RequestHandler
* @param connection the MHD connection to handle
* @return MHD result code
*/
- MHD_RESULT (*handler)(struct TMH_RequestHandler *rh,
+ MHD_RESULT (*handler)(struct AH_RequestHandler *rh,
struct MHD_Connection *connection);
/**
@@ -119,7 +119,7 @@ struct TM_HandlerContext
/**
* Which request handler is handling this request?
*/
- const struct TMH_RequestHandler *rh;
+ const struct AH_RequestHandler *rh;
/**
* Asynchronous request context id.
@@ -177,6 +177,11 @@ extern const struct GNUNET_CONFIGURATION_Handle *AH_cfg;
*/
extern char *AH_fulfillment_url;
+/**
+ * Our business name.
+ */
+extern char *AH_business_name;
+
/**
* Standard time range the truth expires.
*/
diff --git a/src/backend/anastasis-httpd_config.c
b/src/backend/anastasis-httpd_config.c
index bc5cff3..e5419b7 100644
--- a/src/backend/anastasis-httpd_config.c
+++ b/src/backend/anastasis-httpd_config.c
@@ -82,7 +82,7 @@ add_methods (void *cls,
* @return MHD result code
*/
MHD_RESULT
-AH_handler_config (struct TMH_RequestHandler *rh,
+AH_handler_config (struct AH_RequestHandler *rh,
struct MHD_Connection *connection)
{
json_t *method_arr = json_array ();
@@ -106,24 +106,34 @@ AH_handler_config (struct TMH_RequestHandler *rh,
method_arr);
return TALER_MHD_reply_json_pack (connection,
MHD_HTTP_OK,
- "{s:s, s:o, s:I, s:s, s:o, s:o, s:o, s:s}",
+ "{s:s, s:s, s:s, s:s, s:o, s:I,"
+ " s:o, s:o, s:o, s:o, s:o}",
"name",
"anastasis",
+ "version",
+ "0:0:0",
+ "business_name",
+ AH_business_name,
+ "currency",
+ (char *) AH_currency,
"methods",
method_arr,
"storage_limit_in_megabytes",
(json_int_t) AH_upload_limit_mb,
- "currency",
- (char *) AH_currency,
+ /* 6 */
"annual_fee",
TALER_JSON_from_amount (&AH_annual_fee),
- "insurance",
+ "truth_upload_fee",
+ TALER_JSON_from_amount (
+ &AH_truth_upload_fee),
+ "truth_lifetime",
+ GNUNET_JSON_from_time_rel (
+ AH_truth_expiration),
+ "liability_limit",
TALER_JSON_from_amount (&AH_insurance),
"server_salt",
GNUNET_JSON_from_data_auto (
- &AH_server_salt),
- "version",
- "0:0:0");
+ &AH_server_salt));
}
diff --git a/src/backend/anastasis-httpd_config.h
b/src/backend/anastasis-httpd_config.h
index 3acf5a4..7d58792 100644
--- a/src/backend/anastasis-httpd_config.h
+++ b/src/backend/anastasis-httpd_config.h
@@ -33,7 +33,7 @@
* @return MHD result code
*/
MHD_RESULT
-AH_handler_config (struct TMH_RequestHandler *rh,
+AH_handler_config (struct AH_RequestHandler *rh,
struct MHD_Connection *connection);
#endif
diff --git a/src/backend/anastasis-httpd_mhd.c
b/src/backend/anastasis-httpd_mhd.c
index 4712210..c39a54c 100644
--- a/src/backend/anastasis-httpd_mhd.c
+++ b/src/backend/anastasis-httpd_mhd.c
@@ -36,7 +36,7 @@
* @return MHD result code
*/
MHD_RESULT
-TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
+TMH_MHD_handler_static_response (struct AH_RequestHandler *rh,
struct MHD_Connection *connection)
{
if (0 == rh->data_size)
@@ -58,7 +58,7 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler
*rh,
* @return MHD result code
*/
MHD_RESULT
-TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
+TMH_MHD_handler_agpl_redirect (struct AH_RequestHandler *rh,
struct MHD_Connection *connection)
{
(void) rh;
diff --git a/src/backend/anastasis-httpd_mhd.h
b/src/backend/anastasis-httpd_mhd.h
index a9b8b83..628abfa 100644
--- a/src/backend/anastasis-httpd_mhd.h
+++ b/src/backend/anastasis-httpd_mhd.h
@@ -41,7 +41,7 @@
* @return MHD result code
*/
MHD_RESULT
-TMH_MHD_handler_static_response (struct TMH_RequestHandler *rh,
+TMH_MHD_handler_static_response (struct AH_RequestHandler *rh,
struct MHD_Connection *connection);
@@ -54,7 +54,7 @@ TMH_MHD_handler_static_response (struct TMH_RequestHandler
*rh,
* @return MHD result code
*/
MHD_RESULT
-TMH_MHD_handler_agpl_redirect (struct TMH_RequestHandler *rh,
+TMH_MHD_handler_agpl_redirect (struct AH_RequestHandler *rh,
struct MHD_Connection *connection);
diff --git a/src/backend/anastasis-httpd_salt.c
b/src/backend/anastasis-httpd_salt.c
deleted file mode 100644
index c965e70..0000000
--- a/src/backend/anastasis-httpd_salt.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
-
- You should have received a copy of the GNU Affero General Public License
along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file anastasis-httpd_salt.c
- * @brief functions to handle incoming requests on /salt
- * @author Dennis Neufeld
- * @author Dominik Meister
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include "anastasis-httpd_salt.h"
-
-
-MHD_RESULT
-AH_handler_salt (struct TMH_RequestHandler *rh,
- struct MHD_Connection *connection)
-{
- return TALER_MHD_reply_json_pack (
- connection,
- MHD_HTTP_OK,
- "{s:o}",
- "server_salt",
- GNUNET_JSON_from_data_auto (&AH_server_salt));
-}
diff --git a/src/backend/anastasis-httpd_salt.h
b/src/backend/anastasis-httpd_salt.h
deleted file mode 100644
index a60e481..0000000
--- a/src/backend/anastasis-httpd_salt.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- This file is part of TALER
- Copyright (C) 2019 GNUnet e.V.
-
- TALER is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
details.
-
- You should have received a copy of the GNU Affero General Public License
along with
- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file anastasis-httpd_salt.c
- * @brief functions to handle incoming requests on /salt
- * @author Dennis Neufeld
- * @author Dominik Meister
- * @author Christian Grothoff
- */
-#ifndef ANASTASIS_HTTPD_SALT_H
-#define ANASTASIS_HTTPD_SALT_H
-
-#include "anastasis-httpd.h"
-
-/**
- * Return this providers salt.
- *
- * @param connection the MHD connection to handle
- * @return MHD result code
- */
-MHD_RESULT
-AH_handler_salt (struct TMH_RequestHandler *rh,
- struct MHD_Connection *connection);
-
-#endif
diff --git a/src/backend/anastasis-httpd_terms.c
b/src/backend/anastasis-httpd_terms.c
index 0819f73..6be5690 100644
--- a/src/backend/anastasis-httpd_terms.c
+++ b/src/backend/anastasis-httpd_terms.c
@@ -24,6 +24,18 @@
#include "anastasis-httpd_terms.h"
#include <taler/taler_json_lib.h>
+/**
+ * Our terms of service.
+ */
+static struct TALER_MHD_Legal *tos;
+
+
+/**
+ * Our privacy policy.
+ */
+static struct TALER_MHD_Legal *pp;
+
+
/**
* Manages a /terms call.
*
@@ -32,18 +44,54 @@
* @return MHD result code
*/
MHD_RESULT
-AH_handler_terms (struct TMH_RequestHandler *rh,
+AH_handler_terms (struct AH_RequestHandler *rh,
struct MHD_Connection *connection)
{
- return TALER_MHD_reply_json_pack (connection,
- MHD_HTTP_OK,
- "{s:I, s:o, s:s}",
- "storage_limit_in_megabytes",
- (json_int_t) AH_upload_limit_mb,
- "annual_fee",
- TALER_JSON_from_amount (&AH_annual_fee),
- "version",
- "0.0");
+ (void) rh;
+ return TALER_MHD_reply_legal (connection,
+ tos);
+}
+
+
+/**
+ * Handle a "/privacy" request.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @return MHD result code
+ */
+MHD_RESULT
+AH_handler_privacy (const struct AH_RequestHandler *rh,
+ struct MHD_Connection *connection)
+{
+ (void) rh;
+ return TALER_MHD_reply_legal (connection,
+ pp);
+}
+
+
+/**
+ * Load our terms of service as per configuration.
+ *
+ * @param cfg configuration to process
+ */
+void
+AH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ tos = TALER_MHD_legal_load (cfg,
+ "anastasis",
+ "TERMS_DIR",
+ "TERMS_ETAG");
+ if (NULL == tos)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Terms of service not configured\n");
+ pp = TALER_MHD_legal_load (cfg,
+ "anastasis",
+ "PRIVACY_DIR",
+ "PRIVACY_ETAG");
+ if (NULL == pp)
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "Privacy policy not configured\n");
}
diff --git a/src/backend/anastasis-httpd_terms.h
b/src/backend/anastasis-httpd_terms.h
index b477ecf..dc59d41 100644
--- a/src/backend/anastasis-httpd_terms.h
+++ b/src/backend/anastasis-httpd_terms.h
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020, 2021 Taler Systems SA
Anastasis is free software; you can redistribute it and/or modify it under
the
terms of the GNU Lesser General Public License as published by the Free
Software
@@ -33,9 +33,30 @@
* @return MHD result code
*/
MHD_RESULT
-AH_handler_terms (struct TMH_RequestHandler *rh,
+AH_handler_terms (struct AH_RequestHandler *rh,
struct MHD_Connection *connection);
+
+/**
+ * Handle a "/privacy" request.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @return MHD result code
+ */
+MHD_RESULT
+AH_handler_privacy (const struct AH_RequestHandler *rh,
+ struct MHD_Connection *connection);
+
+/**
+ * Load our terms of service as per configuration.
+ *
+ * @param cfg configuration to process
+ */
+void
+AH_load_terms (const struct GNUNET_CONFIGURATION_Handle *cfg);
+
+
#endif
/* end of anastasis-httpd_terms.h */
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index f2fca0d..1cfd4db 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -29,90 +29,135 @@
#include <jansson.h>
-typedef void
-(*ANASTASIS_ConfigCallback)(void *cls,
- unsigned int http_status,
- const json_t *methods,
- const char *conf_currency,
- const struct TALER_Amount *annual_fee,
- const struct TALER_Amount *insurance,
- const struct ANASTASIS_CRYPTO_PowSalt
*server_salt);
-
-
/**
- * @brief A Config Operation Handle
+ * Anastasis authorization method configuration
*/
-struct ANASTASIS_ConfigOperation;
-
-
-struct ANASTASIS_ConfigOperation *
-ANASTASIS_get_config (struct GNUNET_CURL_Context *ctx,
- const char *base_url,
- ANASTASIS_ConfigCallback cb,
- void *cb_cls);
-
-
-void
-ANASTASIS_config_cancel (struct ANASTASIS_ConfigOperation *co);
-
-
-struct ANASTASIS_SaltOperation;
+struct ANASTASIS_AuthorizationMethodConfig
+{
+ /**
+ * Name of the method, i.e. "question".
+ */
+ const char *name;
+ /**
+ * Fee charged for accessing key share using this method.
+ */
+ struct TALER_Amount usage_fee;
+};
-typedef void
-(*ANASTASIS_SaltCallback)(void *cls,
- unsigned int http_status,
- const struct ANASTASIS_CRYPTO_PowSalt *salt);
+/**
+ * @brief Anastasis configuration data.
+ */
+struct ANASTASIS_Config
+{
+ /**
+ * Protocol version supported by the server.
+ */
+ const char *version;
-struct ANASTASIS_SaltOperation *
-ANASTASIS_salt (struct GNUNET_CURL_Context *ctx,
- const char *base_url,
- ANASTASIS_SaltCallback cb,
- void *cb_cls);
+ /**
+ * Business name of the anastasis provider.
+ */
+ const char *business_name;
+ /**
+ * Currency used for payments by the server.
+ */
+ const char *currency;
-void
-ANASTASIS_salt_cancel (struct ANASTASIS_SaltOperation *so);
+ /**
+ * Array of authorization methods supported by the server.
+ */
+ const struct ANASTASIS_AuthorizationMethodConfig *methods;
+ /**
+ * Length of the @e methods array.
+ */
+ unsigned int methods_length;
-/**
- * @brief A Contract Operation Handle
- */
-struct ANASTASIS_SaltOperation
-{
/**
- * The url for this request.
+ * Maximum size of an upload in megabytes.
*/
- char *url;
+ uint32_t storage_limit_in_megabytes;
/**
- * Handle for the request.
+ * Annual fee for an account / policy upload.
*/
- struct GNUNET_CURL_Job *job;
+ struct TALER_Amount annual_fee;
/**
- * Reference to the execution context.
+ * Fee for a truth upload.
*/
- struct GNUNET_CURL_Context *ctx;
+ struct TALER_Amount truth_upload_fee;
/**
- * The callback to pass the backend response to
- */
- ANASTASIS_SaltCallback cb;
+ * How long does the server store truth once uploaded
+ * (per @e truth_upload_fee).
+ */
+ struct GNUNET_TIME_Relative truth_lifetime;
/**
- * Closure for @a cb.
+ * Maximum legal liability for data loss covered by the
+ * provider.
*/
- void *cb_cls;
+ struct TALER_Amount liability_limit;
/**
* Server salt.
*/
struct ANASTASIS_CRYPTO_PowSalt salt;
+
};
+/**
+ * Function called with the result of a /config request.
+ * Note that an HTTP status of #MHD_HTTP_OK is no guarantee
+ * that @a acfg is non-NULL. @a acfg is non-NULL only if
+ * the server provided an acceptable response.
+ *
+ * @param cls closure
+ * @param http_status the HTTP status
+ * @param acfg configuration obtained, NULL if we could not parse it
+ */
+typedef void
+(*ANASTASIS_ConfigCallback)(void *cls,
+ unsigned int http_status,
+ const struct ANASTASIS_Config *acfg);
+
+
+/**
+ * @brief A Config Operation Handle
+ */
+struct ANASTASIS_ConfigOperation;
+
+
+/**
+ * Run a GET /config request against the Anastasis backend.
+ *
+ * @param ctx CURL context to use
+ * @param base_url base URL fo the Anastasis backend
+ * @param cb function to call with the results
+ * @param cb_cls closure for @a cb
+ * @return handle to cancel the operation
+ */
+struct ANASTASIS_ConfigOperation *
+ANASTASIS_get_config (struct GNUNET_CURL_Context *ctx,
+ const char *base_url,
+ ANASTASIS_ConfigCallback cb,
+ void *cb_cls);
+
+
+/**
+ * Cancel ongoing #ANASTASIS_get_config() request.
+ *
+ * @param co configuration request to cancel.
+ */
+void
+ANASTASIS_config_cancel (struct ANASTASIS_ConfigOperation *co);
+
+
/****** POLICY API ******/
diff --git a/src/include/anastasis_testing_lib.h
b/src/include/anastasis_testing_lib.h
index f3d65ba..f4de245 100644
--- a/src/include/anastasis_testing_lib.h
+++ b/src/include/anastasis_testing_lib.h
@@ -523,18 +523,18 @@ ANASTASIS_TESTING_make_trait_salt (unsigned int index,
/**
- * Make the "salt" command.
+ * Make the "/config" command.
*
* @param label command label
* @param anastasis_url base URL of the ANASTASIS serving
- * the salt request.
+ * the /config request.
* @param http_status expected HTTP status.
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_salt (const char *label,
- const char *anastasis_url,
- unsigned int http_status);
+ANASTASIS_TESTING_cmd_config (const char *label,
+ const char *anastasis_url,
+ unsigned int http_status);
/* ********************* test truth upload ********************* */
diff --git a/src/reducer/anastasis_api_redux.c
b/src/reducer/anastasis_api_redux.c
index 144b4c1..825e9b2 100644
--- a/src/reducer/anastasis_api_redux.c
+++ b/src/reducer/anastasis_api_redux.c
@@ -152,6 +152,23 @@ struct ConfigReduxWaiting
};
+/**
+ * Anastasis authorization method configuration
+ */
+struct AuthorizationMethodConfig
+{
+ /**
+ * Name of the method, i.e. "question".
+ */
+ char *name;
+
+ /**
+ * Fee charged for accessing key share using this method.
+ */
+ struct TALER_Amount usage_fee;
+};
+
+
/**
* State for a "get config" operation.
*/
@@ -191,42 +208,59 @@ struct ConfigRequest
/**
* URL of the anastasis backend.
*/
- char *backend_url;
+ char *url;
/**
- * id of the anastasis backend.
+ * Business name of the anastasis backend.
*/
- char *backend_id;
+ char *business_name;
/**
- * label of the anastasis backend.
+ * currency used by the anastasis backend.
*/
- char *backend_name;
+ char *currency;
/**
- * currency used by the anastasis backend.
+ * Array of authorization methods supported by the server.
+ */
+ struct AuthorizationMethodConfig *methods;
+
+ /**
+ * Length of the @e methods array.
+ */
+ unsigned int methods_length;
+
+ /**
+ * Maximum size of an upload in megabytes.
*/
- char *backend_currency;
+ uint32_t storage_limit_in_megabytes;
/**
- * insurance of the anastasis backend.
+ * Annual fee for an account / policy upload.
*/
- struct TALER_Amount backend_insurance;
+ struct TALER_Amount annual_fee;
/**
- * cost of using the anastasis backend.
+ * Fee for a truth upload.
*/
- struct TALER_Amount backend_cost;
+ struct TALER_Amount truth_upload_fee;
/**
- * salt of the provider server used for generation of user identifier.
+ * How long does the server store truth once uploaded
+ * (per @e truth_upload_fee).
*/
- struct ANASTASIS_CRYPTO_PowSalt backend_salt;
+ struct GNUNET_TIME_Relative truth_lifetime;
/**
- * Supported methods.
+ * Maximum legal liability for data loss covered by the
+ * provider.
*/
- json_t *backend_methods;
+ struct TALER_Amount liability_limit;
+
+ /**
+ * Server salt.
+ */
+ struct ANASTASIS_CRYPTO_PowSalt salt;
/**
* Task to timeout /config requests.
@@ -290,11 +324,12 @@ free_config_request (struct ConfigRequest *cr)
ANASTASIS_config_cancel (cr->co);
if (NULL != cr->tt)
GNUNET_SCHEDULER_cancel (cr->tt);
- GNUNET_free (cr->backend_currency);
- GNUNET_free (cr->backend_url);
- GNUNET_free (cr->backend_id);
- GNUNET_free (cr->backend_name);
- json_decref (cr->backend_methods);
+ GNUNET_free (cr->currency);
+ GNUNET_free (cr->url);
+ GNUNET_free (cr->business_name);
+ for (unsigned int i = 0; i<cr->methods_length; i++)
+ GNUNET_free (cr->methods[i].name);
+ GNUNET_free (cr->methods);
GNUNET_free (cr);
}
@@ -387,19 +422,12 @@ ANASTASIS_redux_countries_init_ (void)
*
* @param cls closure
* @param http_status HTTP status of the request
- * @param methods supported methods by this provider
- * @param annual_fee Annual fee of this service
- * @param insurance Amount of insurance of this service
- * @param salt Salt of this provider server
+ * @param acfg anastasis configuration
*/
static void
config_cb (void *cls,
unsigned int http_status,
- const json_t *methods,
- const char *conf_currency,
- const struct TALER_Amount *annual_fee,
- const struct TALER_Amount *insurance,
- const struct ANASTASIS_CRYPTO_PowSalt *salt)
+ const struct ANASTASIS_Config *acfg)
{
struct ConfigRequest *cr = cls;
@@ -407,13 +435,30 @@ config_cb (void *cls,
GNUNET_SCHEDULER_cancel (cr->tt);
cr->tt = NULL;
cr->http_status = http_status;
- if (MHD_HTTP_OK == http_status)
+ if ( (MHD_HTTP_OK == http_status) &&
+ (NULL == acfg) )
{
- cr->backend_methods = json_incref ((json_t *) methods);
- cr->backend_cost = *annual_fee;
- cr->backend_currency = GNUNET_strdup (conf_currency);
- cr->backend_insurance = *insurance;
- cr->backend_salt = *salt;
+ cr->http_status = MHD_HTTP_NOT_FOUND;
+ return;
+ }
+ if (NULL != acfg)
+ {
+ cr->currency = GNUNET_strdup (acfg->currency);
+ cr->business_name = GNUNET_strdup (acfg->business_name);
+ cr->methods = GNUNET_new_array (acfg->methods_length,
+ struct AuthorizationMethodConfig);
+ for (unsigned int i = 0; i<acfg->methods_length; i++)
+ {
+ cr->methods[i].name = GNUNET_strdup (acfg->methods[i].name);
+ cr->methods[i].usage_fee = acfg->methods[i].usage_fee;
+ }
+ cr->methods_length = acfg->methods_length;
+ cr->storage_limit_in_megabytes = acfg->storage_limit_in_megabytes;
+ cr->annual_fee = acfg->annual_fee;
+ cr->truth_upload_fee = acfg->truth_upload_fee;
+ cr->truth_lifetime = acfg->truth_lifetime;
+ cr->liability_limit = acfg->liability_limit;
+ cr->salt = acfg->salt;
}
}
@@ -438,42 +483,38 @@ config_request_timeout (void *cls)
* Schedule job to obtain Anastasis provider configuration at @a url.
*
* @param url base URL of Anastasis provider
- * @param name name of the provider
- * @param id ID of the provider
+ * @return check config handle
*/
-static void
-check_config (const char *url,
- const char *name,
- const char *id)
+static struct ConfigRequest *
+check_config (const char *url)
{
struct ConfigRequest *cr;
for (cr = cr_head; NULL != cr; cr = cr->next)
{
if (0 != strcmp (url,
- cr->backend_url))
+ cr->url))
continue;
if (NULL != cr->co)
- return; /* already on it */
+ return cr; /* already on it */
break;
}
if (NULL == cr)
{
cr = GNUNET_new (struct ConfigRequest);
- cr->backend_url = GNUNET_strdup (url);
- cr->backend_name = GNUNET_strdup (name);
- cr->backend_id = GNUNET_strdup (id);
+ cr->url = GNUNET_strdup (url);
GNUNET_CONTAINER_DLL_insert (cr_head,
cr_tail,
cr);
}
cr->co = ANASTASIS_get_config (ANASTASIS_REDUX_ctx_,
- cr->backend_url,
+ cr->url,
&config_cb,
cr);
if (NULL == cr->co)
{
GNUNET_break (0);
+ return NULL;
}
else
{
@@ -481,6 +522,7 @@ check_config (const char *url,
&config_request_timeout,
cr);
}
+ return cr;
}
@@ -535,16 +577,10 @@ begin_provider_config_check (const char *currency)
json_array_foreach (provider_arr, index, provider)
{
const char *url;
- const char *name;
- const char *id;
const char *cur;
struct GNUNET_JSON_Specification spec[] = {
GNUNET_JSON_spec_string ("url",
&url),
- GNUNET_JSON_spec_string ("name",
- &name),
- GNUNET_JSON_spec_string ("id",
- &id),
GNUNET_JSON_spec_string ("currency",
&cur),
GNUNET_JSON_spec_end ()
@@ -562,9 +598,7 @@ begin_provider_config_check (const char *currency)
if (0 != strcasecmp (currency,
cur))
continue;
- check_config (url,
- name,
- id);
+ check_config (url);
}
}
return TALER_EC_NONE;
@@ -945,14 +979,21 @@ ANASTASIS_REDUX_add_provider_to_state_ (const char *url,
ANASTASIS_ActionCallback cb,
void *cb_cls)
{
- struct ConfigRequest *cr = FIXME;
+ struct ConfigRequest *cr;
struct ConfigReduxWaiting *w;
+ struct ANASTASIS_ReduxAction *ra;
json_t *method;
size_t index;
json_t *provider_list;
json_t *methods_list;
- w = GNUNET_new (struct ConfigReduxWaiting);
+ for (cr = cr_head; NULL != cr; cr = cr->next)
+ if (0 == strcmp (url,
+ cr->url))
+ break;
+ if (NULL == cr)
+
+ w = GNUNET_new (struct ConfigReduxWaiting);
GNUNET_CONTAINER_DLL_insert (cr->w_head,
cr->w_tail,
w);
@@ -990,17 +1031,17 @@ ANASTASIS_REDUX_add_provider_to_state_ (const char *url,
prov = json_pack ("{s:o, s:o, s:o, s:s, s:s, s:o}",
"method_cost",
json_object_get (method,
- "cost"),
+ "cost"), // FIXME: bad RC, bad idea!
"annual_cost",
- TALER_JSON_from_amount (&cr->backend_cost),
+ TALER_JSON_from_amount (&cr->annual_fee),
"insurance",
- TALER_JSON_from_amount (&cr->backend_insurance),
+ TALER_JSON_from_amount (&cr->liability_limit),
"provider_url",
- cr->backend_url,
+ cr->url,
"provider_name",
- cr->backend_name,
+ cr->business_name,
"provider_salt",
- GNUNET_JSON_from_data_auto (&cr->provider_salt));
+ GNUNET_JSON_from_data_auto (&cr->salt));
GNUNET_assert (0 ==
json_object_set_new (ma,
cr->backend_id,
diff --git a/src/restclient/Makefile.am b/src/restclient/Makefile.am
index 7e5d72d..bf8865a 100644
--- a/src/restclient/Makefile.am
+++ b/src/restclient/Makefile.am
@@ -15,7 +15,6 @@ libanastasisrest_la_LDFLAGS = \
-version-info 0:0:0 \
-no-undefined
libanastasisrest_la_SOURCES = \
- anastasis_api_salt.c \
anastasis_api_config.c \
anastasis_api_policy_store.c \
anastasis_api_truth_store.c \
diff --git a/src/restclient/anastasis_api_config.c
b/src/restclient/anastasis_api_config.c
index 2319b4a..d039aa0 100644
--- a/src/restclient/anastasis_api_config.c
+++ b/src/restclient/anastasis_api_config.c
@@ -1,6 +1,6 @@
/*
This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
+ Copyright (C) 2020, 2021 Taler Systems SA
Anastasis is free software; you can redistribute it and/or modify it under
the
terms of the GNU Lesser General Public License as published by the Free
Software
@@ -56,30 +56,6 @@ struct ANASTASIS_ConfigOperation
*/
void *cb_cls;
- /**
- * Cost.
- */
- struct TALER_Amount cost;
-
- /**
- * Insurance.
- */
- struct TALER_Amount insurance;
-
- /**
- * Supported methods.
- */
- json_t *methods;
-
- /**
- * Currency of the cost;
- */
- const char *currency;
-
- /**
- * Server salt.
- */
- struct ANASTASIS_CRYPTO_PowSalt salt;
};
@@ -98,7 +74,6 @@ handle_config_finished (void *cls,
{
struct ANASTASIS_ConfigOperation *co = cls;
const json_t *json = response;
- json_error_t err;
co->job = NULL;
switch (response_code)
@@ -110,11 +85,32 @@ handle_config_finished (void *cls,
break;
case MHD_HTTP_OK:
{
+ const char *name;
+ struct ANASTASIS_Config acfg;
+ json_t *methods;
struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("currency", &co->currency),
- TALER_JSON_spec_amount ("annual_fee", &co->cost),
- TALER_JSON_spec_amount ("insurance", &co->insurance),
- GNUNET_JSON_spec_fixed_auto ("server_salt", &co->salt),
+ GNUNET_JSON_spec_string ("name",
+ &name),
+ GNUNET_JSON_spec_string ("business_name",
+ &acfg.business_name),
+ GNUNET_JSON_spec_string ("version",
+ &acfg.version),
+ GNUNET_JSON_spec_string ("currency",
+ &acfg.currency),
+ GNUNET_JSON_spec_json ("methods",
+ &methods),
+ GNUNET_JSON_spec_uint32 ("storage_limit_in_megabytes",
+ &acfg.storage_limit_in_megabytes),
+ TALER_JSON_spec_amount ("annual_fee",
+ &acfg.annual_fee),
+ TALER_JSON_spec_amount ("annual_fee",
+ &acfg.truth_upload_fee),
+ TALER_JSON_spec_relative_time ("truth_lifetime",
+ &acfg.truth_lifetime),
+ TALER_JSON_spec_amount ("liability_limit",
+ &acfg.liability_limit),
+ GNUNET_JSON_spec_fixed_auto ("server_salt",
+ &acfg.salt),
GNUNET_JSON_spec_end ()
};
@@ -123,25 +119,56 @@ handle_config_finished (void *cls,
spec,
NULL, NULL))
{
- GNUNET_break (0);
+ GNUNET_break_op (0);
+ break;
+ }
+ if (0 != strcmp (name,
+ "anastasis"))
+ {
+ GNUNET_JSON_parse_free (spec);
+ break;
+ }
+ /* FIXME: implement protocol version check here eventually */
+ if (! json_is_array (methods))
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ break;
+ }
+ acfg.methods_length = json_array_size (methods);
+ {
+ struct ANASTASIS_AuthorizationMethodConfig mcfg[GNUNET_NZL (
+
acfg.methods_length)];
+
+ for (unsigned int i = 0; i<acfg.methods_length; i++)
+ {
+ struct ANASTASIS_AuthorizationMethodConfig *m = &mcfg[i];
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("name",
+ &m->name),
+ TALER_JSON_spec_amount ("usage_fee",
+ &m->usage_fee),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (json,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break_op (0);
+ GNUNET_JSON_parse_free (spec);
+ goto end;
+ }
+ }
+ acfg.methods = mcfg;
+ co->cb (co->cb_cls,
+ MHD_HTTP_OK,
+ &acfg);
+ GNUNET_JSON_parse_free (spec);
+ ANASTASIS_config_cancel (co);
return;
}
- co->methods = json_loads (json_string_value (
- json_object_get (json, "methods")),
- JSON_DECODE_ANY, &err);
-
- co->cb (co->cb_cls,
- response_code,
- co->methods,
- co->currency,
- &co->cost,
- &co->insurance,
- &co->salt
- );
- json_decref (co->methods);
- GNUNET_JSON_parse_free (spec);
- ANASTASIS_config_cancel (co);
- return;
}
case MHD_HTTP_BAD_REQUEST:
/* This should never happen, either us or the anastasis server is buggy
@@ -159,21 +186,13 @@ handle_config_finished (void *cls,
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Unexpected response code %u\n",
(unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
+ GNUNET_break_op (0);
break;
}
- if (NULL != co->cb)
- {
- co->cb (co->cb_cls,
- response_code,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
- co->cb = NULL;
- }
+end:
+ co->cb (co->cb_cls,
+ response_code,
+ NULL);
ANASTASIS_config_cancel (co);
}
@@ -185,7 +204,6 @@ ANASTASIS_get_config (struct GNUNET_CURL_Context *ctx,
void *cb_cls)
{
struct ANASTASIS_ConfigOperation *co;
- CURL *eh;
co = GNUNET_new (struct ANASTASIS_ConfigOperation);
co->url = TALER_url_join (base_url,
@@ -194,12 +212,16 @@ ANASTASIS_get_config (struct GNUNET_CURL_Context *ctx,
co->ctx = ctx;
co->cb = cb;
co->cb_cls = cb_cls;
- eh = ANASTASIS_curl_easy_get_ (co->url);
- co->job = GNUNET_CURL_job_add2 (ctx,
- eh,
- GNUNET_NO,
- &handle_config_finished,
- co);
+ {
+ CURL *eh;
+
+ eh = ANASTASIS_curl_easy_get_ (co->url);
+ co->job = GNUNET_CURL_job_add2 (ctx,
+ eh,
+ GNUNET_NO,
+ &handle_config_finished,
+ co);
+ }
if (NULL == co->job)
{
GNUNET_free (co->url);
diff --git a/src/restclient/anastasis_api_salt.c
b/src/restclient/anastasis_api_salt.c
deleted file mode 100644
index f65152a..0000000
--- a/src/restclient/anastasis_api_salt.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- This file is part of Anastasis
- Copyright (C) 2020 Taler Systems SA
-
- Anastasis is free software; you can redistribute it and/or modify it under
the
- terms of the GNU Lesser General Public License as published by the Free
Software
- Foundation; either version 3, or (at your option) any later version.
-
- Anastasis is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with
- Anastasis; see the file COPYING.GPL. If not, see
<http://www.gnu.org/licenses/>
-*/
-/**
- * @file lib/anastasis_api_salt.c
- * @brief Implementation of the /salt GET
- * @author Christian Grothoff
- */
-#include "platform.h"
-#include <curl/curl.h>
-#include <jansson.h>
-#include <microhttpd.h> /* just for HTTP status codes */
-#include <gnunet/gnunet_util_lib.h>
-#include <gnunet/gnunet_curl_lib.h>
-#include <gnunet/gnunet_json_lib.h>
-#include "anastasis_service.h"
-#include "anastasis_api_curl_defaults.h"
-
-
-/**
- * Function called when we're done processing the
- * HTTP /salt request.
- *
- * @param cls the `struct ANASTASIS_SaltOperation`
- * @param response_code HTTP response code, 0 on error
- * @param response parsed JSON result, NULL on error
- */
-static void
-handle_salt_finished (void *cls,
- long response_code,
- const void *response)
-{
- struct ANASTASIS_SaltOperation *so = cls;
- const json_t *json = response;
-
- so->job = NULL;
- switch (response_code)
- {
- case 0:
- /* Hard error */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Backend didn't even return from GET /salt\n");
- break;
- case MHD_HTTP_OK:
- {
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_fixed_auto ("server_salt", &so->salt),
- GNUNET_JSON_spec_end ()
- };
-
- if (GNUNET_OK !=
- GNUNET_JSON_parse (json,
- spec,
- NULL, NULL))
- {
- GNUNET_break (0);
- return;
- }
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "At %s:%d Server Salt from Download is %s-%llu b\n",
__FILE__,
- __LINE__,
- TALER_B2S (&so->salt),
- (unsigned long long) sizeof (so->salt));
- so->cb (so->cb_cls,
- response_code,
- &so->salt);
- ANASTASIS_salt_cancel (so);
- return;
- }
- case MHD_HTTP_BAD_REQUEST:
- /* This should never happen, either us or the anastasis server is buggy
- (or API version conflict); just pass JSON reply to the application */
- break;
- case MHD_HTTP_NOT_FOUND:
- /* Nothing really to verify */
- break;
- case MHD_HTTP_INTERNAL_SERVER_ERROR:
- /* Server had an internal issue; we should retry, but this API
- leaves this to the application */
- break;
- default:
- /* unexpected response code */
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Unexpected response code %u\n",
- (unsigned int) response_code);
- GNUNET_break (0);
- response_code = 0;
- break;
- }
- if (NULL != so->cb)
- {
- so->cb (so->cb_cls,
- response_code,
- NULL);
- so->cb = NULL;
- }
- ANASTASIS_salt_cancel (so);
-}
-
-
-struct ANASTASIS_SaltOperation *
-ANASTASIS_salt (struct GNUNET_CURL_Context *ctx,
- const char *base_url,
- ANASTASIS_SaltCallback cb,
- void *cb_cls)
-{
- struct ANASTASIS_SaltOperation *so;
- CURL *eh;
-
- so = GNUNET_new (struct ANASTASIS_SaltOperation);
- so->url = TALER_url_join (base_url,
- "salt",
- NULL);
- so->ctx = ctx;
- so->cb = cb;
- so->cb_cls = cb_cls;
- eh = ANASTASIS_curl_easy_get_ (so->url);
- so->job = GNUNET_CURL_job_add2 (ctx,
- eh,
- GNUNET_NO,
- &handle_salt_finished,
- so);
- return so;
-}
-
-
-void
-ANASTASIS_salt_cancel (struct ANASTASIS_SaltOperation *so)
-{
- if (NULL != so->job)
- {
- GNUNET_CURL_job_cancel (so->job);
- so->job = NULL;
- }
- GNUNET_free (so->url);
- GNUNET_free (so);
-}
-
-
-/* end of anastasis_api_salt.c */
diff --git a/src/testing/Makefile.am b/src/testing/Makefile.am
index 5fcfebe..576499d 100644
--- a/src/testing/Makefile.am
+++ b/src/testing/Makefile.am
@@ -17,7 +17,7 @@ libanastasistesting_la_SOURCES = \
testing_api_cmd_truth_store.c \
testing_api_cmd_policy_lookup.c \
testing_api_cmd_keyshare_lookup.c \
- testing_api_cmd_salt.c \
+ testing_api_cmd_config.c \
testing_api_helpers.c \
testing_api_trait_account_pub.c \
testing_api_trait_account_priv.c \
diff --git a/src/testing/testing_api_cmd_salt.c
b/src/testing/testing_api_cmd_config.c
similarity index 65%
rename from src/testing/testing_api_cmd_salt.c
rename to src/testing/testing_api_cmd_config.c
index f689cae..b8e21a6 100644
--- a/src/testing/testing_api_cmd_salt.c
+++ b/src/testing/testing_api_cmd_config.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2019 Taler Systems SA
+ Copyright (C) 2019, 2021 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
Software
@@ -14,8 +14,8 @@
TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
*/
/**
- * @file lib/testing_api_cmd_salt.c
- * @brief command to execute the anastasis backend service.
+ * @file lib/testing_api_cmd_config.c
+ * @brief command to obtain the configuration of an anastasis backend service.
* @author Dennis Neufeld
* @author Dominik Meister
*/
@@ -27,9 +27,9 @@
/**
- * State for a "salt" CMD.
+ * State for a "config" CMD.
*/
-struct SaltState
+struct ConfigState
{
/**
* The interpreter state.
@@ -47,9 +47,9 @@ struct SaltState
unsigned int http_status;
/**
- * The /salt GET operation handle.
+ * The /config GET operation handle.
*/
- struct ANASTASIS_SaltOperation *so;
+ struct ANASTASIS_ConfigOperation *so;
/**
* The salt value from server.
@@ -59,18 +59,18 @@ struct SaltState
/**
- * Function called with the results of a #ANASTASIS_salt().
+ * Function called with the results of a #ANASTASIS_config().
*
* @param cls closure
* @param http_status HTTP status of the request
- * @param salt salt from the server
+ * @param config config from the server
*/
static void
-salt_cb (void *cls,
- unsigned int http_status,
- const struct ANASTASIS_CRYPTO_PowSalt *salt)
+config_cb (void *cls,
+ unsigned int http_status,
+ const struct ANASTASIS_Config *config)
{
- struct SaltState *ss = cls;
+ struct ConfigState *ss = cls;
ss->so = NULL;
if (http_status != ss->http_status)
@@ -84,40 +84,40 @@ salt_cb (void *cls,
TALER_TESTING_interpreter_fail (ss->is);
return;
}
- if (NULL == salt)
+ if (NULL == config)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Salt is NULL, command %s in %s:%u\n",
+ "Config is NULL, command %s in %s:%u\n",
ss->is->commands[ss->is->ip].label,
__FILE__,
__LINE__);
TALER_TESTING_interpreter_fail (ss->is);
return;
}
- ss->salt = *salt;
+ ss->salt = config->salt;
TALER_TESTING_interpreter_next (ss->is);
}
/**
- * Run a "salt" CMD.
+ * Run a "config" CMD.
*
* @param cls closure.
* @param cmd command currently being run.
* @param is interpreter state.
*/
static void
-salt_run (void *cls,
- const struct TALER_TESTING_Command *cmd,
- struct TALER_TESTING_Interpreter *is)
+config_run (void *cls,
+ const struct TALER_TESTING_Command *cmd,
+ struct TALER_TESTING_Interpreter *is)
{
- struct SaltState *ss = cls;
+ struct ConfigState *ss = cls;
ss->is = is;
- ss->so = ANASTASIS_salt (is->ctx,
- ss->anastasis_url,
- salt_cb,
- ss);
+ ss->so = ANASTASIS_get_config (is->ctx,
+ ss->anastasis_url,
+ &config_cb,
+ ss);
if (NULL == ss->so)
{
GNUNET_break (0);
@@ -128,24 +128,24 @@ salt_run (void *cls,
/**
- * Free the state of a "salt" CMD, and possibly
+ * Free the state of a "config" CMD, and possibly
* cancel it if it did not complete.
*
* @param cls closure.
* @param cmd command being freed.
*/
static void
-salt_cleanup (void *cls,
- const struct TALER_TESTING_Command *cmd)
+config_cleanup (void *cls,
+ const struct TALER_TESTING_Command *cmd)
{
- struct SaltState *ss = cls;
+ struct ConfigState *ss = cls;
if (NULL != ss->so)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Command '%s' did not complete (salt)\n",
+ "Command '%s' did not complete (config)\n",
cmd->label);
- ANASTASIS_salt_cancel (ss->so);
+ ANASTASIS_config_cancel (ss->so);
ss->so = NULL;
}
GNUNET_free (ss);
@@ -162,12 +162,12 @@ salt_cleanup (void *cls,
* @return #GNUNET_OK on success
*/
static int
-salt_traits (void *cls,
- const void **ret,
- const char *trait,
- unsigned int index)
+config_traits (void *cls,
+ const void **ret,
+ const char *trait,
+ unsigned int index)
{
- struct SaltState *ss = cls;
+ struct ConfigState *ss = cls;
struct TALER_TESTING_Trait traits[] = {
ANASTASIS_TESTING_make_trait_salt (0,
@@ -183,33 +183,33 @@ salt_traits (void *cls,
/**
- * Make the "salt" command.
+ * Make the "config" command.
*
* @param label command label
* @param anastasis_url base URL of the ANASTASIS serving
- * the salt request.
+ * the config request.
* @param http_status expected HTTP status.
* @return the command
*/
struct TALER_TESTING_Command
-ANASTASIS_TESTING_cmd_salt (const char *label,
- const char *anastasis_url,
- unsigned int http_status)
+ANASTASIS_TESTING_cmd_config (const char *label,
+ const char *anastasis_url,
+ unsigned int http_status)
{
- struct SaltState *ss;
+ struct ConfigState *ss;
- ss = GNUNET_new (struct SaltState);
+ ss = GNUNET_new (struct ConfigState);
ss->http_status = http_status;
ss->anastasis_url = anastasis_url;
{
struct TALER_TESTING_Command cmd = {
.cls = ss,
.label = label,
- .run = &salt_run,
- .cleanup = &salt_cleanup,
- .traits = &salt_traits
+ .run = &config_run,
+ .cleanup = &config_cleanup,
+ .traits = &config_traits
};
return cmd;
}
-}
\ No newline at end of file
+}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: eliminate redundant /salt response, fix /terms and /privacy replies, expose more information in /config,
gnunet <=