gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-challenger] branch master updated (0ab453c -> 9eb507b)


From: gnunet
Subject: [taler-challenger] branch master updated (0ab453c -> 9eb507b)
Date: Fri, 28 Apr 2023 23:02:59 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository challenger.

    from 0ab453c  -fix db ftbfs
     new 0f545aa  -fix
     new 9eb507b  -fix

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/challenger/Makefile.am                  |  1 +
 src/challenger/challenger-httpd.c           |  5 +++
 src/challenger/challenger-httpd.h           |  5 +++
 src/challenger/challenger-httpd_challenge.c | 49 ++++++++++++++++-------------
 src/challenger/challenger-httpd_login.c     | 47 ++++++++++++++-------------
 src/challenger/challenger-httpd_setup.c     |  8 ++---
 src/challenger/challenger-httpd_solve.c     |  4 +--
 7 files changed, 70 insertions(+), 49 deletions(-)

diff --git a/src/challenger/Makefile.am b/src/challenger/Makefile.am
index 0498539..58fbac2 100644
--- a/src/challenger/Makefile.am
+++ b/src/challenger/Makefile.am
@@ -38,6 +38,7 @@ challenger_httpd_SOURCES = \
 challenger_httpd_LDADD = \
   $(top_builddir)/src/util/libchallengerutil.la \
   $(top_builddir)/src/challengerdb/libchallengerdb.la \
+  -ltalertemplating \
   -lmicrohttpd \
   -ljansson \
   -ltalermhd \
diff --git a/src/challenger/challenger-httpd.c 
b/src/challenger/challenger-httpd.c
index 01975fb..b147e39 100644
--- a/src/challenger/challenger-httpd.c
+++ b/src/challenger/challenger-httpd.c
@@ -80,6 +80,11 @@ struct CHALLENGER_DatabasePlugin *db;
  */
 struct GNUNET_TIME_Relative CH_validation_duration;
 
+/**
+ * How often do we retransmit the challenge.
+ */
+struct GNUNET_TIME_Relative CH_pin_retransmission_frequency;
+
 /**
  * A client has requested the given url using the given method
  * (#MHD_HTTP_METHOD_GET, #MHD_HTTP_METHOD_PUT,
diff --git a/src/challenger/challenger-httpd.h 
b/src/challenger/challenger-httpd.h
index 4a89c8b..d3e129a 100644
--- a/src/challenger/challenger-httpd.h
+++ b/src/challenger/challenger-httpd.h
@@ -134,6 +134,11 @@ extern struct GNUNET_CURL_Context *CH_ctx;
  */
 extern struct GNUNET_TIME_Relative CH_validation_duration;
 
+/**
+ * How often do we retransmit the challenge.
+ */
+extern struct GNUNET_TIME_Relative CH_pin_retransmission_frequency;
+
 /**
  * Kick MHD to run now, to be called after MHD_resume_connection().
  * Basically, we need to explicitly resume MHD's event loop whenever
diff --git a/src/challenger/challenger-httpd_challenge.c 
b/src/challenger/challenger-httpd_challenge.c
index 3b4e405..cf45cb5 100644
--- a/src/challenger/challenger-httpd_challenge.c
+++ b/src/challenger/challenger-httpd_challenge.c
@@ -23,6 +23,7 @@
 #include <gnunet/gnunet_util_lib.h>
 #include "challenger-httpd_challenge.h"
 #include <taler/taler_json_lib.h>
+#include <taler/taler_templating_lib.h>
 #include <taler/taler_merchant_service.h>
 #include <taler/taler_signatures.h>
 
@@ -41,7 +42,7 @@ struct ChallengeContext
   /**
    * 0-terminated address information submitted to us.
    */
-  char *addressp;
+  char *address;
 
   /**
    * Number of bytes in @a address, excluding 0-terminator.
@@ -65,6 +66,7 @@ cleanup_ctx (void *cls)
     GNUNET_break_op (MHD_YES ==
                      MHD_destroy_post_processor (bc->pp));
   }
+  GNUNET_free (bc->address);
   GNUNET_free (bc);
 }
 
@@ -135,7 +137,7 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
                                      sizeof (nonce)))
   {
     GNUNET_break_op (0);
-    return TALER_MHD_reply_with_error (connection,
+    return TALER_MHD_reply_with_error (hc->connection,
                                        MHD_HTTP_NOT_FOUND,
                                        TALER_EC_GENERIC_PARAMETER_MISSING,
                                        hc->path);
@@ -172,25 +174,25 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
     struct GNUNET_TIME_Absolute last_tx_time
       = GNUNET_TIME_absolute_get ();
     uint32_t last_pin
-      = GNUNET_CRYPTO_random_uint32 (GNUNET_CRYPTO_RANDOM_NONCE) % 100000000;
-    uint32_t pin_transmissions_left;
+      = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE,
+                                  100000000);
     uint32_t pin_attempts_left = 3; /* if addr is new */
     enum GNUNET_DB_QueryStatus qs;
     struct GNUNET_TIME_Absolute next_tx_time;
