gnunet-svn
[Top][All Lists]
Advanced

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

[taler-anastasis] 02/02: worked on splitter


From: gnunet
Subject: [taler-anastasis] 02/02: worked on splitter
Date: Sun, 17 May 2020 19:51:55 +0200

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

dennis-neufeld pushed a commit to branch master
in repository anastasis.

commit bdf42ed83709793af99bb32d6e9bea529c4bd04c
Author: Dennis Neufeld <address@hidden>
AuthorDate: Sun May 17 17:51:48 2020 +0000

    worked on splitter
---
 src/cli/anastasis-cli-splitter.c | 129 ++++++++++++++++++++++++++++++++-------
 1 file changed, 107 insertions(+), 22 deletions(-)

diff --git a/src/cli/anastasis-cli-splitter.c b/src/cli/anastasis-cli-splitter.c
index 93036ad..a738f21 100644
--- a/src/cli/anastasis-cli-splitter.c
+++ b/src/cli/anastasis-cli-splitter.c
@@ -49,6 +49,11 @@ struct TruthUploadState
    */
   const char *backend_methods;
 
+  /**
+   * server salt of the anastasis backend.
+   */
+  const struct ANASTASIS_CRYPTO_SaltP *backend_salt;
+
   /**
    * insurance of the anastasis backend.
    */
@@ -141,6 +146,32 @@ struct TruthUploadState
   const struct ANASTASIS_Truth *truth;
 };
 
+/**
+ * State for a "salt" CMD.
+ */
+struct SaltState
+{
+  /**
+   * URL of the anastasis backend.
+   */
+  const char *anastasis_url;
+
+  /**
+   * Expected status code.
+   */
+  unsigned int http_status;
+
+  /**
+   * The /salt GET operation handle.
+   */
+  struct ANASTASIS_SaltOperation *so;
+
+  /**
+   * The salt value from server.
+   */
+  struct ANASTASIS_CRYPTO_SaltP salt;
+};
+
 /**
  * Global option '--me' to import json containing details of user.
  */
@@ -177,6 +208,40 @@ static struct TruthUploadState *tu_states;
 static unsigned int tu_states_length;
 
 
+/**
+ * Function called with the results of a #ANASTASIS_salt().
+ *
+ * @param cls closure
+ * @param http_status HTTP status of the request
+ * @param salt salt from the server
+ */
+static void
+salt_cb (void *cls,
+         unsigned int http_status,
+         const struct ANASTASIS_CRYPTO_SaltP *salt)
+{
+  struct SaltState *ss = cls;
+
+  ss->so = NULL;
+  if (http_status != ss->http_status)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Unexpected response code %u in %s:%u\n",
+                http_status,
+                __FILE__,
+                __LINE__);
+    return;
+  }
+  if (NULL == salt)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Salt is NULL in %s:%u\n",
+                __FILE__,
+                __LINE__);
+    return;
+  }
+  ss->salt = *salt;
+}
 
 
 static void
@@ -279,6 +344,33 @@ read_keyboard_command (void *cls)
                     strlen ("server add")))
   {
     // FIXME "server add" logic here
+    struct TruthUploadState tus;
+    struct SaltState *ss;
+
+    ss = GNUNET_new (struct SaltState);
+    const char *url = &buffer[strlen ("server add ")];
+    tus.backend_url = url;
+    ss->anastasis_url = tus.backend_url;
+    ss->http_status = MHD_HTTP_OK;
+    ss->so = ANASTASIS_salt (ctx,
+                             tus.backend_url,
+                             salt_cb,
+                             ss);
+    if (NULL == ss->so)
+    {
+      GNUNET_break (0);
+      return;
+    }
+    tus.backend_salt = &ss->salt;
+
+    // FIXME /terms request here, DELETE next 3 lines!
+    tus.backend_methods = "Secure-Question";
+    // TALER_amount_get_zero ("KUDOS", tus.backend_insurance);
+    // TALER_amount_get_zero ("KUDOS", tus.backend_cost);
+
+    GNUNET_array_append (tu_states,
+                         tu_states_length,
+                         tus);
     start_read_keyboard ();
     GNUNET_free (buffer);
     buffer = NULL;
@@ -295,22 +387,18 @@ read_keyboard_command (void *cls)
     {
       for (unsigned int i = 0; i < tu_states_length; i++)
       {
-        char *secret;
         if (0 == strcmp ("SMS", tu_states[i].method))
-          secret = tu_states[i].phone;
+          printf ("truth#%u: %s %s\n",
+                  i,
+                  tu_states[i].method,
+                  tu_states[i].phone);
         if (0 == strcmp ("Secure-Question", tu_states[i].method))
         {
-          secret = "\"";
-          strcat (secret, tu_states[i].secret_question);
-          strcat (secret, "\" ");
-          strcat (secret, "<OMITTED>");
-        }
-        if (NULL != secret)
-          printf ("truth#%u: %s %s %s\n",
+          printf ("truth#%u: %s \"%s\" <OMITTED>\n",
                   i,
-                  tu_states[i].backend_label,
                   tu_states[i].method,
-                  secret);
+                  tu_states[i].secret_question);
+        }
       }
     }
     else
@@ -365,22 +453,19 @@ read_keyboard_command (void *cls)
     {
       for (unsigned int i = 0; i < tu_states_length; i++)
       {
-        char *secret;
         if (0 == strcmp ("SMS", tu_states[i].method))
-          secret = tu_states[i].phone;
+          printf ("truth#%u: %s %s\n",
+                  i,
+                  tu_states[i].method,
+                  tu_states[i].phone);
         if (0 == strcmp ("Secure-Question", tu_states[i].method))
         {
-          secret = "\"";
-          strcat (secret, tu_states[i].secret_question);
-          strcat (secret, "\" \"");
-          strcat (secret, tu_states[i].secret_answer);
-          strcat (secret, "\"");
-        }
-        if (NULL != secret)
-          printf ("truth#%u: %s %s\n",
+          printf ("truth#%u: %s \"%s\" \"%s\"\n",
                   i,
                   tu_states[i].method,
-                  secret);
+                  tu_states[i].secret_question,
+                  tu_states[i].secret_answer);
+        }
       }
     }
     else

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

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