gnunet-svn
[Top][All Lists]
Advanced

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

[taler-sync] branch master updated: implement fresh option also in clien


From: gnunet
Subject: [taler-sync] branch master updated: implement fresh option also in client API
Date: Wed, 02 Dec 2020 20:20:10 +0100

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

grothoff pushed a commit to branch master
in repository sync.

The following commit(s) were added to refs/heads/master by this push:
     new 67e6d86  implement fresh option also in client API
67e6d86 is described below

commit 67e6d86c6ad7e4c487fff55bb7eb9c93114a3446
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Wed Dec 2 20:20:08 2020 +0100

    implement fresh option also in client API
---
 src/include/sync_service.h                  | 26 ++++++++++-
 src/lib/sync_api_upload.c                   | 67 ++++++++++++++---------------
 src/sync/sync-httpd_backup_post.c           |  3 +-
 src/testing/testing_api_cmd_backup_upload.c |  4 +-
 4 files changed, 61 insertions(+), 39 deletions(-)

diff --git a/src/include/sync_service.h b/src/include/sync_service.h
index 80d18ea..43d1757 100644
--- a/src/include/sync_service.h
+++ b/src/include/sync_service.h
@@ -208,6 +208,28 @@ typedef void
  */
 struct SYNC_UploadOperation;
 