+    bool retransmit;
 
     next_tx_time = GNUNET_TIME_absolute_subtract (last_tx_time,
-                                                  get_duration);
+                                                  CH_validation_duration);
     qs = db->challenge_set_address_and_pin (db->cls,
                                             &nonce,
-                                            address,
+                                            bc->address,
                                             next_tx_time,
-                                            &last_tx,
+                                            &last_tx_time,
                                             &last_pin,
-                                            &pin_transmissions_left,
-                                            &pin_attempts_left);
+                                            &retransmit);
     switch (qs)
     {
-    case GNUNET_DB_SUCCESS_HARD_ERROR:
+    case GNUNET_DB_STATUS_HARD_ERROR:
       {
         enum GNUNET_GenericReturnValue ret;
         json_t *root = json_object ();
@@ -200,7 +202,9 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
         ret = TALER_TEMPLATING_reply (hc->connection,
                                       MHD_HTTP_INTERNAL_SERVER_ERROR,
                                       "internal-server-error.must",
-                                      NULL);
+                                      NULL,
+                                      NULL,
+                                      root);
         json_decref (root);
         if (GNUNET_SYSERR == ret)
         {
@@ -210,10 +214,10 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
         GNUNET_break (GNUNET_OK == ret);
         return MHD_YES;
       }
-    case GNUNET_DB_SUCCESS_SOFT_ERROR:
+    case GNUNET_DB_STATUS_SOFT_ERROR:
       GNUNET_break (0);
       return GNUNET_NO;
-    case GNUNET_DB_SUCCESS_NO_RESULTS:
+    case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
       {
         enum GNUNET_GenericReturnValue ret;
         json_t *root = json_object ();
@@ -222,7 +226,9 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
         ret = TALER_TEMPLATING_reply (hc->connection,
                                       MHD_HTTP_NOT_FOUND,
                                       "validation-unknown.must",
-                                      NULL);
+                                      NULL,
+                                      NULL,
+                                      root);
         json_decref (root);
         if (GNUNET_SYSERR == ret)
         {
@@ -232,7 +238,7 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
         GNUNET_break (GNUNET_OK == ret);
         return MHD_YES;
       }
-    case GNUNET_DB_SUCCESS_ONE_RESULT:
+    case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
       break;
     }
     if (0 == pin_attempts_left)
@@ -242,7 +248,7 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
 
       GNUNET_assert (NULL != root);
       ret = TALER_TEMPLATING_reply (hc->connection,
-                                    MHD_HTTP_XXX,
+                                    MHD_HTTP_TOO_MANY_REQUESTS,
                                     "attempts-exhausted.must",
                                     NULL,
                                     NULL,
@@ -256,10 +262,8 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
       GNUNET_break (GNUNET_OK == ret);
       return MHD_YES;
     }
-    if ( (GNUNET_TIME_relative_cmp (duration,
-                                    (>),
-                                    CH_pin_retransmission_frequency)) &&
-         (pin_transmissions_left > 0) )
+
+    if (retransmit)
     {
       /* Retransmit PIN */
     }
