[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis] branch master updated: implement rate limiting error h
From: |
gnunet |
Subject: |
[taler-anastasis] branch master updated: implement rate limiting error handling |
Date: |
Sun, 28 Mar 2021 23:15:41 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis.
The following commit(s) were added to refs/heads/master by this push:
new 1c5be01 implement rate limiting error handling
1c5be01 is described below
commit 1c5be01580caec40af032ce810349cfcdb6412cc
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Mar 28 23:15:39 2021 +0200
implement rate limiting error handling
---
src/backend/anastasis-httpd_truth.c | 1 -
src/include/anastasis.h | 7 ++++++-
src/include/anastasis_service.h | 8 +++++++-
src/lib/anastasis_recovery.c | 12 +++++++++++-
src/reducer/anastasis_api_recovery_redux.c | 23 ++++++++++++++++++++++-
src/restclient/anastasis_api_keyshare_lookup.c | 12 +++++++++---
src/testing/testing_api_cmd_keyshare_lookup.c | 2 ++
src/testing/testing_cmd_challenge_answer.c | 2 ++
8 files changed, 59 insertions(+), 8 deletions(-)
diff --git a/src/backend/anastasis-httpd_truth.c
b/src/backend/anastasis-httpd_truth.c
index d417708..7001018 100644
--- a/src/backend/anastasis-httpd_truth.c
+++ b/src/backend/anastasis-httpd_truth.c
@@ -828,7 +828,6 @@ AH_handler_truth_get (
TALER_EC_GENERIC_DB_FETCH_FAILED,
"get escrow challenge");
case GNUNET_DB_STATUS_SUCCESS_NO_RESULTS:
- GNUNET_break_op (0);
return TALER_MHD_reply_with_error (connection,
MHD_HTTP_NOT_FOUND,
TALER_EC_ANASTASIS_TRUTH_UNKNOWN,
diff --git a/src/include/anastasis.h b/src/include/anastasis.h
index 48a7769..3b8500e 100644
--- a/src/include/anastasis.h
+++ b/src/include/anastasis.h
@@ -126,7 +126,12 @@ enum ANASTASIS_ChallengeStatus
/**
* The server does not know this truth.
*/
- ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN
+ ANASTASIS_CHALLENGE_STATUS_TRUTH_UNKNOWN,
+
+ /**
+ * The rate limit for solving the challenge was exceeded.
+ */
+ ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED
};
diff --git a/src/include/anastasis_service.h b/src/include/anastasis_service.h
index db0e9a8..148d621 100644
--- a/src/include/anastasis_service.h
+++ b/src/include/anastasis_service.h
@@ -457,7 +457,13 @@ enum ANASTASIS_KeyShareDownloadStatus
/**
* The provider does not know this truth.
*/
- ANASTASIS_KSD_TRUTH_UNKNOWN
+ ANASTASIS_KSD_TRUTH_UNKNOWN,
+
+ /**
+ * Too many attempts to solve the challenge were made in a short
+ * time. Try again laster.
+ */
+ ANASTASIS_KSD_RATE_LIMIT_EXCEEDED
};
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index 7a893ce..a0a5e7b 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -303,13 +303,23 @@ keyshare_lookup_cb (void *cls,
.challenge = c
};
+ c->af (c->af_cls,
+ &csr);
+ return;
+ }
+ case ANASTASIS_KSD_RATE_LIMIT_EXCEEDED:
+ {
+ struct ANASTASIS_ChallengeStartResponse csr = {
+ .cs = ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED,
+ .challenge = c
+ };
+
c->af (c->af_cls,
&csr);
return;
}
case ANASTASIS_KSD_SERVER_ERROR:
case ANASTASIS_KSD_CLIENT_FAILURE:
- default:
{
struct ANASTASIS_ChallengeStartResponse csr = {
.cs = ANASTASIS_CHALLENGE_STATUS_SERVER_FAILURE,
diff --git a/src/reducer/anastasis_api_recovery_redux.c
b/src/reducer/anastasis_api_recovery_redux.c
index 23fbe9c..78b1de0 100644
--- a/src/reducer/anastasis_api_recovery_redux.c
+++ b/src/reducer/anastasis_api_recovery_redux.c
@@ -576,7 +576,28 @@ answer_feedback_cb (
set_state (sctx->state,
ANASTASIS_GENERIC_STATE_ERROR);
sctx->cb (sctx->cb_cls,
- TALER_EC_NONE,
+ TALER_EC_ANASTASIS_TRUTH_UNKNOWN,
+ sctx->state);
+ sctx_free (sctx);
+ return;
+ case ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED:
+ {
+ json_t *err;
+
+ err = json_pack ("{s:s}",
+ "state",
+ "rate-limit-exceeded");
+ GNUNET_assert (NULL != err);
+ GNUNET_assert (0 ==
+ json_object_set_new (feedback,
+ uuid,
+ err));
+ }
+ GNUNET_break_op (0);
+ set_state (sctx->state,
+ ANASTASIS_GENERIC_STATE_ERROR);
+ sctx->cb (sctx->cb_cls,
+ TALER_EC_ANASTASIS_TRUTH_RATE_LIMITED,
sctx->state);
sctx_free (sctx);
return;
diff --git a/src/restclient/anastasis_api_keyshare_lookup.c
b/src/restclient/anastasis_api_keyshare_lookup.c
index 4708363..f044686 100644
--- a/src/restclient/anastasis_api_keyshare_lookup.c
+++ b/src/restclient/anastasis_api_keyshare_lookup.c
@@ -233,10 +233,16 @@ handle_keyshare_lookup_finished (void *cls,
/* Nothing really to verify */
kdd.status = ANASTASIS_KSD_CLIENT_FAILURE;
break;
+ case MHD_HTTP_TOO_MANY_REQUESTS:
+ kdd.status = ANASTASIS_KSD_RATE_LIMIT_EXCEEDED;
+ break;
case MHD_HTTP_INTERNAL_SERVER_ERROR:
/* Server had an internal issue; we should retry, but this API
leaves this to the application */
kdd.status = ANASTASIS_KSD_SERVER_ERROR;
+ kdd.details.server_failure.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ kdd.details.server_failure.http_status = response_code;
break;
default:
/* unexpected response code */
@@ -245,11 +251,11 @@ handle_keyshare_lookup_finished (void *cls,
(unsigned int) response_code);
GNUNET_break (0);
kdd.status = ANASTASIS_KSD_SERVER_ERROR;
+ kdd.details.server_failure.ec = TALER_JSON_get_error_code2 (data,
+ data_size);
+ kdd.details.server_failure.http_status = response_code;
break;
}
- kdd.details.server_failure.ec = TALER_JSON_get_error_code2 (data,
- data_size);
- kdd.details.server_failure.http_status = response_code;
kslo->cb (kslo->cb_cls,
&kdd);
ANASTASIS_keyshare_lookup_cancel (kslo);
diff --git a/src/testing/testing_api_cmd_keyshare_lookup.c
b/src/testing/testing_api_cmd_keyshare_lookup.c
index f86feac..6b09b56 100644
--- a/src/testing/testing_api_cmd_keyshare_lookup.c
+++ b/src/testing/testing_api_cmd_keyshare_lookup.c
@@ -201,6 +201,8 @@ keyshare_lookup_cb (void *cls,
break;
case ANASTASIS_KSD_TRUTH_UNKNOWN:
break;
+ case ANASTASIS_KSD_RATE_LIMIT_EXCEEDED:
+ break;
}
TALER_TESTING_interpreter_next (ksls->is);
}
diff --git a/src/testing/testing_cmd_challenge_answer.c
b/src/testing/testing_cmd_challenge_answer.c
index 22af2dc..296eae8 100644
--- a/src/testing/testing_cmd_challenge_answer.c
+++ b/src/testing/testing_cmd_challenge_answer.c
@@ -157,6 +157,8 @@ challenge_answer_cb (void *af_cls,
GNUNET_break (0);
TALER_TESTING_interpreter_fail (cs->is);
return;
+ case ANASTASIS_CHALLENGE_STATUS_RATE_LIMIT_EXCEEDED:
+ break;
}
TALER_TESTING_interpreter_next (cs->is);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis] branch master updated: implement rate limiting error handling,
gnunet <=