summaryrefslogtreecommitdiff
path: root/src/auditor/taler-auditor-httpd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/auditor/taler-auditor-httpd.c')
-rw-r--r--src/auditor/taler-auditor-httpd.c79
1 files changed, 66 insertions, 13 deletions
diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c
index 47d618669..59bd849bc 100644
--- a/src/auditor/taler-auditor-httpd.c
+++ b/src/auditor/taler-auditor-httpd.c
@@ -31,7 +31,7 @@
#include "taler_auditordb_lib.h"
#include "taler_exchangedb_lib.h"
#include "taler-auditor-httpd_deposit-confirmation.h"
-#include "taler-auditor-httpd_exchanges.h"
+#include "taler-auditor-httpd_deposit-confirmation-get.h"
#include "taler-auditor-httpd_mhd.h"
#include "taler-auditor-httpd.h"
@@ -48,7 +48,8 @@
* release version, and the format is NOT the same that semantic
* versioning uses either.
*/
-#define AUDITOR_PROTOCOL_VERSION "0:0:0"
+#define AUDITOR_PROTOCOL_VERSION "1:0:1"
+
/**
* Backlog for listen operation on unix domain sockets.
@@ -81,6 +82,12 @@ struct TALER_EXCHANGEDB_Plugin *TAH_eplugin;
static struct TALER_AuditorPublicKeyP auditor_pub;
/**
+ * Exchange master public key (according to the
+ * configuration). (global)
+ */
+struct TALER_MasterPublicKeyP TAH_master_public_key;
+
+/**
* Default timeout in seconds for HTTP requests.
*/
static unsigned int connection_timeout = 30;
@@ -132,7 +139,7 @@ handle_mhd_completion_callback (void *cls,
/**
- * Handle a "/version" request.
+ * Handle a "/config" request.
*
* @param rh context of the handler
* @param connection the MHD connection to handle
@@ -142,11 +149,11 @@ handle_mhd_completion_callback (void *cls,
* @return MHD result code
*/
static MHD_RESULT
-handle_version (struct TAH_RequestHandler *rh,
- struct MHD_Connection *connection,
- void **connection_cls,
- const char *upload_data,
- size_t *upload_data_size)
+handle_config (struct TAH_RequestHandler *rh,
+ struct MHD_Connection *connection,
+ void **connection_cls,
+ const char *upload_data,
+ size_t *upload_data_size)
{
static json_t *ver; /* we build the response only once, keep around for next query! */
@@ -157,12 +164,18 @@ handle_version (struct TAH_RequestHandler *rh,
if (NULL == ver)
{
ver = GNUNET_JSON_PACK (
+ GNUNET_JSON_pack_string ("name",
+ "taler-auditor"),
GNUNET_JSON_pack_string ("version",
AUDITOR_PROTOCOL_VERSION),
+ GNUNET_JSON_pack_string ("implementation",
+ "urn:net:taler:specs:taler-auditor:c-reference"),
GNUNET_JSON_pack_string ("currency",
TAH_currency),
GNUNET_JSON_pack_data_auto ("auditor_public_key",
- &auditor_pub));
+ &auditor_pub),
+ GNUNET_JSON_pack_data_auto ("exchange_master_public_key",
+ &TAH_master_public_key));
}
if (NULL == ver)
{
@@ -204,12 +217,15 @@ handle_mhd_request (void *cls,
{ "/deposit-confirmation", MHD_HTTP_METHOD_PUT, "application/json",
NULL, 0,
&TAH_DEPOSIT_CONFIRMATION_handler, MHD_HTTP_OK },
- { "/exchanges", MHD_HTTP_METHOD_GET, "application/json",
+ { "/deposit-confirmation", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0,
- &TAH_EXCHANGES_handler, MHD_HTTP_OK },
- { "/version", MHD_HTTP_METHOD_GET, "application/json",
+ &TAH_DEPOSIT_CONFIRMATION_handler_get, MHD_HTTP_OK },
+// { "/deposit-confirmation", MHD_HTTP_METHOD_DELETE, "application/json",
+// NULL, 0,
+// &TAH_DEPOSIT_CONFIRMATION_delete, MHD_HTTP_OK },
+ { "/config", MHD_HTTP_METHOD_GET, "application/json",
NULL, 0,
- &handle_version, MHD_HTTP_OK },
+ &handle_config, MHD_HTTP_OK },
/* Landing page, for now tells humans to go away
* (NOTE: ideally, the reverse proxy will respond with a nicer page) */
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
@@ -298,6 +314,40 @@ auditor_serve_process_config (void)
{
return GNUNET_SYSERR;
}
+
+ {
+ char *master_public_key_str;
+
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ "exchange",
+ "MASTER_PUBLIC_KEY",
+ &master_public_key_str))
+ {
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "MASTER_PUBLIC_KEY");
+ return GNUNET_SYSERR;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CRYPTO_eddsa_public_key_from_string (
+ master_public_key_str,
+ strlen (master_public_key_str),
+ &TAH_master_public_key.eddsa_pub))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ "exchange",
+ "MASTER_PUBLIC_KEY",
+ "invalid base32 encoding for a master public key");
+ GNUNET_free (master_public_key_str);
+ return GNUNET_SYSERR;
+ }
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Launching auditor for exchange `%s'...\n",
+ master_public_key_str);
+ GNUNET_free (master_public_key_str);
+ }
+
{
char *pub;
@@ -410,6 +460,9 @@ run (void *cls,
enum TALER_MHD_GlobalOptions go;
int fh;
+ (void) cls;
+ (void) args;
+ (void) cfgfile;
go = TALER_MHD_GO_NONE;
if (auditor_connection_close)
go |= TALER_MHD_GO_FORCE_CONNECTION_CLOSE;