Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1117)

Unified Diff: remoting/host/chromoting_host.cc

Issue 9836062: Implement exponential backoff for failed Me2Me authentication attempts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/host/chromoting_host.cc
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 7a26a8ac6bd70fba0fbf5435c30fca030ef044f1..8ff02a6d6b8b8d02caefd0581d7b1c5aeb2fd6ab 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -31,6 +31,33 @@ using remoting::protocol::InputStub;
namespace remoting {
+namespace {
+
+const net::BackoffEntry::Policy kDefaultBackoffPolicy = {
+ // Number of initial errors (in sequence) to ignore before applying
+ // exponential back-off rules.
+ 0,
+
+ // Initial delay for exponential back-off in ms.
+ 2000,
+
+ // Factor by which the waiting time will be multiplied.
+ 2,
+
+ // Fuzzing percentage. ex: 10% will spread requests randomly
+ // between 90%-100% of the calculated time.
+ 0,
+
+ // Maximum amount of time we are willing to delay our request in ms.
+ -1,
+
+ // Time to keep an entry from being discarded even when it
+ // has no significant state, -1 to never discard.
+ -1,
+};
+
+} // namespace
+
ChromotingHost::ChromotingHost(
ChromotingHostContext* context,
SignalStrategy* signal_strategy,
@@ -43,6 +70,7 @@ ChromotingHost::ChromotingHost(
stopping_recorders_(0),
state_(kInitial),
protocol_config_(protocol::CandidateSessionConfig::CreateDefault()),
+ login_backoff_(&kDefaultBackoffPolicy),
authenticating_client_(false),
reject_authenticating_client_(false) {
DCHECK(context_);
@@ -137,7 +165,7 @@ void ChromotingHost::SetAuthenticatorFactory(
void ChromotingHost::OnSessionAuthenticated(ClientSession* client) {
DCHECK(context_->network_message_loop()->BelongsToCurrentThread());
- // TODO(sergeyu): Update BackoffEntry here.
+ login_backoff_.Reset();
}
void ChromotingHost::OnSessionAuthenticatedAndConnected(ClientSession* client) {
@@ -251,6 +279,13 @@ void ChromotingHost::OnIncomingSession(
return;
}
+ if (login_backoff_.ShouldRejectRequest()) {
+ *response = protocol::SessionManager::DISABLED;
+ return;
+ }
+
+ login_backoff_.InformOfRequest(false);
Jói 2012/03/26 12:31:56 It's confusing to me that this is unconditionally
Sergey Ulanov 2012/03/26 23:00:32 Yes, that's the idea. This method is called when a
+
protocol::SessionConfig config;
if (!protocol_config_->Select(session->candidate_config(), &config)) {
LOG(WARNING) << "Rejecting connection from " << session->jid()

Powered by Google App Engine
This is Rietveld 408576698