aboutsummaryrefslogtreecommitdiffstats
path: root/common/rfb
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2015-01-27 13:24:29 +0100
committerPierre Ossman <ossman@cendio.se>2015-01-27 13:24:29 +0100
commit7e4da45422ecfb0746c5c79593a642a275142643 (patch)
treedbd4860596318af73f2cc85d1f1cd7b82444c46e /common/rfb
parent50a0427925d50804ec66d0d11a0ee10dcb572c83 (diff)
parent9018af44dadebb5ed50ba9336007fc9da653a9a0 (diff)
downloadtigervnc-7e4da45422ecfb0746c5c79593a642a275142643.tar.gz
tigervnc-7e4da45422ecfb0746c5c79593a642a275142643.zip
Merge branch 'xorgheaders' of https://github.com/CendioOssman/tigervnc
Diffstat (limited to 'common/rfb')
-rw-r--r--common/rfb/LogWriter.h4
-rw-r--r--common/rfb/ScreenSet.h20
-rw-r--r--common/rfb/ServerCore.cxx6
-rw-r--r--common/rfb/ServerCore.h1
-rw-r--r--common/rfb/Timer.cxx1
-rw-r--r--common/rfb/VNCSConnectionST.cxx13
-rw-r--r--common/rfb/VNCSConnectionST.h2
7 files changed, 35 insertions, 12 deletions
diff --git a/common/rfb/LogWriter.h b/common/rfb/LogWriter.h
index 23e3069c..6b85a85c 100644
--- a/common/rfb/LogWriter.h
+++ b/common/rfb/LogWriter.h
@@ -36,6 +36,10 @@
// is assigned a particular log level.
#define DEF_LOGFUNCTION(name, level) \
+ inline void name(const char* fmt, va_list ap) { \
+ if (m_log && (level <= m_level)) \
+ m_log->write(level, m_name, fmt, ap);\
+ } \
inline void name(const char* fmt, ...) __printf_attr(2, 3) { \
if (m_log && (level <= m_level)) { \
va_list ap; va_start(ap, fmt); \
diff --git a/common/rfb/ScreenSet.h b/common/rfb/ScreenSet.h
index 8997aa64..ad340c2b 100644
--- a/common/rfb/ScreenSet.h
+++ b/common/rfb/ScreenSet.h
@@ -22,6 +22,7 @@
#define __RFB_SCREENSET_INCLUDED__
#include <stdio.h>
+#include <string.h>
#include <rdr/types.h>
#include <rfb/Rect.h>
@@ -108,15 +109,20 @@ namespace rfb {
return true;
};
- inline void debug_print(void) const {
+ inline void print(char* str, size_t len) const {
+ char buffer[128];
std::list<Screen>::const_iterator iter;
- fprintf(stderr, "%d screens\n", num_screens());
+ snprintf(buffer, sizeof(buffer), "%d screen(s)\n", num_screens());
+ str[0] = '\0';
+ strncat(str, buffer, len - 1 - strlen(str));
for (iter = screens.begin();iter != screens.end();++iter) {
- fprintf(stderr, " %10d (0x%08x): %dx%d+%d+%d (flags 0x%08x)\n",
- (int)iter->id, (unsigned)iter->id,
- iter->dimensions.width(), iter->dimensions.height(),
- iter->dimensions.tl.x, iter->dimensions.tl.y,
- (unsigned)iter->flags);
+ snprintf(buffer, sizeof(buffer),
+ " %10d (0x%08x): %dx%d+%d+%d (flags 0x%08x)\n",
+ (int)iter->id, (unsigned)iter->id,
+ iter->dimensions.width(), iter->dimensions.height(),
+ iter->dimensions.tl.x, iter->dimensions.tl.y,
+ (unsigned)iter->flags);
+ strncat(str, buffer, len - 1 - strlen(str));
}
};
diff --git a/common/rfb/ServerCore.cxx b/common/rfb/ServerCore.cxx
index b11a352a..6e221d53 100644
--- a/common/rfb/ServerCore.cxx
+++ b/common/rfb/ServerCore.cxx
@@ -97,4 +97,8 @@ rfb::BoolParameter rfb::Server::queryConnect
("QueryConnect",
"Prompt the local user to accept or reject incoming connections.",
false);
-
+rfb::IntParameter rfb::Server::queryConnectTimeout
+("QueryConnectTimeout",
+ "Number of seconds to show the Accept Connection dialog before "
+ "rejecting the connection",
+ 10);
diff --git a/common/rfb/ServerCore.h b/common/rfb/ServerCore.h
index 5fc996ff..c4d7d537 100644
--- a/common/rfb/ServerCore.h
+++ b/common/rfb/ServerCore.h
@@ -48,6 +48,7 @@ namespace rfb {
static BoolParameter sendCutText;
static BoolParameter acceptSetDesktopSize;
static BoolParameter queryConnect;
+ static IntParameter queryConnectTimeout;
};
diff --git a/common/rfb/Timer.cxx b/common/rfb/Timer.cxx
index 5f8ac893..5f9c6f2f 100644
--- a/common/rfb/Timer.cxx
+++ b/common/rfb/Timer.cxx
@@ -101,7 +101,6 @@ int Timer::checkTimeouts() {
while (pending.front()->isBefore(now)) {
Timer* timer = pending.front();
pending.pop_front();
- vlog.debug("handleTimeout(%p)", timer);
if (timer->cb->handleTimeout(timer)) {
timer->dueTime = addMillis(timer->dueTime, timer->timeoutMs);
if (timer->isBefore(now)) {
diff --git a/common/rfb/VNCSConnectionST.cxx b/common/rfb/VNCSConnectionST.cxx
index e30b4f42..746bb901 100644
--- a/common/rfb/VNCSConnectionST.cxx
+++ b/common/rfb/VNCSConnectionST.cxx
@@ -1,5 +1,5 @@
/* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved.
- * Copyright 2009-2014 Pierre Ossman for Cendio AB
+ * Copyright 2009-2015 Pierre Ossman for Cendio AB
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -66,7 +66,8 @@ struct RTTInfo {
VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
bool reverse)
- : SConnection(reverse), sock(s), inProcessMessages(false),
+ : SConnection(reverse), sock(s),
+ queryConnectTimer(this), inProcessMessages(false),
pendingSyncFence(false), syncFence(false), fenceFlags(0),
fenceDataLen(0), fenceData(NULL),
baseRTT(-1), minRTT(-1), seenCongestion(false), pingCounter(0),
@@ -434,8 +435,10 @@ void VNCSConnectionST::queryConnection(const char* userName)
CharArray reason;
VNCServerST::queryResult qr = server->queryConnection(sock, userName,
&reason.buf);
- if (qr == VNCServerST::PENDING)
+ if (qr == VNCServerST::PENDING) {
+ queryConnectTimer.start(rfb::Server::queryConnectTimeout * 1000);
return;
+ }
// - If server returns ACCEPT/REJECT then pass result to SConnection
approveConnection(qr == VNCServerST::ACCEPT, reason.buf);
@@ -714,6 +717,10 @@ bool VNCSConnectionST::handleTimeout(Timer* t)
writeFramebufferUpdate();
else if (t == &congestionTimer)
updateCongestion();
+ else if (t == &queryConnectTimer) {
+ if (state() == RFBSTATE_QUERYING)
+ approveConnection(false, "The attempt to prompt the user to accept the connection failed");
+ }
} catch (rdr::Exception& e) {
close(e.str());
}
diff --git a/common/rfb/VNCSConnectionST.h b/common/rfb/VNCSConnectionST.h
index fd1897a6..7b25570d 100644
--- a/common/rfb/VNCSConnectionST.h
+++ b/common/rfb/VNCSConnectionST.h
@@ -174,6 +174,8 @@ namespace rfb {
network::Socket* sock;
CharArray peerEndpoint;
+ Timer queryConnectTimer;
+
bool inProcessMessages;
bool pendingSyncFence, syncFence;