2015-01-08 18:37:20 +01:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2015-04-11 16:41:05 +02:00
|
|
|
Copyright (C) 2014, 2015 GNUnet e.V.
|
2015-01-08 18:37:20 +01:00
|
|
|
|
|
|
|
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, If not, see <http://www.gnu.org/licenses/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file taler-mint-httpd.c
|
|
|
|
* @brief Serve the HTTP interface of the mint
|
|
|
|
* @author Florian Dold
|
|
|
|
* @author Benedikt Mueller
|
|
|
|
* @author Christian Grothoff
|
|
|
|
*/
|
|
|
|
#include "platform.h"
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
#include <jansson.h>
|
|
|
|
#include <microhttpd.h>
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "taler_signatures.h"
|
2015-01-28 20:55:15 +01:00
|
|
|
#include "taler_util.h"
|
2015-01-16 13:50:07 +01:00
|
|
|
#include "taler-mint-httpd_parsing.h"
|
2015-01-08 18:37:20 +01:00
|
|
|
#include "taler-mint-httpd_mhd.h"
|
|
|
|
#include "taler-mint-httpd_deposit.h"
|
|
|
|
#include "taler-mint-httpd_withdraw.h"
|
|
|
|
#include "taler-mint-httpd_refresh.h"
|
2015-01-28 21:08:19 +01:00
|
|
|
#include "taler-mint-httpd_keystate.h"
|
2015-03-20 23:51:28 +01:00
|
|
|
#include "taler_mintdb_plugin.h"
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2015-04-11 16:38:09 +02:00
|
|
|
/**
|
|
|
|
* Which currency is used by this mint?
|
|
|
|
*/
|
|
|
|
char *TMH_mint_currency_string;
|
2015-01-08 18:37:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base directory of the mint (global)
|
|
|
|
*/
|
2015-03-27 19:58:40 +01:00
|
|
|
char *TMH_mint_directory;
|
2015-01-08 18:37:20 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The mint's configuration (global)
|
|
|
|
*/
|
|
|
|
struct GNUNET_CONFIGURATION_Handle *cfg;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Master public key (according to the
|
|
|
|
* configuration in the mint directory).
|
|
|
|
*/
|
2015-03-27 19:58:40 +01:00
|
|
|
struct GNUNET_CRYPTO_EddsaPublicKey TMH_master_public_key;
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2015-03-13 10:01:57 +01:00
|
|
|
/**
|
|
|
|
* In which format does this MINT expect wiring instructions?
|
|
|
|
*/
|
2015-04-12 22:52:54 +02:00
|
|
|
char *TMH_expected_wire_format;
|
2015-03-13 10:01:57 +01:00
|
|
|
|
2015-03-28 11:06:00 +01:00
|
|
|
/**
|
|
|
|
* Our DB plugin.
|
|
|
|
*/
|
|
|
|
struct TALER_MINTDB_Plugin *TMH_plugin;
|
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
/**
|
|
|
|
* The HTTP Daemon.
|
|
|
|
*/
|
|
|
|
static struct MHD_Daemon *mydaemon;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Port to run the daemon on.
|
|
|
|
*/
|
|
|
|
static uint16_t serve_port;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-01-16 14:04:02 +01:00
|
|
|
* Function called whenever MHD is done with a request. If the
|
|
|
|
* request was a POST, we may have stored a `struct Buffer *` in the
|
|
|
|
* @a con_cls that might still need to be cleaned up. Call the
|
|
|
|
* respective function to free the memory.
|
2015-01-08 18:37:20 +01:00
|
|
|
*
|
2015-01-16 14:04:02 +01:00
|
|
|
* @param cls client-defined closure
|
|
|
|
* @param connection connection handle
|
|
|
|
* @param con_cls value as set by the last call to
|
|
|
|
* the #MHD_AccessHandlerCallback
|
|
|
|
* @param toe reason for request termination
|
|
|
|
* @see #MHD_OPTION_NOTIFY_COMPLETED
|
|
|
|
* @ingroup request
|
2015-01-08 18:37:20 +01:00
|
|
|
*/
|
2015-01-16 14:04:02 +01:00
|
|
|
static void
|
|
|
|
handle_mhd_completion_callback (void *cls,
|
|
|
|
struct MHD_Connection *connection,
|
|
|
|
void **con_cls,
|
|
|
|
enum MHD_RequestTerminationCode toe)
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
2015-01-16 14:04:02 +01:00
|
|
|
if (NULL == *con_cls)
|
|
|
|
return;
|
2015-03-27 19:58:40 +01:00
|
|
|
TMH_PARSE_post_cleanup_callback (*con_cls);
|
2015-01-16 14:04:02 +01:00
|
|
|
*con_cls = NULL;
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle a request coming from libmicrohttpd.
|
|
|
|
*
|
|
|
|
* @param cls closure for MHD daemon (unused)
|
|
|
|
* @param connection the connection
|
|
|
|
* @param url the requested url
|
|
|
|
* @param method the method (POST, GET, ...)
|
2015-03-28 15:42:07 +01:00
|
|
|
* @param version HTTP version (ignored)
|
2015-01-08 18:37:20 +01:00
|
|
|
* @param upload_data request data
|
|
|
|
* @param upload_data_size size of @a upload_data in bytes
|
|
|
|
* @param con_cls closure for request (a `struct Buffer *`)
|
|
|
|
* @return MHD result code
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
handle_mhd_request (void *cls,
|
|
|
|
struct MHD_Connection *connection,
|
|
|
|
const char *url,
|
|
|
|
const char *method,
|
|
|
|
const char *version,
|
|
|
|
const char *upload_data,
|
|
|
|
size_t *upload_data_size,
|
|
|
|
void **con_cls)
|
|
|
|
{
|
2015-03-27 19:58:40 +01:00
|
|
|
static struct TMH_RequestHandler handlers[] =
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
{ "/", MHD_HTTP_METHOD_GET, "text/plain",
|
|
|
|
"Hello, I'm the mint\n", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_static_response, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/agpl", MHD_HTTP_METHOD_GET, "text/plain",
|
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/keys", MHD_HTTP_METHOD_GET, "application/json",
|
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_KS_handler_keys, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/keys", NULL, "text/plain",
|
|
|
|
"Only GET is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/withdraw/status", MHD_HTTP_METHOD_GET, "application/json",
|
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_WITHDRAW_handler_withdraw_status, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/withdraw/status", NULL, "text/plain",
|
|
|
|
"Only GET is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
|
|
|
{ "/withdraw/sign", MHD_HTTP_METHOD_POST, "application/json",
|
2015-01-08 18:37:20 +01:00
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_WITHDRAW_handler_withdraw_sign, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/withdraw/sign", NULL, "text/plain",
|
2015-03-29 14:17:52 +02:00
|
|
|
"Only POST is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
|
|
|
{ "/deposit", MHD_HTTP_METHOD_POST, "application/json",
|
|
|
|
NULL, 0,
|
|
|
|
&TMH_DEPOSIT_handler_deposit, MHD_HTTP_OK },
|
|
|
|
{ "/deposit", NULL, "text/plain",
|
|
|
|
"Only POST is allowed", 0,
|
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/refresh/melt", MHD_HTTP_METHOD_POST, "application/json",
|
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_REFRESH_handler_refresh_melt, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/refresh/melt", NULL, "text/plain",
|
|
|
|
"Only POST is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json",
|
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_REFRESH_handler_refresh_melt, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/refresh/reveal", NULL, "text/plain",
|
|
|
|
"Only POST is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
|
|
|
{ "/refresh/reveal", MHD_HTTP_METHOD_POST, "application/json",
|
2015-01-08 18:37:20 +01:00
|
|
|
NULL, 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_REFRESH_handler_refresh_reveal, MHD_HTTP_OK },
|
2015-01-08 18:37:20 +01:00
|
|
|
{ "/refresh/reveal", NULL, "text/plain",
|
2015-03-29 14:17:52 +02:00
|
|
|
"Only POST is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
|
|
|
{ "/refresh/link", MHD_HTTP_METHOD_GET, "application/json",
|
2015-01-08 18:37:20 +01:00
|
|
|
NULL, 0,
|
2015-03-29 14:17:52 +02:00
|
|
|
&TMH_REFRESH_handler_refresh_link, MHD_HTTP_OK },
|
|
|
|
{ "/refresh/link", NULL, "text/plain",
|
|
|
|
"Only GET is allowed", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_send_json_pack_error, MHD_HTTP_METHOD_NOT_ALLOWED },
|
2015-03-29 14:17:52 +02:00
|
|
|
|
2015-04-15 22:33:25 +02:00
|
|
|
#if HAVE_DEVELOPER
|
|
|
|
#endif
|
|
|
|
|
2015-01-08 18:37:20 +01:00
|
|
|
{ NULL, NULL, NULL, NULL, 0, 0 }
|
|
|
|
};
|
2015-03-27 19:58:40 +01:00
|
|
|
static struct TMH_RequestHandler h404 =
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
"", NULL, "text/html",
|
|
|
|
"<html><title>404: not found</title></html>", 0,
|
2015-03-27 19:58:40 +01:00
|
|
|
&TMH_MHD_handler_static_response, MHD_HTTP_NOT_FOUND
|
2015-01-08 18:37:20 +01:00
|
|
|
};
|
2015-03-27 19:58:40 +01:00
|
|
|
struct TMH_RequestHandler *rh;
|
2015-01-08 18:37:20 +01:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
|
|
|
|
"Handling request for URL '%s'\n",
|
|
|
|
url);
|
|
|
|
for (i=0;NULL != handlers[i].url;i++)
|
|
|
|
{
|
|
|
|
rh = &handlers[i];
|
|
|
|
if ( (0 == strcasecmp (url,
|
|
|
|
rh->url)) &&
|
|
|
|
( (NULL == rh->method) ||
|
|
|
|
(0 == strcasecmp (method,
|
|
|
|
rh->method)) ) )
|
|
|
|
return rh->handler (rh,
|
|
|
|
connection,
|
|
|
|
con_cls,
|
|
|
|
upload_data,
|
|
|
|
upload_data_size);
|
|
|
|
}
|
2015-03-27 19:58:40 +01:00
|
|
|
return TMH_MHD_handler_static_response (&h404,
|
2015-01-08 18:37:20 +01:00
|
|
|
connection,
|
|
|
|
con_cls,
|
|
|
|
upload_data,
|
|
|
|
upload_data_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load configuration parameters for the mint
|
|
|
|
* server into the corresponding global variables.
|
|
|
|
*
|
2015-03-28 15:42:07 +01:00
|
|
|
* @param mint_directory the mint's directory
|
2015-01-28 19:48:41 +01:00
|
|
|
* @return #GNUNET_OK on success
|
2015-01-08 18:37:20 +01:00
|
|
|
*/
|
|
|
|
static int
|
|
|
|
mint_serve_process_config (const char *mint_directory)
|
|
|
|
{
|
|
|
|
unsigned long long port;
|
2015-03-27 19:58:40 +01:00
|
|
|
char *TMH_master_public_key_str;
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2015-01-28 14:55:25 +01:00
|
|
|
cfg = TALER_config_load (mint_directory);
|
2015-01-08 18:37:20 +01:00
|
|
|
if (NULL == cfg)
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
2015-04-11 16:38:09 +02:00
|
|
|
"Failed to load mint configuration\n");
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
2015-04-11 16:38:09 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"mint",
|
|
|
|
"currency",
|
|
|
|
&TMH_mint_currency_string))
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
|
|
|
"No currency given in mint configuration.");
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-04-11 16:38:09 +02:00
|
|
|
}
|
|
|
|
if (strlen (TMH_mint_currency_string) >= TALER_CURRENCY_LEN)
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
|
|
|
"Currency `%s' longer than the allowed limit of %u characters.",
|
|
|
|
TMH_mint_currency_string,
|
|
|
|
(unsigned int) TALER_CURRENCY_LEN);
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-04-11 16:38:09 +02:00
|
|
|
}
|
2015-04-12 22:52:54 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"mint",
|
|
|
|
"wireformat",
|
|
|
|
&TMH_expected_wire_format))
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
|
|
|
"No wireformat given in mint configuration.");
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-04-12 22:52:54 +02:00
|
|
|
}
|
2015-01-08 18:37:20 +01:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
2015-03-27 19:58:40 +01:00
|
|
|
"mint",
|
|
|
|
"master_public_key",
|
|
|
|
&TMH_master_public_key_str))
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
fprintf (stderr,
|
|
|
|
"No master public key given in mint configuration.");
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
|
|
|
if (GNUNET_OK !=
|
2015-03-27 19:58:40 +01:00
|
|
|
GNUNET_CRYPTO_eddsa_public_key_from_string (TMH_master_public_key_str,
|
|
|
|
strlen (TMH_master_public_key_str),
|
|
|
|
&TMH_master_public_key))
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
fprintf (stderr,
|
|
|
|
"Invalid master public key given in mint configuration.");
|
2015-03-27 19:58:40 +01:00
|
|
|
GNUNET_free (TMH_master_public_key_str);
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-01-28 19:48:41 +01:00
|
|
|
}
|
2015-03-27 19:58:40 +01:00
|
|
|
GNUNET_free (TMH_master_public_key_str);
|
2015-01-08 18:37:20 +01:00
|
|
|
|
2015-03-28 11:06:00 +01:00
|
|
|
if (NULL ==
|
2015-03-28 12:29:35 +01:00
|
|
|
(TMH_plugin = TALER_MINTDB_plugin_load (cfg)))
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
fprintf (stderr,
|
2015-04-13 13:49:42 +02:00
|
|
|
"Failed to initialize DB subsystem\n");
|
|
|
|
return GNUNET_SYSERR;
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_number (cfg,
|
2015-04-12 22:52:54 +02:00
|
|
|
"mint",
|
|
|
|
"port",
|
2015-01-08 18:37:20 +01:00
|
|
|
&port))
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
2015-04-12 22:52:54 +02:00
|
|
|
"Missing or invalid configuration for the port of the mint\n");
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
|
|
|
|
2015-04-12 22:52:54 +02:00
|
|
|
if ( (0 == port) ||
|
|
|
|
(port > UINT16_MAX) )
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
fprintf (stderr,
|
2015-04-12 22:52:54 +02:00
|
|
|
"Invalid configuration (value out of range): %llu is not a valid port\n",
|
|
|
|
port);
|
2015-04-13 13:49:42 +02:00
|
|
|
return GNUNET_SYSERR;
|
2015-01-08 18:37:20 +01:00
|
|
|
}
|
2015-04-12 22:52:54 +02:00
|
|
|
serve_port = (uint16_t) port;
|
2015-01-08 18:37:20 +01:00
|
|
|
|
|
|
|
return GNUNET_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main function of the serve tool
|
|
|
|
*
|
|
|
|
* @param argc number of arguments from the command line
|
|
|
|
* @param argv command line arguments
|
|
|
|
* @return 0 ok, 1 on error
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
main (int argc, char *const *argv)
|
|
|
|
{
|
|
|
|
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
|
|
|
|
{'d', "mint-dir", "DIR",
|
|
|
|
"mint directory", 1,
|
2015-03-27 19:58:40 +01:00
|
|
|
&GNUNET_GETOPT_set_filename, &TMH_mint_directory},
|
2015-04-13 13:49:42 +02:00
|
|
|
TALER_GETOPT_OPTION_HELP ("HTTP server providing a RESTful API to access a Taler mint"),
|
|
|
|
GNUNET_GETOPT_OPTION_VERSION (VERSION "-" VCS_VERSION),
|
2015-01-08 18:37:20 +01:00
|
|
|
GNUNET_GETOPT_OPTION_END
|
|
|
|
};
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
GNUNET_assert (GNUNET_OK ==
|
2015-04-13 13:49:42 +02:00
|
|
|
GNUNET_log_setup ("taler-mint-httpd",
|
2015-01-08 18:37:20 +01:00
|
|
|
"INFO",
|
|
|
|
NULL));
|
2015-04-13 13:49:42 +02:00
|
|
|
if (0 >=
|
|
|
|
GNUNET_GETOPT_run ("taler-mint-httpd",
|
2015-01-08 18:37:20 +01:00
|
|
|
options,
|
2015-04-13 13:49:42 +02:00
|
|
|
argc, argv))
|
2015-01-08 18:37:20 +01:00
|
|
|
return 1;
|
2015-03-27 19:58:40 +01:00
|
|
|
if (NULL == TMH_mint_directory)
|
2015-01-08 18:37:20 +01:00
|
|
|
{
|
|
|
|
fprintf (stderr,
|
2015-04-13 13:49:42 +02:00
|
|
|
"Mint directory not specified\n");
|
2015-01-08 18:37:20 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-04-13 13:49:42 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
mint_serve_process_config (TMH_mint_directory))
|
2015-01-08 18:37:20 +01:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
mydaemon = MHD_start_daemon (MHD_USE_SELECT_INTERNALLY | MHD_USE_DEBUG,
|
|
|
|
serve_port,
|
|
|
|
NULL, NULL,
|
|
|
|
&handle_mhd_request, NULL,
|
2015-04-13 13:49:42 +02:00
|
|
|
MHD_OPTION_NOTIFY_COMPLETED, &handle_mhd_completion_callback, NULL,
|
2015-01-08 18:37:20 +01:00
|
|
|
MHD_OPTION_END);
|
|
|
|
|
|
|
|
if (NULL == mydaemon)
|
|
|
|
{
|
|
|
|
fprintf (stderr,
|
2015-04-13 13:49:42 +02:00
|
|
|
"Failed to start HTTP server.\n");
|
2015-01-08 18:37:20 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2015-03-27 19:58:40 +01:00
|
|
|
ret = TMH_KS_loop ();
|
2015-01-08 18:37:20 +01:00
|
|
|
MHD_stop_daemon (mydaemon);
|
2015-03-28 12:29:35 +01:00
|
|
|
TALER_MINTDB_plugin_unload (TMH_plugin);
|
2015-01-08 18:37:20 +01:00
|
|
|
return (GNUNET_OK == ret) ? 0 : 1;
|
|
|
|
}
|