Disabled reconnect after fingerprint failed #4527

This commit is contained in:
Xinyu Hou 2015-04-20 14:43:39 +01:00
parent 365d16c94b
commit e6e3eae0a9
6 changed files with 27 additions and 7 deletions

View File

@ -95,6 +95,7 @@ REGISTER_EVENT(IListenSocket, connecting)
// //
REGISTER_EVENT(ISocket, disconnected) REGISTER_EVENT(ISocket, disconnected)
REGISTER_EVENT(ISocket, stopRetry)
// //
// OSXScreen // OSXScreen

View File

@ -281,7 +281,8 @@ private:
class ISocketEvents : public EventTypes { class ISocketEvents : public EventTypes {
public: public:
ISocketEvents() : ISocketEvents() :
m_disconnected(Event::kUnknown) { } m_disconnected(Event::kUnknown),
m_stopRetry(Event::kUnknown) { }
//! @name accessors //! @name accessors
//@{ //@{
@ -294,10 +295,18 @@ public:
*/ */
Event::Type disconnected(); Event::Type disconnected();
//! Get stop retry event type
/*!
Returns the stop retry event type. This is sent when the client
doesn't want to reconnect after it disconnects from the server.
*/
Event::Type stopRetry();
//@} //@}
private: private:
Event::Type m_disconnected; Event::Type m_disconnected;
Event::Type m_stopRetry;
}; };
class OSXScreenEvents : public EventTypes { class OSXScreenEvents : public EventTypes {

View File

@ -60,7 +60,7 @@ Client::Client(
const String& name, const NetworkAddress& address, const String& name, const NetworkAddress& address,
ISocketFactory* socketFactory, ISocketFactory* socketFactory,
synergy::Screen* screen, synergy::Screen* screen,
ClientArgs args) : ClientArgs& args) :
m_mock(false), m_mock(false),
m_name(name), m_name(name),
m_serverAddress(address), m_serverAddress(address),
@ -470,6 +470,10 @@ Client::setupConnection()
m_stream->getEventTarget(), m_stream->getEventTarget(),
new TMethodEventJob<Client>(this, new TMethodEventJob<Client>(this,
&Client::handleDisconnected)); &Client::handleDisconnected));
m_events->adoptHandler(m_events->forISocket().stopRetry(),
m_stream->getEventTarget(),
new TMethodEventJob<Client>(this, &Client::handleStopRetry));
} }
void void
@ -525,6 +529,8 @@ Client::cleanupConnection()
m_stream->getEventTarget()); m_stream->getEventTarget());
m_events->removeHandler(m_events->forISocket().disconnected(), m_events->removeHandler(m_events->forISocket().disconnected(),
m_stream->getEventTarget()); m_stream->getEventTarget());
m_events->removeHandler(m_events->forISocket().stopRetry(),
m_stream->getEventTarget());
cleanupStream(); cleanupStream();
} }
} }
@ -743,6 +749,11 @@ Client::onFileRecieveCompleted()
} }
} }
void
Client::handleStopRetry(const Event&, void*)
{
m_args.m_restartable = false;
}
void void
Client::writeToDropDirThread(void*) Client::writeToDropDirThread(void*)

View File

@ -60,7 +60,7 @@ public:
const String& name, const NetworkAddress& address, const String& name, const NetworkAddress& address,
ISocketFactory* socketFactory, ISocketFactory* socketFactory,
synergy::Screen* screen, synergy::Screen* screen,
ClientArgs args); ClientArgs& args);
~Client(); ~Client();
#ifdef TEST_ENV #ifdef TEST_ENV
@ -196,6 +196,7 @@ private:
void handleResume(const Event& event, void*); void handleResume(const Event& event, void*);
void handleFileChunkSending(const Event&, void*); void handleFileChunkSending(const Event&, void*);
void handleFileRecieveCompleted(const Event&, void*); void handleFileRecieveCompleted(const Event&, void*);
void handleStopRetry(const Event&, void*);
void onFileRecieveCompleted(); void onFileRecieveCompleted();
public: public:
@ -226,5 +227,5 @@ private:
Thread* m_writeToDropDirThread; Thread* m_writeToDropDirThread;
TCPSocket* m_socket; TCPSocket* m_socket;
bool m_useSecureNetwork; bool m_useSecureNetwork;
ClientArgs m_args; ClientArgs& m_args;
}; };

View File

@ -281,10 +281,8 @@ SecureSocket::secureConnect(int socket)
checkResult(r, fatal, retry); checkResult(r, fatal, retry);
if (fatal) { if (fatal) {
// tell user and sleep so the socket isn't hammered.
LOG((CLOG_ERR "failed to connect secure socket")); LOG((CLOG_ERR "failed to connect secure socket"));
LOG((CLOG_INFO "server connection may not be secure")); LOG((CLOG_INFO "server connection may not be secure"));
disconnect();
return false; return false;
} }
@ -299,6 +297,7 @@ SecureSocket::secureConnect(int socket)
} }
else { else {
LOG((CLOG_ERR "failed to verify server certificate fingerprint")); LOG((CLOG_ERR "failed to verify server certificate fingerprint"));
sendEvent(getEvents()->forISocket().stopRetry());
disconnect(); disconnect();
} }
} }

View File

@ -331,7 +331,6 @@ ClientApp::handleClientDisconnected(const Event&, void*)
updateStatus(); updateStatus();
} }
Client* Client*
ClientApp::openClient(const String& name, const NetworkAddress& address, ClientApp::openClient(const String& name, const NetworkAddress& address,
synergy::Screen* screen) synergy::Screen* screen)