+/**
+ * Options for payment.
+ */
+enum SYNC_PaymentOptions
+{
+  /**
+   * No special options.
+   */
+  SYNC_PO_NONE = 0,
+
+  /**
+   * Trigger payment even if sync does not require it
+   * yet (forced payment).
+   */
+  SYNC_PO_FORCE_PAYMENT = 1,
+
+  /**
+   * Request a fresh order to be created, say because the
+   * existing one was claimed (but not paid) by another wallet.
+   */
+  SYNC_PO_FRESH_ORDER = 2
+};
 
 /**
  * Upload a @a backup to a Sync server. Note that @a backup must
@@ -235,7 +257,7 @@ struct SYNC_UploadOperation;
  * @param backup the encrypted backup, must remain in
  *         memory until we are done with the operation!
  * @param payment_requested #GNUNET_YES if the client wants to pay more for 
the account now
- * @param paid_order_id order ID of a recent payment made, or NULL for none
+ * @param po payment options
  * @param cb function to call with the result
  * @param cb_cls closure for @a cb
  * @return handle for the operation
@@ -247,7 +269,7 @@ SYNC_upload (struct GNUNET_CURL_Context *ctx,
              const struct GNUNET_HashCode *prev_backup_hash,
              size_t backup_size,
              const void *backup,
-             int payment_requested,
+             enum SYNC_PaymentOptions po,
              const char *paid_order_id,
              SYNC_UploadCallback cb,
              void *cb_cls);
diff --git a/src/lib/sync_api_upload.c b/src/lib/sync_api_upload.c
index 100d10c..4ac5ee9 100644
--- a/src/lib/sync_api_upload.c
+++ b/src/lib/sync_api_upload.c
@@ -240,35 +240,6 @@ handle_header (char *buffer,
 }
 
 
-/**
- * Upload a @a backup to a Sync server. Note that @a backup must
- * have already been compressed, padded and encrypted by the
- * client.
- *
- * While @a pub is theoretically protected by the HTTPS protocol and
- * required to access the backup, it should be assumed that an
- * adversary might be able to download the backups from the Sync
- * server -- or even run the Sync server. Thus, strong encryption
- * is essential and NOT implemented by this function.
- *
- * The use of Anastasis to safely store the Sync encryption keys and
- * @a pub is recommended.  Storing @a priv in Anastasis depends on
- * your priorities: without @a priv, further updates to the backup are
- * not possible, and the user would have to pay for another
- * account. OTOH, without @a priv an adversary that compromised
- * Anastasis can only read the backups, but not alter or destroy them.
- *
- * @param ctx for HTTP client request processing
- * @param base_url base URL of the Sync server
- * @param priv private key of an account with the server
- * @param prev_backup_hash hash of the previous backup, NULL for the first 
upload ever
- * @param backup_size number of bytes in @a backup
- * @param payment_requested #GNUNET_YES if the client wants to pay more for 
the account now
- * @param paid_order_id order ID of a recent payment made, or NULL for none
- * @param cb function to call with the result
- * @param cb_cls closure for @a cb
- * @return handle for the operation
- */
 struct SYNC_UploadOperation *
 SYNC_upload (struct GNUNET_CURL_Context *ctx,
              const char *base_url,
@@ -276,7 +247,7 @@ SYNC_upload (struct GNUNET_CURL_Context *ctx,
              const struct GNUNET_HashCode *prev_backup_hash,
              size_t backup_size,
              const void *backup,
-             int payment_requested,
+             enum SYNC_PaymentOptions po,
              const char *paid_order_id,
              SYNC_UploadCallback cb,
              void *cb_cls)
@@ -382,16 +353,42 @@ SYNC_upload (struct GNUNET_CURL_Context *ctx,
                      "backups/%s",
                      account_s);
     GNUNET_free (account_s);
-    uo->url = (GNUNET_YES == payment_requested)
-              ? TALER_url_join (base_url,
+    if  (0 != (po & SYNC_PO_FRESH_ORDER))
+    {
+      uo->url = (0 != (po & SYNC_PO_FORCE_PAYMENT))
+      ? TALER_url_join (base_url,
+                        path,
+                        "fresh",
+                        "y",
+                        "pay",
+                        "y",
+                        (NULL != paid_order_id)
+                                ? "paying"
+                                : NULL,
+                        paid_order_id,
+                        NULL)
+              : TALER_url_join (base_url,
                                 path,
-                                "pay",
+                                "fresh",
                                 "y",
                                 (NULL != paid_order_id)
                                 ? "paying"
                                 : NULL,
                                 paid_order_id,
-                                NULL)
+                                NULL);
+    }
+    else
+    {
+      uo->url = (0 != (po & SYNC_PO_FORCE_PAYMENT))
+      ? TALER_url_join (base_url,
+                        path,
+                        "pay",
+                        "y",
+                        (NULL != paid_order_id)
+                                ? "paying"
+                                : NULL,
+                        paid_order_id,
+                        NULL)
               : TALER_url_join (base_url,
                                 path,
                                 (NULL != paid_order_id)
@@ -399,6 +396,8 @@ SYNC_upload (struct GNUNET_CURL_Context *ctx,
                                 : NULL,
                                 paid_order_id,
                                 NULL);
+    }
+
     GNUNET_free (path);
   }
   uo->ctx = ctx;
diff --git a/src/sync/sync-httpd_backup_post.c 
b/src/sync/sync-httpd_backup_post.c
index fb47ac0..4993e0f 100644
--- a/src/sync/sync-httpd_backup_post.c
+++ b/src/sync/sync-httpd_backup_post.c
@@ -684,8 +684,7 @@ SH_backup_post (struct MHD_Connection *connection,
       fresh = MHD_lookup_connection_value (connection,
                                            MHD_GET_ARGUMENT_KIND,
                                            "fresh");
-      if (0 == strcasecmp (fresh,
-                           "yes"))
+      if (NULL != fresh)
         bc->force_fresh_order = true;
     }
     *con_cls = bc;
diff --git a/src/testing/testing_api_cmd_backup_upload.c 
b/src/testing/testing_api_cmd_backup_upload.c
index 6a37ffb..1491db0 100644
--- a/src/testing/testing_api_cmd_backup_upload.c
+++ b/src/testing/testing_api_cmd_backup_upload.c
@@ -339,7 +339,9 @@ backup_upload_run (void *cls,
                          : NULL,
                          bus->backup_size,
                          bus->backup,
-                         (0 != (SYNC_TESTING_UO_REQUEST_PAYMENT & bus->uopt)),
+                         (0 != (SYNC_TESTING_UO_REQUEST_PAYMENT & bus->uopt))
+                         ? SYNC_PO_FORCE_PAYMENT
+                         : SYNC_PO_NONE,
                          bus->payment_order_req,
                          &backup_upload_cb,
                          bus);

-- 
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]