Commit 9f0a1a3b authored by dscho's avatar dscho

synced with TightVNC and RealVNC

parent b9ebdab1
checked sync with TightVNC 1.2.8:
viewonly/full passwords; if given a list, only the first is a full one
vncRandomBytes is a little more secure now
new weights for tight encoding
checked sync with RealVNC 3.3.7
introduced maxRectsPerUpdate
added first alpha version of LibVNCClient added first alpha version of LibVNCClient
added simple and simple15 example (really simple examples) added simple and simple15 example (really simple examples)
finally got around to fix configure in CVS finally got around to fix configure in CVS
...@@ -20,6 +26,7 @@ ...@@ -20,6 +26,7 @@
more portable way to determine endianness and types of a given size more portable way to determine endianness and types of a given size
through autoconf based methods through autoconf based methods
0.5 0.5
rpm packaging through autoconf
autoconf'ed the whole package (including optional support for zlib, autoconf'ed the whole package (including optional support for zlib,
pthreads and libjpeg as well as zrle/c++) pthreads and libjpeg as well as zrle/c++)
moved appropriate files to contrib/ and examples/ respectively moved appropriate files to contrib/ and examples/ respectively
......
immediate: immediate:
---------- ----------
x11vnc: clipboard, cursor TightVNC encoding!!! Regression!!!
extra_bytes in rfbDrawCharWithClip. extra_bytes in rfbDrawCharWithClip.
tested mouse buttons make copy rect, but text is not marked as mod. tested mouse buttons make copy rect, but text is not marked as mod.
cursor drawing: set optional grain to mark bigger rectangles as drawn (else
you end up with thousands of one-pixel-rectangles to encode).
selectbox: scroll bars
documentation
hint that to mark very tiny regions as
modified is possibly inefficient for the encodings.
(a trail of points could better be a small rectangle).
later: later:
------ ------
selectbox: scroll bars
authentification schemes (secure vnc) authentification schemes (secure vnc)
IO function ptr exists; now explain how to tunnel and implement a IO function ptr exists; now explain how to tunnel and implement a
client address restriction scheme. client address restriction scheme.
...@@ -24,6 +18,17 @@ CORBA ...@@ -24,6 +18,17 @@ CORBA
done: done:
----- -----
.following two items overridden by RealVNC's idea: if there are too many
rectangles (like >50), just use the bounding box.
cursor drawing: set optional grain to mark bigger rectangles as drawn (else
you end up with thousands of one-pixel-rectangles to encode).
documentation
hint that to mark very tiny regions as
modified is possibly inefficient for the encodings.
(a trail of points could better be a small rectangle).
.viewonly/full password method
.x11vnc: clipboard, cursor (Karl's work)
.autoconf also CARD8,CARD16,... .autoconf also CARD8,CARD16,...
.autoconf .autoconf
.internal HTTP tunnelling feature (needs a special GET target and a few .internal HTTP tunnelling feature (needs a special GET target and a few
......
...@@ -467,12 +467,16 @@ Bool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len) ...@@ -467,12 +467,16 @@ Bool defaultPasswordCheck(rfbClientPtr cl,const char* response,int len)
Bool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len) Bool rfbCheckPasswordByList(rfbClientPtr cl,const char* response,int len)
{ {
char **passwds; char **passwds;
int i=0;
for(passwds=(char**)cl->screen->rfbAuthPasswdData;*passwds;passwds++) { for(passwds=(char**)cl->screen->rfbAuthPasswdData;*passwds;passwds++,i++) {
vncEncryptBytes(cl->authChallenge, *passwds); vncEncryptBytes(cl->authChallenge, *passwds);
if (memcmp(cl->authChallenge, response, len) == 0) if (memcmp(cl->authChallenge, response, len) == 0) {
if(i>=cl->screen->rfbAuthPasswdFirstViewOnly)
cl->viewOnly=TRUE;
return(TRUE); return(TRUE);
}
} }
rfbLog("rfbAuthProcessClientMessage: authentication failed from %s\n", rfbLog("rfbAuthProcessClientMessage: authentication failed from %s\n",
...@@ -574,6 +578,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, ...@@ -574,6 +578,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
rfbScreen->rfbNeverShared = FALSE; rfbScreen->rfbNeverShared = FALSE;
rfbScreen->rfbDontDisconnect = FALSE; rfbScreen->rfbDontDisconnect = FALSE;
rfbScreen->rfbAuthPasswdData = 0; rfbScreen->rfbAuthPasswdData = 0;
rfbScreen->rfbAuthPasswdFirstViewOnly = 1;
rfbScreen->width = width; rfbScreen->width = width;
rfbScreen->height = height; rfbScreen->height = height;
...@@ -611,6 +616,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, ...@@ -611,6 +616,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
IF_PTHREADS(rfbScreen->backgroundLoop = FALSE); IF_PTHREADS(rfbScreen->backgroundLoop = FALSE);
rfbScreen->rfbDeferUpdateTime=5; rfbScreen->rfbDeferUpdateTime=5;
rfbScreen->maxRectsPerUpdate=50;
/* proc's and hook's */ /* proc's and hook's */
......
...@@ -232,7 +232,12 @@ typedef struct _rfbScreenInfo ...@@ -232,7 +232,12 @@ typedef struct _rfbScreenInfo
PasswordCheckProcPtr passwordCheck; PasswordCheckProcPtr passwordCheck;
void* rfbAuthPasswdData; void* rfbAuthPasswdData;
/* If rfbAuthPasswdData is given a list, this is the first
view only password. */
int rfbAuthPasswdFirstViewOnly;
/* send only this many rectangles in one update */
int maxRectsPerUpdate;
/* this is the amount of milliseconds to wait at least before sending /* this is the amount of milliseconds to wait at least before sending
* an update. */ * an update. */
int rfbDeferUpdateTime; int rfbDeferUpdateTime;
...@@ -329,6 +334,8 @@ typedef struct _rfbClientRec { ...@@ -329,6 +334,8 @@ typedef struct _rfbClientRec {
int preferredEncoding; int preferredEncoding;
int correMaxWidth, correMaxHeight; int correMaxWidth, correMaxHeight;
Bool viewOnly;
/* The following member is only used during VNC authentication */ /* The following member is only used during VNC authentication */
uint8_t authChallenge[CHALLENGESIZE]; uint8_t authChallenge[CHALLENGESIZE];
......
...@@ -37,6 +37,8 @@ extern Bool sraRgnPopRect(sraRegion *region, sraRect *rect, ...@@ -37,6 +37,8 @@ extern Bool sraRgnPopRect(sraRegion *region, sraRect *rect,
extern unsigned long sraRgnCountRects(const sraRegion *rgn); extern unsigned long sraRgnCountRects(const sraRegion *rgn);
extern Bool sraRgnEmpty(const sraRegion *rgn); extern Bool sraRgnEmpty(const sraRegion *rgn);
extern sraRegion *sraRgnBBox(const sraRegion *src);
/* -=- rectangle iterator */ /* -=- rectangle iterator */
typedef struct sraRectangleIterator { typedef struct sraRectangleIterator {
......
...@@ -582,6 +582,39 @@ sraRgnOffset(sraRegion *dst, int dx, int dy) { ...@@ -582,6 +582,39 @@ sraRgnOffset(sraRegion *dst, int dx, int dy) {
} }
} }
sraRegion *sraRgnBBox(const sraRegion *src) {
int xmin=((unsigned int)(int)-1)>>1,ymin=xmin,xmax=1-xmin,ymax=xmax;
sraSpan *vcurr, *hcurr;
if(!src)
return sraRgnCreate();
vcurr = ((sraSpanList*)src)->front._next;
while (vcurr != &(((sraSpanList*)src)->back)) {
if(vcurr->start<ymin)
ymin=vcurr->start;
if(vcurr->end>ymax)
ymax=vcurr->end;
hcurr = vcurr->subspan->front._next;
while (hcurr != &(vcurr->subspan->back)) {
if(hcurr->start<xmin)
xmin=hcurr->start;
if(hcurr->end>xmax)
xmax=hcurr->end;
fprintf(stderr,"%d,%d,%d,%d\n",hcurr->start,vcurr->start,hcurr->end,vcurr->end);
hcurr = hcurr->_next;
}
vcurr = vcurr->_next;
}
if(xmax<xmin || ymax<ymin)
return sraRgnCreate();
return sraRgnCreateRect(xmin,ymin,xmax,ymax);
}
Bool Bool
sraRgnPopRect(sraRegion *rgn, sraRect *rect, unsigned long flags) { sraRgnPopRect(sraRegion *rgn, sraRect *rect, unsigned long flags) {
sraSpan *vcurr, *hcurr; sraSpan *vcurr, *hcurr;
......
...@@ -233,6 +233,8 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP) ...@@ -233,6 +233,8 @@ rfbNewTCPOrUDPClient(rfbScreen,sock,isUDP)
cl->screen = rfbScreen; cl->screen = rfbScreen;
cl->sock = sock; cl->sock = sock;
cl->viewOnly = FALSE;
rfbResetStats(cl); rfbResetStats(cl);
if(isUDP) { if(isUDP) {
...@@ -932,70 +934,78 @@ rfbProcessClientNormalMessage(cl) ...@@ -932,70 +934,78 @@ rfbProcessClientNormalMessage(cl)
case rfbKeyEvent: case rfbKeyEvent:
cl->rfbKeyEventsRcvd++; cl->rfbKeyEventsRcvd++;
if ((n = ReadExact(cl, ((char *)&msg) + 1, if ((n = ReadExact(cl, ((char *)&msg) + 1,
sz_rfbKeyEventMsg - 1)) <= 0) { sz_rfbKeyEventMsg - 1)) <= 0) {
if (n != 0) if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl); rfbCloseClient(cl);
return; return;
} }
if(!cl->viewOnly) {
cl->screen->kbdAddEvent(msg.ke.down, (KeySym)Swap32IfLE(msg.ke.key), cl);
}
cl->screen->kbdAddEvent(msg.ke.down, (KeySym)Swap32IfLE(msg.ke.key), cl);
return; return;
case rfbPointerEvent: case rfbPointerEvent:
cl->rfbPointerEventsRcvd++; cl->rfbPointerEventsRcvd++;
if ((n = ReadExact(cl, ((char *)&msg) + 1, if ((n = ReadExact(cl, ((char *)&msg) + 1,
sz_rfbPointerEventMsg - 1)) <= 0) { sz_rfbPointerEventMsg - 1)) <= 0) {
if (n != 0) if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl); rfbCloseClient(cl);
return; return;
} }
if (pointerClient && (pointerClient != cl)) if (pointerClient && (pointerClient != cl))
return; return;
if (msg.pe.buttonMask == 0) if (msg.pe.buttonMask == 0)
pointerClient = NULL; pointerClient = NULL;
else else
pointerClient = cl; pointerClient = cl;
if(!cl->viewOnly) {
cl->screen->ptrAddEvent(msg.pe.buttonMask,
Swap16IfLE(msg.pe.x), Swap16IfLE(msg.pe.y), cl);
}
cl->screen->ptrAddEvent(msg.pe.buttonMask,
Swap16IfLE(msg.pe.x), Swap16IfLE(msg.pe.y), cl);
return; return;
case rfbClientCutText: case rfbClientCutText:
if ((n = ReadExact(cl, ((char *)&msg) + 1, if ((n = ReadExact(cl, ((char *)&msg) + 1,
sz_rfbClientCutTextMsg - 1)) <= 0) { sz_rfbClientCutTextMsg - 1)) <= 0) {
if (n != 0) if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbLogPerror("rfbProcessClientNormalMessage: read");
rfbCloseClient(cl); rfbCloseClient(cl);
return; return;
} }
msg.cct.length = Swap32IfLE(msg.cct.length); if(!cl->viewOnly) {
msg.cct.length = Swap32IfLE(msg.cct.length);
str = (char *)malloc(msg.cct.length); str = (char *)malloc(msg.cct.length);
if ((n = ReadExact(cl, str, msg.cct.length)) <= 0) { if ((n = ReadExact(cl, str, msg.cct.length)) <= 0) {
if (n != 0) if (n != 0)
rfbLogPerror("rfbProcessClientNormalMessage: read"); rfbLogPerror("rfbProcessClientNormalMessage: read");
free(str); free(str);
rfbCloseClient(cl); rfbCloseClient(cl);
return; return;
} }
cl->screen->setXCutText(str, msg.cct.length, cl); cl->screen->setXCutText(str, msg.cct.length, cl);
free(str);
}
free(str);
return; return;
...@@ -1166,6 +1176,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion) ...@@ -1166,6 +1176,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
nUpdateRegionRects += (((w-1) / cl->correMaxWidth + 1) nUpdateRegionRects += (((w-1) / cl->correMaxWidth + 1)
* ((h-1) / cl->correMaxHeight + 1)); * ((h-1) / cl->correMaxHeight + 1));
} }
sraRgnReleaseIterator(i);
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
} else if (cl->preferredEncoding == rfbEncodingZlib) { } else if (cl->preferredEncoding == rfbEncodingZlib) {
nUpdateRegionRects = 0; nUpdateRegionRects = 0;
...@@ -1193,6 +1204,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion) ...@@ -1193,6 +1204,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
} }
nUpdateRegionRects += n; nUpdateRegionRects += n;
} }
sraRgnReleaseIterator(i);
#endif #endif
#endif #endif
} else { } else {
...@@ -1201,6 +1213,14 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion) ...@@ -1201,6 +1213,14 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
fu->type = rfbFramebufferUpdate; fu->type = rfbFramebufferUpdate;
if (nUpdateRegionRects != 0xFFFF) { if (nUpdateRegionRects != 0xFFFF) {
if(cl->screen->maxRectsPerUpdate>0
&& nUpdateRegionRects>cl->screen->maxRectsPerUpdate) {
sraRegion* newUpdateRegion = sraRgnBBox(updateRegion);
sraRgnDestroy(updateRegion);
updateRegion = newUpdateRegion;
nUpdateRegionRects = sraRgnCountRects(updateRegion);
}
fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) + fu->nRects = Swap16IfLE((uint16_t)(sraRgnCountRects(updateCopyRegion) +
nUpdateRegionRects + nUpdateRegionRects +
!!sendCursorShape + !!sendCursorPos)); !!sendCursorShape + !!sendCursorPos));
......
...@@ -521,6 +521,7 @@ ListenOnTCPPort(port) ...@@ -521,6 +521,7 @@ ListenOnTCPPort(port)
int sock; int sock;
int one = 1; int one = 1;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
/* addr.sin_addr.s_addr = interface.s_addr; */ /* addr.sin_addr.s_addr = interface.s_addr; */
...@@ -555,6 +556,7 @@ ConnectToTcpAddr(host, port) ...@@ -555,6 +556,7 @@ ConnectToTcpAddr(host, port)
int sock; int sock;
struct sockaddr_in addr; struct sockaddr_in addr;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
...@@ -587,6 +589,7 @@ ListenOnUDPPort(port) ...@@ -587,6 +589,7 @@ ListenOnUDPPort(port)
int sock; int sock;
int one = 1; int one = 1;
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
/* addr.sin_addr.s_addr = interface.s_addr; */ /* addr.sin_addr.s_addr = interface.s_addr; */
......
...@@ -67,13 +67,13 @@ typedef struct TIGHT_CONF_s { ...@@ -67,13 +67,13 @@ typedef struct TIGHT_CONF_s {
} TIGHT_CONF; } TIGHT_CONF;
static TIGHT_CONF tightConf[10] = { static TIGHT_CONF tightConf[10] = {
{ 512, 32, 6, 65536, 0, 0, 0, 0, 0, 0, 4, 20, 10000, 23000 }, { 512, 32, 6, 65536, 0, 0, 0, 0, 0, 0, 4, 5, 10000, 23000 },
{ 2048, 128, 6, 65536, 1, 1, 1, 0, 0, 0, 8, 30, 8000, 18000 }, { 2048, 128, 6, 65536, 1, 1, 1, 0, 0, 0, 8, 10, 8000, 18000 },
{ 6144, 256, 8, 65536, 3, 3, 2, 0, 0, 0, 24, 40, 6500, 15000 }, { 6144, 256, 8, 65536, 3, 3, 2, 0, 0, 0, 24, 15, 6500, 15000 },
{ 10240, 1024, 12, 65536, 5, 5, 3, 0, 0, 0, 32, 50, 5000, 12000 }, { 10240, 1024, 12, 65536, 5, 5, 3, 0, 0, 0, 32, 25, 5000, 12000 },
{ 16384, 2048, 12, 65536, 6, 6, 4, 0, 0, 0, 32, 55, 4000, 10000 }, { 16384, 2048, 12, 65536, 6, 6, 4, 0, 0, 0, 32, 37, 4000, 10000 },
{ 32768, 2048, 12, 4096, 7, 7, 5, 4, 150, 380, 32, 60, 3000, 8000 }, { 32768, 2048, 12, 4096, 7, 7, 5, 4, 150, 380, 32, 50, 3000, 8000 },
{ 65536, 2048, 16, 4096, 7, 7, 6, 4, 170, 420, 48, 65, 2000, 5000 }, { 65536, 2048, 16, 4096, 7, 7, 6, 4, 170, 420, 48, 60, 2000, 5000 },
{ 65536, 2048, 16, 4096, 8, 8, 7, 5, 180, 450, 64, 70, 1000, 2500 }, { 65536, 2048, 16, 4096, 8, 8, 7, 5, 180, 450, 64, 70, 1000, 2500 },
{ 65536, 2048, 32, 8192, 9, 9, 8, 6, 190, 475, 64, 75, 500, 1200 }, { 65536, 2048, 32, 8192, 9, 9, 8, 6, 190, 475, 64, 75, 500, 1200 },
{ 65536, 2048, 32, 8192, 9, 9, 9, 6, 200, 500, 96, 80, 200, 500 } { 65536, 2048, 32, 8192, 9, 9, 9, 6, 200, 500, 96, 80, 200, 500 }
...@@ -432,6 +432,13 @@ ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr) ...@@ -432,6 +432,13 @@ ExtendSolidArea(cl, x, y, w, h, colorValue, x_ptr, y_ptr, w_ptr, h_ptr)
*w_ptr += cx - (*x_ptr + *w_ptr); *w_ptr += cx - (*x_ptr + *w_ptr);
} }
/*
* Check if a rectangle is all of the same color. If needSameColor is
* set to non-zero, then also check that its color equals to the
* *colorPtr value. The result is 1 if the test is successfull, and in
* that case new color will be stored in *colorPtr.
*/
static Bool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, Bool needSameColor) static Bool CheckSolidTile(rfbClientPtr cl, int x, int y, int w, int h, uint32_t* colorPtr, Bool needSameColor)
{ {
switch(cl->screen->rfbServerFormat.bitsPerPixel) { switch(cl->screen->rfbServerFormat.bitsPerPixel) {
......
...@@ -142,9 +142,13 @@ void ...@@ -142,9 +142,13 @@ void
vncRandomBytes(unsigned char *bytes) vncRandomBytes(unsigned char *bytes)
{ {
int i; int i;
unsigned int seed = (unsigned int) time(0); static Bool s_srandom_called = FALSE;
if (!s_srandom_called) {
srandom((unsigned int)time(0) ^ (unsigned int)getpid());
s_srandom_called = TRUE;
}
srandom(seed);
for (i = 0; i < CHALLENGESIZE; i++) { for (i = 0; i < CHALLENGESIZE; i++) {
bytes[i] = (unsigned char)(random() & 255); bytes[i] = (unsigned char)(random() & 255);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment