From aa83a9187873339c97177da77f9cd84f30f678f0 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sat, 1 Jul 2017 14:18:25 +0200 Subject: support VC checks (#5035) --- src/backend/taler-merchant-httpd_exchanges.c | 29 ++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src/backend') diff --git a/src/backend/taler-merchant-httpd_exchanges.c b/src/backend/taler-merchant-httpd_exchanges.c index ea84e6bd..a0d32024 100644 --- a/src/backend/taler-merchant-httpd_exchanges.c +++ b/src/backend/taler-merchant-httpd_exchanges.c @@ -255,10 +255,12 @@ json_t *trusted_exchanges; * in order to get the "good" keys. * @param keys information about the various keys used * by the exchange + * @param compat version compatibility data */ static void keys_mgmt_cb (void *cls, - const struct TALER_EXCHANGE_Keys *keys); + const struct TALER_EXCHANGE_Keys *keys, + enum TALER_EXCHANGE_VersionCompatibility compat); /** @@ -589,10 +591,12 @@ wire_task_cb (void *cls) * in order to get the "good" keys. * @param keys information about the various keys used * by the exchange + * @param compat version compatibility data */ static void keys_mgmt_cb (void *cls, - const struct TALER_EXCHANGE_Keys *keys) + const struct TALER_EXCHANGE_Keys *keys, + enum TALER_EXCHANGE_VersionCompatibility compat) { struct Exchange *exchange = cls; struct GNUNET_TIME_Absolute expire; @@ -611,6 +615,14 @@ keys_mgmt_cb (void *cls, GNUNET_SCHEDULER_cancel (exchange->wire_task); exchange->wire_task = NULL; } + if (TALER_EXCHANGE_VC_INCOMPATIBLE_NEWER == compat) + { + /* Give up, log hard error. */ + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Exchange `%s' runs an incompatible more recent version of the Taler protocol. Will not retry. This client may need to be updated.\n", + exchange->uri); + return; + } exchange->retry_delay = RETRY_BACKOFF (exchange->retry_delay); GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to fetch /keys from `%s', retrying in %s\n", @@ -622,6 +634,19 @@ keys_mgmt_cb (void *cls, exchange); return; } + if (0 != (TALER_EXCHANGE_VC_NEWER & compat)) + { + /* Warn user exactly once about need to upgrade */ + static int once; + + if (0 == once) + { + once = 1; + GNUNET_log (GNUNET_ERROR_TYPE_WARNING, + "Exchange `%s' runs a more recent version of the Taler protocol. You may want to update this client.\n", + exchange->uri); + } + } expire = TALER_EXCHANGE_check_keys_current (exchange->conn); if (0 == expire.abs_value_us) delay = RELOAD_DELAY; -- cgit v1.2.3