gnunet-svn
[Top][All Lists]
Advanced

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

[taler-sync] branch master updated: update config


From: gnunet
Subject: [taler-sync] branch master updated: update config
Date: Thu, 14 Nov 2019 23:05:52 +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 d0e2222  update config
d0e2222 is described below

commit d0e22221b9fd3627d63e484b8957337d2638a871
Author: Christian Grothoff <address@hidden>
AuthorDate: Thu Nov 14 23:05:49 2019 +0100

    update config
---
 src/sync/Makefile.am        |  7 +++++--
 src/sync/sync-httpd.c       | 48 +++++++++++++++++++++++++++++++++++++-----
 src/sync/sync-httpd.h       | 10 +++++++++
 src/sync/sync-httpd_terms.c | 51 +++++++++++++++++++++++++++++++++++++++++++++
 src/sync/sync-httpd_terms.h | 43 ++++++++++++++++++++++++++++++++++++++
 src/sync/sync.conf          |  7 ++++++-
 6 files changed, 158 insertions(+), 8 deletions(-)

diff --git a/src/sync/Makefile.am b/src/sync/Makefile.am
index ad60afe..0bb6703 100644
--- a/src/sync/Makefile.am
+++ b/src/sync/Makefile.am
@@ -11,14 +11,17 @@ bin_PROGRAMS = \
 
 sync_httpd_SOURCES = \
   sync-httpd.c sync-httpd.h \
+  sync-httpd_backup.c sync-httpd_backup.h \
+  sync-httpd_mhd.c sync-httpd_mhd.h \
   sync-httpd_parsing.c sync-httpd_parsing.h \
   sync-httpd_responses.c sync-httpd_responses.h \
-  sync-httpd_mhd.c sync-httpd_mhd.h \
-  sync-httpd_backup.c sync-httpd_backup.h
+  sync-httpd_terms.c sync-httpd_terms.h
 sync_httpd_LDADD = \
   $(top_builddir)/src/syncdb/libsyncdb.la \
   -lmicrohttpd \
   -ljansson \
+  -ltalerjson \
+  -ltalerutil \
   -lgnunetcurl \
   -lgnunetjson \
   -lgnunetutil
diff --git a/src/sync/sync-httpd.c b/src/sync/sync-httpd.c
index beb0e20..d7f6eb5 100644
--- a/src/sync/sync-httpd.c
+++ b/src/sync/sync-httpd.c
@@ -27,6 +27,7 @@
 #include "sync-httpd_mhd.h"
 #include "sync_database_lib.h"
 #include "sync-httpd_backup.h"
+#include "sync-httpd_terms.h"
 
 /**
  * Backlog for listen operation on unix-domain sockets.
@@ -43,6 +44,16 @@ static long long unsigned port;
  */
 int SH_sync_connection_close;
 
+/**
+ * Upload limit to the service, in megabytes.
+ */
+unsigned long long int SH_upload_limit_mb;
+
+/**
+ * Annual fee for the backup account.
+ */
+struct TALER_Amount SH_annual_fee;
+
 /**
  * Task running the HTTP server.
  */