@@ -270,8 +274,9 @@ CH_handler_challenge (struct CH_HandlerContext *hc,
       args = GNUNET_JSON_PACK (
         GNUNET_JSON_pack_uint64 ("attempts_left",
                                  pin_attempts_left),
-        GNUNET_JSON_pack_absolute_time ("next_tx_time",
-                                        next_tx_time),
+        GNUNET_JSON_pack_timestamp ("next_tx_time",
+                                    GNUNET_TIME_absolute_to_timestamp (
+                                      next_tx_time))
         );
       ret = TALER_TEMPLATING_reply (hc->connection,
                                     MHD_HTTP_OK,
diff --git a/src/challenger/challenger-httpd_login.c 
b/src/challenger/challenger-httpd_login.c
index f31ff24..d7273c9 100644
--- a/src/challenger/challenger-httpd_login.c
+++ b/src/challenger/challenger-httpd_login.c
@@ -21,6 +21,7 @@
 #include "platform.h"
 #include "challenger-httpd.h"
 #include <gnunet/gnunet_util_lib.h>
+#include <taler/taler_templating_lib.h>
 #include "challenger-httpd_login.h"
 
 
@@ -43,19 +44,19 @@ CH_handler_login (struct CH_HandlerContext *hc,
                                      sizeof (nonce)))
   {
     GNUNET_break_op (0);
-    return TALER_MHD_reply_with_error (connection,
+    return TALER_MHD_reply_with_error (hc->connection,
                                        MHD_HTTP_NOT_FOUND,
                                        TALER_EC_GENERIC_PARAMETER_MISSING,
                                        hc->path);
   }
   response_type
-    = MHD_lookup_connection_value (connection,
+    = MHD_lookup_connection_value (hc->connection,
                                    MHD_GET_ARGUMENT_KIND,
                                    "response_type");
   if (NULL == response_type)
   {
     GNUNET_break_op (0);
-    return TALER_MHD_reply_with_error (connection,
+    return TALER_MHD_reply_with_error (hc->connection,
                                        MHD_HTTP_BAD_REQUEST,
                                        TALER_EC_GENERIC_PARAMETER_MISSING,
                                        "response_type");
@@ -64,7 +65,7 @@ CH_handler_login (struct CH_HandlerContext *hc,
                    "code"))
   {
     GNUNET_break_op (0);
-    return TALER_MHD_reply_with_error (connection,
+    return TALER_MHD_reply_with_error (hc->connection,
                                        MHD_HTTP_BAD_REQUEST,
                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
                                        "response_type (mus be 'code')");
@@ -75,13 +76,13 @@ CH_handler_login (struct CH_HandlerContext *hc,
     char dummy;
 
     client_id_str
-      = MHD_lookup_connection_value (connection,
+      = MHD_lookup_connection_value (hc->connection,
                                      MHD_GET_ARGUMENT_KIND,
                                      "client_id");
     if (NULL == client_id_str)
     {
       GNUNET_break_op (0);
-      return TALER_MHD_reply_with_error (connection,
+      return TALER_MHD_reply_with_error (hc->connection,
                                          MHD_HTTP_BAD_REQUEST,
                                          TALER_EC_GENERIC_PARAMETER_MISSING,
                                          "client_id");
@@ -92,14 +93,14 @@ CH_handler_login (struct CH_HandlerContext *hc,
                      &dummy))
     {
       GNUNET_break_op (0);
-      return TALER_MHD_reply_with_error (connection,
+      return TALER_MHD_reply_with_error (hc->connection,
                                          MHD_HTTP_BAD_REQUEST,
                                          TALER_EC_GENERIC_PARAMETER_MALFORMED,
                                          "client_id");
     }
   }
   redirect_uri
-    = MHD_lookup_connection_value (connection,
+    = MHD_lookup_connection_value (hc->connection,
                                    MHD_GET_ARGUMENT_KIND,
                                    "redirect_uri");
   if ( (NULL != redirect_uri) &&
@@ -111,19 +112,19 @@ CH_handler_login (struct CH_HandlerContext *hc,
                       strlen ("https://";))) )
   {
     GNUNET_break_op (0);
-    return TALER_MHD_reply_with_error (connection,
+    return TALER_MHD_reply_with_error (hc->connection,
                                        MHD_HTTP_BAD_REQUEST,
                                        TALER_EC_GENERIC_PARAMETER_MALFORMED,
                                        "redirect_uri (has to start with 
'http://' or 'https://')");
   }
   state
-    = MHD_lookup_connection_value (connection,
+    = MHD_lookup_connection_value (hc->connection,
                                    MHD_GET_ARGUMENT_KIND,
                                    "state");
   if (NULL == state)
     state = "";
   scope
-    = MHD_lookup_connection_value (connection,
+    = MHD_lookup_connection_value (hc->connection,
                                    MHD_GET_ARGUMENT_KIND,
                                    "scope");
   (void) scope; /* ignored */
@@ -135,14 +136,14 @@ CH_handler_login (struct CH_HandlerContext *hc,
     qs = db->login_start (db->cls,
                           &nonce,
                           client_id,
-                          client_scope,
-                          client_state,
-                          client_redirect_url,
+                          scope,
+                          state,
+                          redirect_uri,
                           &last_address,
                           &address_attempts_left);
     switch (qs)
     {
-    case GNUNET_DB_SUCCESS_HARD_ERROR:
+    case GNUNET_DB_STATUS_HARD_ERROR:
       {
         enum GNUNET_GenericReturnValue ret;
         json_t *root = json_object ();
@@ -152,7 +153,9 @@ CH_handler_login (struct CH_HandlerContext *hc,
         ret = TALER_TEMPLATING_reply (hc->connection,
                                       MHD_HTTP_INTERNAL_SERVER_ERROR,
                                       "internal-server-error.must",
-                                      NULL);
+                                      NULL,
+                                      NULL,
+                                      root);
         json_decref (root);
         if (GNUNET_SYSERR == ret)
         {
@@ -162,10 +165,10 @@ CH_handler_login (struct CH_HandlerContext *hc,
         GNUNET_break (GNUNET_OK == ret);
         return MHD_YES;
       }
-    case GNUNET_DB_SUCCESS_SOFT_ERROR:
+    case GNUNET_DB_STATUS_SOFT_ERROR:
       GNUNET_break (0);
       return GNUNET_NO;
-    case GNUNET_DB_SUCCESS_NO_RESULTS:
+    case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
       {
         enum GNUNET_GenericReturnValue ret;
         json_t *root = json_object ();
@@ -174,7 +177,9 @@ CH_handler_login (struct CH_HandlerContext *hc,
         ret = TALER_TEMPLATING_reply (hc->connection,
                                       MHD_HTTP_NOT_FOUND,
                                       "validation-unknown.must",
-                                      NULL);
+                                      NULL,
+                                      NULL,
+                                      root);
         json_decref (root);
         if (GNUNET_SYSERR == ret)
         {
@@ -184,7 +189,7 @@ CH_handler_login (struct CH_HandlerContext *hc,
         GNUNET_break (GNUNET_OK == ret);
         return MHD_YES;
       }
-    case GNUNET_DB_SUCCESS_ONE_RESULT:
+    case GNUNET_DB_STATUS_SUCCESS_ONE_RESULT:
       break;
     }
     {
@@ -197,7 +202,7 @@ CH_handler_login (struct CH_HandlerContext *hc,
         GNUNET_JSON_pack_string ("last_address",
                                  last_address),
         GNUNET_JSON_pack_uint64 ("changes_left",
-                                 address_attempts_left),
+                                 address_attempts_left)
         );
       ret = TALER_TEMPLATING_reply (
         hc->connection,
diff --git a/src/challenger/challenger-httpd_setup.c 
b/src/challenger/challenger-httpd_setup.c
index 2e02f3d..035c961 100644
--- a/src/challenger/challenger-httpd_setup.c
+++ b/src/challenger/challenger-httpd_setup.c
@@ -96,10 +96,10 @@ CH_handler_setup (struct CH_HandlerContext *hc,
     GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
                                 &nonce,
                                 sizeof (nonce));
-    qs = db->validation_setup (db->cls,
-                               client_id,
-                               &nonce,
-                               expiration_time);
+    qs = db->setup_nonce (db->cls,
+                          client_id,
+                          &nonce,
+                          expiration_time);
     switch (qs)
     {
     case GNUNET_DB_STATUS_HARD_ERROR:
diff --git a/src/challenger/challenger-httpd_solve.c 
b/src/challenger/challenger-httpd_solve.c
index a5aab01..0d5c436 100644
--- a/src/challenger/challenger-httpd_solve.c
+++ b/src/challenger/challenger-httpd_solve.c
@@ -65,7 +65,7 @@ cleanup_ctx (void *cls)
     GNUNET_break_op (MHD_YES ==
                      MHD_destroy_post_processor (bc->pp));
   }
-  GNUENT_free (bc->pin);
+  GNUNET_free (bc->pin);
   GNUNET_free (bc);
 }
 
@@ -136,7 +136,7 @@ CH_handler_solve (struct CH_HandlerContext *hc,
                                      sizeof (nonce)))
   {
     GNUNET_break_op (0);
-    return TALER_MHD_reply_with_error (connection,
+    return TALER_MHD_reply_with_error (hc->connection,
                                        MHD_HTTP_NOT_FOUND,
                                        TALER_EC_GENERIC_PARAMETER_MISSING,
                                        hc->path);

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]