diff options
author | Pierre Ossman <ossman@cendio.se> | 2017-10-04 16:21:57 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2017-10-04 16:21:57 +0200 |
commit | 36304753691c36f6a75d341545ad6ebb9e859362 (patch) | |
tree | 940ea0892cb050ef31e615207d3645eeda979825 /unix/xserver/hw/vnc | |
parent | 63d2fddd6b613406d9ea28dcd5d1c58feb167126 (diff) | |
download | tigervnc-36304753691c36f6a75d341545ad6ebb9e859362.tar.gz tigervnc-36304753691c36f6a75d341545ad6ebb9e859362.zip |
Push query connect timeout back in to Xvnc
It was moved to the common code in f8e3b34c6, but it was unreliable
because the state could sometimes get out of sync. Push it back in
to Xvnc since it isn't necessarily something all servers will have.
Diffstat (limited to 'unix/xserver/hw/vnc')
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.cc | 27 | ||||
-rw-r--r-- | unix/xserver/hw/vnc/XserverDesktop.h | 6 |
2 files changed, 28 insertions, 5 deletions
diff --git a/unix/xserver/hw/vnc/XserverDesktop.cc b/unix/xserver/hw/vnc/XserverDesktop.cc index dd1d4ca0..c68a0775 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.cc +++ b/unix/xserver/hw/vnc/XserverDesktop.cc @@ -57,6 +57,11 @@ BoolParameter rawKeyboard("RawKeyboard", "Send keyboard events straight through and " "avoid mapping them to the current keyboard " "layout", false); +IntParameter queryConnectTimeout("QueryConnectTimeout", + "Number of seconds to show the " + "Accept Connection dialog before " + "rejecting the connection", + 10); class FileHTTPServer : public rfb::HTTPServer { public: @@ -107,7 +112,7 @@ XserverDesktop::XserverDesktop(int screenIndex_, server(0), httpServer(0), listeners(listeners_), httpListeners(httpListeners_), directFbptr(true), - queryConnectId(0) + queryConnectId(0), queryConnectTimer(this) { format = pf; @@ -301,7 +306,7 @@ XserverDesktop::queryConnection(network::Socket* sock, { int count; - if (queryConnectId) { + if (queryConnectTimer.isStarted()) { *reason = strDup("Another connection is currently being queried."); return rfb::VNCServerST::REJECT; } @@ -319,6 +324,8 @@ XserverDesktop::queryConnection(network::Socket* sock, queryConnectId = (uint32_t)(intptr_t)sock; queryConnectSocket = sock; + queryConnectTimer.start(queryConnectTimeout * 1000); + return rfb::VNCServerST::PENDING; } @@ -557,14 +564,14 @@ void XserverDesktop::getQueryConnect(uint32_t* opaqueId, { *opaqueId = queryConnectId; - if (queryConnectId == 0) { + if (!queryConnectTimer.isStarted()) { *address = ""; *username = ""; *timeout = 0; } else { *address = queryConnectAddress.buf; *username = queryConnectUsername.buf; - *timeout = rfb::Server::queryConnectTimeout; + *timeout = queryConnectTimeout; } } @@ -574,6 +581,7 @@ void XserverDesktop::approveConnection(uint32_t opaqueId, bool accept, if (queryConnectId == opaqueId) { server->approveConnection(queryConnectSocket, accept, rejectMsg); queryConnectId = 0; + queryConnectTimer.stop(); } } @@ -783,3 +791,14 @@ void XserverDesktop::keyEvent(rdr::U32 keysym, rdr::U32 keycode, bool down) vncKeyboardEvent(keysym, keycode, down); } + +bool XserverDesktop::handleTimeout(Timer* t) +{ + if (t == &queryConnectTimer) { + server->approveConnection(queryConnectSocket, false, + "The attempt to prompt the user to " + "accept the connection failed"); + } + + return false; +} diff --git a/unix/xserver/hw/vnc/XserverDesktop.h b/unix/xserver/hw/vnc/XserverDesktop.h index 9e7dfd1e..2a378ea1 100644 --- a/unix/xserver/hw/vnc/XserverDesktop.h +++ b/unix/xserver/hw/vnc/XserverDesktop.h @@ -47,7 +47,8 @@ namespace network { class TcpListener; class Socket; class SocketServer; } class XserverDesktop : public rfb::SDesktop, public rfb::FullFramePixelBuffer, public rdr::Substitutor, - public rfb::VNCServerST::QueryConnectionHandler { + public rfb::VNCServerST::QueryConnectionHandler, + public rfb::Timer::Callback { public: XserverDesktop(int screenIndex, @@ -113,6 +114,8 @@ protected: network::SocketServer* sockserv, bool read, bool write); + virtual bool handleTimeout(rfb::Timer* t); + private: rfb::ScreenSet computeScreenLayout(); @@ -127,6 +130,7 @@ private: network::Socket* queryConnectSocket; rfb::CharArray queryConnectAddress; rfb::CharArray queryConnectUsername; + rfb::Timer queryConnectTimer; #ifdef RANDR typedef std::map<intptr_t, rdr::U32> OutputIdMap; |