@@ -76,17 +87,17 @@ struct SYNC_DatabasePlugin *db;
 
 
 /**
- * Return GNUNET_YES if given a valid correlation ID and
- * GNUNET_NO otherwise.
+ * Return #GNUNET_YES if given a valid correlation ID and
+ * #GNUNET_NO otherwise.
  *
- * @returns GNUNET_YES iff given a valid correlation ID
+ * @returns #GNUNET_YES iff given a valid correlation ID
  */
 static int
 is_valid_correlation_id (const char *correlation_id)
 {
   if (strlen (correlation_id) >= 64)
     return GNUNET_NO;
-  for (int i = 0; i < strlen (correlation_id); i++)
+  for (size_t i = 0; i < strlen (correlation_id); i++)
     if (! (isalnum (correlation_id[i]) || (correlation_id[i] == '-')))
       return GNUNET_NO;
   return GNUNET_YES;
@@ -150,6 +161,9 @@ url_handler (void *cls,
     { "/agpl", MHD_HTTP_METHOD_GET, "text/plain",
       NULL, 0,
       &SH_MHD_handler_agpl_redirect, MHD_HTTP_FOUND },
+    { "/terms", MHD_HTTP_METHOD_GET, "text/plain",
+      NULL, 0,
+      &SH_handler_terms, MHD_HTTP_OK },
     {NULL, NULL, NULL, NULL, 0, 0 }
   };
   static struct SH_RequestHandler h404 = {
@@ -439,7 +453,6 @@ run (void *cls,
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               "Starting sync-httpd\n");
-
   result = GNUNET_SYSERR;
   GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
                                  NULL);
@@ -447,6 +460,31 @@ run (void *cls,
                  GNUNET_log_setup ("sync-httpd",
                                    "WARNING",
                                    NULL));
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (config,
+                                             "sync",
+                                             "UPLOAD_LIMIT_MB",
+                                             &SH_upload_limit_mb))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "sync",
+                               "UPLOAD_LIMIT_MB");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+  if (GNUNET_OK !=
+      TALER_config_get_denom (config,
+                              "sync",
+                              "ANNUAL_FEE",
+                              &SH_annual_fee))
+  {
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
+                               "sync",
+                               "ANNUAL_FEE");
+    GNUNET_SCHEDULER_shutdown ();
+    return;
+  }
+
   if (NULL ==
       (db = SYNC_DB_plugin_load (config)))
   {
diff --git a/src/sync/sync-httpd.h b/src/sync/sync-httpd.h
index 53c4f40..c2e76a3 100644
--- a/src/sync/sync-httpd.h
+++ b/src/sync/sync-httpd.h
@@ -136,6 +136,16 @@ extern int SH_sync_connection_close;
  */
 extern struct SYNC_DatabasePlugin *db;
 
+/**
+ * Upload limit to the service, in megabytes.
+ */
+extern unsigned long long SH_upload_limit_mb;
+
+/**
+ * Annual fee for the backup account.
+ */
+extern struct TALER_Amount SH_annual_fee;
+
 /**
  * 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/sync/sync-httpd_terms.c b/src/sync/sync-httpd_terms.c
new file mode 100644
index 0000000..710f2c6
--- /dev/null
+++ b/src/sync/sync-httpd_terms.c
@@ -0,0 +1,51 @@
+/*
+  This file is part of TALER
+  (C) 2019 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file sync/sync-httpd_terms.c
+ * @brief headers for /terms handler
+ * @author Christian Grothoff
+ */
+#include "platform.h"
+#include "sync-httpd_responses.h"
+#include "sync-httpd_terms.h"
+#include <taler/taler_json_lib.h>
+
+/**
+ * Manages a /terms call.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @param mi merchant backend instance, never NULL
+ * @return MHD result code
+ */
+int
+SH_handler_terms (struct SH_RequestHandler *rh,
+                  struct MHD_Connection *connection,
+                  void **connection_cls,
+                  const char *upload_data,
+                  size_t *upload_data_size)
+{
+  return SH_RESPONSE_reply_json_pack (connection,
+                                      MHD_HTTP_OK,
+                                      "{s:I, s:o}",
+                                      "storage_limit_in_megabytes",
+                                      (json_int_t) SH_upload_limit_mb,
+                                      "annual_fee",
+                                      TALER_JSON_from_amount (&SH_annual_fee));
+}
diff --git a/src/sync/sync-httpd_terms.h b/src/sync/sync-httpd_terms.h
new file mode 100644
index 0000000..d6c538e
--- /dev/null
+++ b/src/sync/sync-httpd_terms.h
@@ -0,0 +1,43 @@
+/*
+  This file is part of TALER
+  (C) 2019 Taler Systems SA
+
+  TALER is free software; you can redistribute it and/or modify it under the
+  terms of the GNU General Public License as published by the Free Software
+  Foundation; either version 3, or (at your option) any later version.
+
+  TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License along with
+  TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file sync/sync-httpd_terms.h
+ * @brief headers for /terms handler
+ * @author Christian Grothoff Dold
+ */
+#ifndef SYNC_HTTPD_TERMS_H
+#define SYNC_HTTPD_TERMS_H
+#include <microhttpd.h>
+#include "sync-httpd.h"
+
+/**
+ * Manages a /terms call.
+ *
+ * @param rh context of the handler
+ * @param connection the MHD connection to handle
+ * @param[in,out] connection_cls the connection's closure (can be updated)
+ * @param upload_data upload data
+ * @param[in,out] upload_data_size number of bytes (left) in @a upload_data
+ * @return MHD result code
+ */
+int
+SH_handler_terms (struct SH_RequestHandler *rh,
+                  struct MHD_Connection *connection,
+                  void **connection_cls,
+                  const char *upload_data,
+                  size_t *upload_data_size);
+
+#endif
diff --git a/src/sync/sync.conf b/src/sync/sync.conf
index 9425c22..601241e 100644
--- a/src/sync/sync.conf
+++ b/src/sync/sync.conf
@@ -17,7 +17,6 @@ PORT = 9966
 # if left empty.  Only used if "SERVE" is 'tcp'.
 # BIND_TO =
 
-
 # Which unix domain path should we bind to? Only used if "SERVE" is 'unix'.
 UNIXPATH = ${sync_RUNTIME_DIR}/backend.http
 # What should be the file access permissions (see chmod) for "UNIXPATH"?
@@ -26,6 +25,12 @@ UNIXPATH_MODE = 660
 # Which database backend do we use?
 DB = postgres
 
+# Annual fee for an account
+ANNUAL_FEE = TESTKUDOS:0.1
+
+# Upload limit per backup, in megabytes
+UPLOAD_LIMIT_MB = 16
+
 # Configuration for postgres database.
 [syncdb-postgres]
 CONFIG = postgres:///sync

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



reply via email to

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