diff options
author | Cedric Zwahlen <cedric.zwahlen@students.bfh.ch> | 2024-03-14 22:47:05 +0100 |
---|---|---|
committer | Cedric Zwahlen <cedric.zwahlen@students.bfh.ch> | 2024-04-19 20:47:26 +0200 |
commit | 8601311517d3cf2a0a1e97fbd7ff96484c0fcb96 (patch) | |
tree | cd4365be7b6685b2e054cee96e7046c599818f12 | |
parent | 66709ae46c37ba15f8dae8fcd23fbbc77d334762 (diff) | |
download | exchange-8601311517d3cf2a0a1e97fbd7ff96484c0fcb96.tar.gz exchange-8601311517d3cf2a0a1e97fbd7ff96484c0fcb96.tar.bz2 exchange-8601311517d3cf2a0a1e97fbd7ff96484c0fcb96.zip |
Improve auditor request redirection
-rw-r--r-- | src/auditor/Makefile.am | 1 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd.c | 40 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd.h | 3 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation-del.c | 24 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation-del.h | 3 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation-get.c | 3 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_deposit-confirmation-get.h | 3 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_mhd.c | 6 | ||||
-rw-r--r-- | src/auditor/taler-auditor-httpd_mhd.h | 6 |
9 files changed, 60 insertions, 29 deletions
diff --git a/src/auditor/Makefile.am b/src/auditor/Makefile.am index 381c0b115..cf9705f6b 100644 --- a/src/auditor/Makefile.am +++ b/src/auditor/Makefile.am @@ -163,6 +163,7 @@ taler_auditor_httpd_SOURCES = \ taler-auditor-httpd.c taler-auditor-httpd.h \ taler-auditor-httpd_deposit-confirmation.c taler-auditor-httpd_deposit-confirmation.h \ taler-auditor-httpd_deposit-confirmation-get.c taler-auditor-httpd_deposit-confirmation-get.h \ + taler-auditor-httpd_deposit-confirmation-del.c taler-auditor-httpd_deposit-confirmation-del.h \ taler-auditor-httpd_mhd.c taler-auditor-httpd_mhd.h taler_auditor_httpd_LDADD = \ $(LIBGCRYPT_LIBS) \ diff --git a/src/auditor/taler-auditor-httpd.c b/src/auditor/taler-auditor-httpd.c index 42352285d..6cdd5b861 100644 --- a/src/auditor/taler-auditor-httpd.c +++ b/src/auditor/taler-auditor-httpd.c @@ -154,7 +154,8 @@ handle_config (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size) + size_t *upload_data_size, + const char *const args[]) { static json_t *ver; /* we build the response only once, keep around for next query! */ @@ -260,7 +261,39 @@ handle_mhd_request (void *cls, { struct TAH_RequestHandler *rh = &handlers[i]; - if ( (0 == strcasecmp (url, + unsigned int argsnr = 2; + + // arguments, and the url itself, and a terminator that is always null + const char *args[argsnr + 1]; + + memset(&args,0,sizeof (args)); + + size_t ulen = strlen (url) + 1; + char d[ulen]; + unsigned int i = 0; + char *sp; + + GNUNET_memcpy (d, + url, + ulen); + + args[i++] = strtok_r(d, "/", &sp); + + while ( (NULL != args[i - 1]) && (i < argsnr) ) + args[i++] = strtok_r(NULL, "/", &sp); + + printf ("args: %s, %s, %s\n", args[0], args[1], args[2]); + + // max length url could be + char argurl[strlen(url) + 2]; + strcpy(argurl,"/"); + + if (args[0] != NULL) + strcat(argurl,args[0]); + + printf ("reconstructed link: %s\n", argurl); + + if ( (0 == strcasecmp (argurl, rh->url)) && ( (NULL == rh->method) || (0 == strcasecmp (method, @@ -269,7 +302,8 @@ handle_mhd_request (void *cls, connection, con_cls, upload_data, - upload_data_size); + upload_data_size, + args); } #define NOT_FOUND "<html><title>404: not found</title></html>" return TALER_MHD_reply_static (connection, diff --git a/src/auditor/taler-auditor-httpd.h b/src/auditor/taler-auditor-httpd.h index 853722f09..5952c6934 100644 --- a/src/auditor/taler-auditor-httpd.h +++ b/src/auditor/taler-auditor-httpd.h @@ -95,7 +95,8 @@ struct TAH_RequestHandler struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size); + size_t *upload_data_size, + const char *const args[]); /** * Default response code. diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c index 27c645e2b..91e9688c4 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-del.c @@ -29,17 +29,16 @@ TAH_DEPOSIT_CONFIRMATION_handler_delete (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size) + size_t *upload_data_size, + const char *const args[]) { - MHD_RESULT res; + MHD_RESULT res; enum GNUNET_DB_QueryStatus qs; uint64_t row_id = 0; - // this requires param="" ? - row_id = MHD_lookup_connection_value (connection,MHD_GET_ARGUMENT_KIND, - "SERIAL_ID"); + printf("args in handler: %s\n",args[1]); if (GNUNET_SYSERR == TAH_plugin->preflight (TAH_plugin->cls)) @@ -50,25 +49,14 @@ TAH_DEPOSIT_CONFIRMATION_handler_delete (struct TAH_RequestHandler *rh, TALER_EC_GENERIC_DB_SETUP_FAILED, NULL); } -/* - // use this to write to the rowid? - if ( - (GNUNET_OK != - GNUNET_STRINGS_string_to_data (ps, - strlen (ps), - &coin_pubs[i], - sizeof(coin_pubs[i])))) { - // error - - }*/ // execute the transaction qs = TAH_plugin->delete_deposit_confirmation (TAH_plugin->cls,row_id); if (0 > qs) { - // goes in here if there was an error + // goes in here if there was an error with the transaction TALER_LOG_WARNING ("xyz\n"); return TALER_MHD_reply_with_error (connection, @@ -78,7 +66,7 @@ TAH_DEPOSIT_CONFIRMATION_handler_delete (struct TAH_RequestHandler *rh, } - // if an error occurs (not adapted to this specific delete) + // on success? return TALER_MHD_REPLY_JSON_PACK (connection, diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-del.h b/src/auditor/taler-auditor-httpd_deposit-confirmation-del.h index 0ffdf7033..ce07fc52b 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-del.h +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-del.h @@ -55,7 +55,8 @@ TAH_DEPOSIT_CONFIRMATION_handler_delete (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size); + size_t *upload_data_size, + const char *const args[]); #endif // SRC_TALER_AUDITOR_HTTPD_DEPOSIT_CONFIRMATION_DEL_H diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c index 265d625c4..33e3c7db7 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.c @@ -116,7 +116,8 @@ TAH_DEPOSIT_CONFIRMATION_handler_get (struct TAH_RequestHandler *rh, struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size)
+ size_t *upload_data_size,
+ const char *const args[])
{
json_t *ja;
enum GNUNET_DB_QueryStatus qs;
diff --git a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.h b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.h index 4f8064c54..0698a0d0a 100644 --- a/src/auditor/taler-auditor-httpd_deposit-confirmation-get.h +++ b/src/auditor/taler-auditor-httpd_deposit-confirmation-get.h @@ -52,7 +52,8 @@ TAH_DEPOSIT_CONFIRMATION_handler_get (struct TAH_RequestHandler *rh, struct MHD_Connection *connection,
void **connection_cls,
const char *upload_data,
- size_t *upload_data_size);
+ size_t *upload_data_size,
+ const char *const args[]);
#endif
diff --git a/src/auditor/taler-auditor-httpd_mhd.c b/src/auditor/taler-auditor-httpd_mhd.c index e5d2f71ee..0edbd303a 100644 --- a/src/auditor/taler-auditor-httpd_mhd.c +++ b/src/auditor/taler-auditor-httpd_mhd.c @@ -48,7 +48,8 @@ TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size) + size_t *upload_data_size, +const char *const args[]) { size_t dlen; @@ -82,7 +83,8 @@ TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size) + size_t *upload_data_size, +const char *const args[]) { (void) rh; (void) connection_cls; diff --git a/src/auditor/taler-auditor-httpd_mhd.h b/src/auditor/taler-auditor-httpd_mhd.h index 1804a1861..bb1fde2d3 100644 --- a/src/auditor/taler-auditor-httpd_mhd.h +++ b/src/auditor/taler-auditor-httpd_mhd.h @@ -44,7 +44,8 @@ TAH_MHD_handler_static_response (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size); + size_t *upload_data_size, + const char *const args[]); /** @@ -63,7 +64,8 @@ TAH_MHD_handler_agpl_redirect (struct TAH_RequestHandler *rh, struct MHD_Connection *connection, void **connection_cls, const char *upload_data, - size_t *upload_data_size); + size_t *upload_data_size, + const char *const args[]); #endif |