diff options
author | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-20 21:18:10 +0000 |
---|---|---|
committer | sergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-20 21:18:10 +0000 |
commit | 273d0de7c54bfc083d753868fdb7d3063a860780 (patch) | |
tree | 9308e8530841558840c6c584bf7577b28954e65e /remoting/host | |
parent | 1dc2961c69bb18a61b0572e8f7bc0b8449b8fd60 (diff) | |
download | chromium_src-273d0de7c54bfc083d753868fdb7d3063a860780.zip chromium_src-273d0de7c54bfc083d753868fdb7d3063a860780.tar.gz chromium_src-273d0de7c54bfc083d753868fdb7d3063a860780.tar.bz2 |
Limit number of failed connection attempts.
BUG=None
TEST=Host shuts down after 5 failed connection attempts
Review URL: http://codereview.chromium.org/7172021
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rw-r--r-- | remoting/host/chromoting_host.cc | 6 | ||||
-rw-r--r-- | remoting/host/heartbeat_sender.cc | 6 | ||||
-rw-r--r-- | remoting/host/heartbeat_sender.h | 1 | ||||
-rw-r--r-- | remoting/host/host_plugin.cc | 12 | ||||
-rw-r--r-- | remoting/host/host_status_observer.h | 4 | ||||
-rw-r--r-- | remoting/host/register_support_host_request.cc | 6 | ||||
-rw-r--r-- | remoting/host/register_support_host_request.h | 1 |
7 files changed, 32 insertions, 4 deletions
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 67b4552..d5f37f3c 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -287,6 +287,12 @@ void ChromotingHost::OnNewClientSession( if (!access_verifier_->VerifyPermissions(session->jid(), session->initiator_token())) { *response = protocol::SessionManager::DECLINE; + + // Notify observers. + for (StatusObserverList::iterator it = status_observers_.begin(); + it != status_observers_.end(); ++it) { + (*it)->OnAccessDenied(); + } return; } diff --git a/remoting/host/heartbeat_sender.cc b/remoting/host/heartbeat_sender.cc index 5ef02b7..b011313 100644 --- a/remoting/host/heartbeat_sender.cc +++ b/remoting/host/heartbeat_sender.cc @@ -86,8 +86,10 @@ void HeartbeatSender::OnSignallingDisconnected() { request_.reset(NULL); } -void HeartbeatSender::OnShutdown() { -} +// Ignore any notifications other than signalling +// connected/disconnected events. +void HeartbeatSender::OnAccessDenied() { } +void HeartbeatSender::OnShutdown() { } void HeartbeatSender::DoSendStanza() { DCHECK_EQ(MessageLoop::current(), message_loop_); diff --git a/remoting/host/heartbeat_sender.h b/remoting/host/heartbeat_sender.h index 016db0f..c7394a0 100644 --- a/remoting/host/heartbeat_sender.h +++ b/remoting/host/heartbeat_sender.h @@ -70,6 +70,7 @@ class HeartbeatSender : public HostStatusObserver { virtual void OnSignallingConnected(SignalStrategy* signal_strategy, const std::string& full_jid) OVERRIDE; virtual void OnSignallingDisconnected() OVERRIDE; + virtual void OnAccessDenied() OVERRIDE; virtual void OnShutdown() OVERRIDE; private: diff --git a/remoting/host/host_plugin.cc b/remoting/host/host_plugin.cc index f63c3c7..4542b8b 100644 --- a/remoting/host/host_plugin.cc +++ b/remoting/host/host_plugin.cc @@ -95,6 +95,8 @@ const char* kAttrNameConnected = "CONNECTED"; const char* kAttrNameAffirmingConnection = "AFFIRMING_CONNECTION"; const char* kAttrNameError = "ERROR"; +const int kMaxLoginAttempts = 5; + // Global netscape functions initialized in NP_Initialize. NPNetscapeFuncs* g_npnetscape_funcs = NULL; @@ -157,6 +159,7 @@ class HostNPScriptObject : public remoting::HostStatusObserver { state_(kDisconnected), on_state_changed_func_(NULL), np_thread_id_(base::PlatformThread::CurrentId()), + failed_login_attempts_(0), disconnected_event_(true, false) { VLOG(2) << "HostNPScriptObject"; host_context_.SetUITaskPostFunction(base::Bind( @@ -336,6 +339,14 @@ class HostNPScriptObject : public remoting::HostStatusObserver { virtual void OnSignallingDisconnected() OVERRIDE { } + virtual void OnAccessDenied() OVERRIDE { + DCHECK_EQ(MessageLoop::current(), host_context_.network_message_loop()); + + ++failed_login_attempts_; + if (failed_login_attempts_ == kMaxLoginAttempts) + DisconnectInternal(); + } + virtual void OnShutdown() OVERRIDE { DCHECK_EQ(MessageLoop::current(), host_context_.main_message_loop()); @@ -407,6 +418,7 @@ class HostNPScriptObject : public remoting::HostStatusObserver { scoped_refptr<remoting::ChromotingHost> host_; scoped_refptr<remoting::MutableHostConfig> host_config_; remoting::ChromotingHostContext host_context_; + int failed_login_attempts_; base::WaitableEvent disconnected_event_; base::CancellationFlag destructing_; diff --git a/remoting/host/host_status_observer.h b/remoting/host/host_status_observer.h index e7fda0b..f38775a 100644 --- a/remoting/host/host_status_observer.h +++ b/remoting/host/host_status_observer.h @@ -19,6 +19,10 @@ class HostStatusObserver { const std::string& full_jid) = 0; virtual void OnSignallingDisconnected() = 0; + // Called on the network thread when an unauthorized user attempts + // to connect to the host. + virtual void OnAccessDenied() = 0; + // Called on the main thread when the host shuts down. virtual void OnShutdown() = 0; }; diff --git a/remoting/host/register_support_host_request.cc b/remoting/host/register_support_host_request.cc index fff4c6b..5b6b9f0 100644 --- a/remoting/host/register_support_host_request.cc +++ b/remoting/host/register_support_host_request.cc @@ -78,8 +78,10 @@ void RegisterSupportHostRequest::OnSignallingDisconnected() { request_.reset(); } -void RegisterSupportHostRequest::OnShutdown() { -} +// Ignore any notifications other than signalling +// connected/disconnected events. +void RegisterSupportHostRequest::OnAccessDenied() { } +void RegisterSupportHostRequest::OnShutdown() { } XmlElement* RegisterSupportHostRequest::CreateRegistrationRequest( const std::string& jid) { diff --git a/remoting/host/register_support_host_request.h b/remoting/host/register_support_host_request.h index c9b1e60..3ba6baf 100644 --- a/remoting/host/register_support_host_request.h +++ b/remoting/host/register_support_host_request.h @@ -53,6 +53,7 @@ class RegisterSupportHostRequest : public HostStatusObserver { virtual void OnSignallingConnected(SignalStrategy* signal_strategy, const std::string& full_jid) OVERRIDE; virtual void OnSignallingDisconnected() OVERRIDE; + virtual void OnAccessDenied() OVERRIDE; virtual void OnShutdown() OVERRIDE; private: |