From fb3c4bb1885f40a84bd534cd38f631b93bfa4a87 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 27 Feb 2022 22:35:51 +0100 Subject: -first rough cut towards implementing new /truths/ endpoint design (#7064) --- src/backend/anastasis-httpd.c | 48 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'src/backend/anastasis-httpd.c') diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c index 4ef6087..0c9d957 100644 --- a/src/backend/anastasis-httpd.c +++ b/src/backend/anastasis-httpd.c @@ -1,6 +1,6 @@ /* This file is part of Anastasis - (C) 2020 Anastasis SARL + (C) 2020-2022 Anastasis SARL Anastasis 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 @@ -416,12 +416,20 @@ url_handler (void *cls, { struct ANASTASIS_CRYPTO_TruthUUIDP tu; const char *pub_key_str; + const char *end; + size_t len; pub_key_str = &url[strlen ("/truth/")]; + end = strchr (pub_key_str, + '/'); + if (NULL == end) + len = strlen (pub_key_str); + else + len = end - pub_key_str; if (GNUNET_OK != GNUNET_STRINGS_string_to_data ( pub_key_str, - strlen (pub_key_str), + len, &tu, sizeof(tu))) { @@ -431,15 +439,17 @@ url_handler (void *cls, TALER_EC_GENERIC_PARAMETER_MALFORMED, "truth UUID"); } - if (0 == strcmp (method, - MHD_HTTP_METHOD_GET)) + if ( (NULL == end) && + (0 == strcmp (method, + MHD_HTTP_METHOD_GET)) ) { return AH_handler_truth_get (connection, &tu, hc); } - if (0 == strcmp (method, - MHD_HTTP_METHOD_POST)) + if ( (NULL == end) && + (0 == strcmp (method, + MHD_HTTP_METHOD_POST)) ) { return AH_handler_truth_post (connection, hc, @@ -447,6 +457,30 @@ url_handler (void *cls, upload_data, upload_data_size); } + if ( (NULL != end) && + (0 == strcmp (end, + "/solve")) && + (0 == strcmp (method, + MHD_HTTP_METHOD_POST)) ) + { + return AH_handler_truth_solve (connection, + hc, + &tu, + upload_data, + upload_data_size); + } + if ( (NULL != end) && + (0 == strcmp (end, + "/challenge")) && + (0 == strcmp (method, + MHD_HTTP_METHOD_POST)) ) + { + return AH_handler_truth_challenge (connection, + hc, + &tu, + upload_data, + upload_data_size); + } if (0 == strcmp (method, MHD_HTTP_METHOD_OPTIONS)) { @@ -498,6 +532,8 @@ do_shutdown (void *cls) (void) cls; AH_resume_all_bc (); AH_truth_shutdown (); + AH_truth_challenge_shutdown (); + AH_truth_solve_shutdown (); AH_truth_upload_shutdown (); if (NULL != mhd_task) { -- cgit v1.2.3