[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-exchange] 98/151: add logic to parse measures from configuration
From: |
gnunet |
Subject: |
[taler-exchange] 98/151: add logic to parse measures from configuration |
Date: |
Tue, 30 Jul 2024 23:37:48 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository exchange.
commit e926b0aa861fd00274d26202d7e8807efe997df5
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Thu Jul 18 17:51:33 2024 +0200
add logic to parse measures from configuration
---
src/kyclogic/kyclogic_api.c | 120 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 119 insertions(+), 1 deletion(-)
diff --git a/src/kyclogic/kyclogic_api.c b/src/kyclogic/kyclogic_api.c
index 07beb556f..340a3566b 100644
--- a/src/kyclogic/kyclogic_api.c
+++ b/src/kyclogic/kyclogic_api.c
@@ -1617,7 +1617,7 @@ add_program (const struct GNUNET_CONFIGURATION_Handle
*cfg,
struct TALER_KYCLOGIC_AmlProgram *ap;
ap = GNUNET_new (struct TALER_KYCLOGIC_AmlProgram);
- ap->program_name = GNUNET_strdup (§ion[strlen ("kyc-check-")]);
+ ap->program_name = GNUNET_strdup (§ion[strlen ("aml-program-")]);
ap->command = command;
ap->description = description;
ap->fallback = fallback;
@@ -1671,6 +1671,121 @@ handle_program_section (void *cls,
}
+/**
+ * Parse configuration @a cfg in section @a section for
+ * the specification of a KYC measure.
+ *
+ * @param cfg configuration to parse
+ * @param section configuration section to parse
+ * @return #GNUNET_OK on success
+ */
+static enum GNUNET_GenericReturnValue
+add_measure (const struct GNUNET_CONFIGURATION_Handle *cfg,
+ const char *section)
+{
+ char *check_name = NULL;
+ char *context_str = NULL;
+ char *program = NULL;
+ json_t *context;
+ json_error_t err;
+
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Parsing KYC measure %s\n",
+ section);
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "CHECK_NAME",
+ &check_name))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "CHECK_NAME",
+ "check name required");
+ goto fail;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "PROGRAM",
+ &program))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "PROGRAM",
+ "program name required");
+ goto fail;
+ }
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (cfg,
+ section,
+ "CONTEXT",
+ &context_str))
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "CONTEXT",
+ "context required");
+ goto fail;
+ }
+ context = json_loads (context_str,
+ JSON_REJECT_DUPLICATES,
+ &err);
+ GNUNET_free (context_str);
+ if (NULL == context)
+ {
+ GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
+ section,
+ "COMMAND",
+ err.text);
+ goto fail;
+ }
+
+ {
+ struct TALER_KYCLOGIC_Measure m;
+
+ m.measure_name = GNUNET_strdup (§ion[strlen ("kyc-measure-")]);
+ m.check_name = check_name;
+ m.prog_name = program;
+ m.context = context;
+ GNUNET_array_append (default_rules.custom_measures,
+ default_rules.num_custom_measures,
+ m);
+ }
+ return GNUNET_OK;
+fail:
+ GNUNET_free (check_name);
+ GNUNET_free (program);
+ GNUNET_free (context_str);
+ return GNUNET_SYSERR;
+}
+
+
+/**
+ * Function to iterate over configuration sections.
+ *
+ * @param cls a `struct SectionContext *`
+ * @param section name of the section
+ */
+static void
+handle_measure_section (void *cls,
+ const char *section)
+{
+ struct SectionContext *sc = cls;
+
+ if (0 == strncasecmp (section,
+ "kyc-measure-",
+ strlen ("kyc-measure-")))
+ {
+ if (GNUNET_OK !=
+ add_measure (sc->cfg,
+ section))
+ sc->result = false;
+ return;
+ }
+}
+
+
/**
* Comparator for qsort. Compares two rules
* by timeframe to sort rules by time.
@@ -1720,6 +1835,9 @@ TALER_KYCLOGIC_kyc_init (const struct
GNUNET_CONFIGURATION_Handle *cfg)
GNUNET_CONFIGURATION_iterate_sections (cfg,
&handle_program_section,
&sc);
+ GNUNET_CONFIGURATION_iterate_sections (cfg,
+ &handle_measure_section,
+ &sc);
if (! sc.result)
{
TALER_KYCLOGIC_kyc_done ();
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-exchange] 60/151: implement TALER_EXCHANGE_lookup_kyc_attributes, (continued)
- [taler-exchange] 60/151: implement TALER_EXCHANGE_lookup_kyc_attributes, gnunet, 2024/07/30
- [taler-exchange] 36/151: store provider_name, instead of provider_section, gnunet, 2024/07/30
- [taler-exchange] 48/151: add spa logic, gnunet, 2024/07/30
- [taler-exchange] 87/151: skeleton, gnunet, 2024/07/30
- [taler-exchange] 78/151: WIP: kyc-start, gnunet, 2024/07/30
- [taler-exchange] 47/151: -towards having 3 SPAs, gnunet, 2024/07/30
- [taler-exchange] 112/151: more bugfixes, gnunet, 2024/07/30
- [taler-exchange] 24/151: fix purses_merge, gnunet, 2024/07/30
- [taler-exchange] 22/151: basic refactoring of httpd for new AML, incomplete, gnunet, 2024/07/30
- [taler-exchange] 27/151: -fix more build issues, gnunet, 2024/07/30
- [taler-exchange] 98/151: add logic to parse measures from configuration,
gnunet <=
- [taler-exchange] 35/151: fix FTBFS, gnunet, 2024/07/30
- [taler-exchange] 79/151: -bump gana, gnunet, 2024/07/30
- [taler-exchange] 89/151: -improve logging, gnunet, 2024/07/30
- [taler-exchange] 80/151: -fix FTBFS of new kyc-start logic, gnunet, 2024/07/30
- [taler-exchange] 90/151: pass h_payto, gnunet, 2024/07/30
- [taler-exchange] 106/151: -fixing minor bugs, gnunet, 2024/07/30
- [taler-exchange] 59/151: -implement GET "/aml/$PUB/attributes/$H_PAYTO", gnunet, 2024/07/30
- [taler-exchange] 95/151: -fix auditor insanity, gnunet, 2024/07/30
- [taler-exchange] 53/151: work on kyc-info endpoint, gnunet, 2024/07/30
- [taler-exchange] 44/151: -bump gana, gnunet, 2024/07/30