diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2009-11-02 16:13:26 +0100 |
---|---|---|
committer | Johannes Schindelin <johannes.schindelin@gmx.de> | 2009-11-02 16:13:26 +0100 |
commit | f49a292783407c14869d811c05c2bbd009af27f7 (patch) | |
tree | 5cf5e9544f6762bb67e94e195b882120a40bcf3f /libvncclient/sockets.c | |
parent | 67223b7c4d3411dbc5a311c7b66770f2ac9b7b83 (diff) | |
parent | 29990f0090754c722653aafd3fc6800cebc1584c (diff) | |
download | libtdevnc-f49a292783407c14869d811c05c2bbd009af27f7.tar.gz libtdevnc-f49a292783407c14869d811c05c2bbd009af27f7.zip |
Merge branch 'VeNCrypt'
Diffstat (limited to 'libvncclient/sockets.c')
-rw-r--r-- | libvncclient/sockets.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c index d1c507d..489608f 100644 --- a/libvncclient/sockets.c +++ b/libvncclient/sockets.c @@ -44,6 +44,7 @@ #include <arpa/inet.h> #include <netdb.h> #endif +#include "tls.h" void PrintInHex(char *buf, int len); @@ -128,7 +129,16 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n) if (n <= RFB_BUF_SIZE) { while (client->buffered < n) { - int i = read(client->sock, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered); + int i; +#ifdef LIBVNCSERVER_WITH_CLIENT_TLS + if (client->tlsSession) { + i = ReadFromTLS(client, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered); + } else { +#endif + i = read(client->sock, client->buf + client->buffered, RFB_BUF_SIZE - client->buffered); +#ifdef LIBVNCSERVER_WITH_CLIENT_TLS + } +#endif if (i <= 0) { if (i < 0) { #ifdef WIN32 @@ -160,7 +170,16 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n) } else { while (n > 0) { - int i = read(client->sock, out, n); + int i; +#ifdef LIBVNCSERVER_WITH_CLIENT_TLS + if (client->tlsSession) { + i = ReadFromTLS(client, out, n); + } else { +#endif + i = read(client->sock, out, n); +#ifdef LIBVNCSERVER_WITH_CLIENT_TLS + } +#endif if (i <= 0) { if (i < 0) { #ifdef WIN32 @@ -214,6 +233,16 @@ WriteToRFBServer(rfbClient* client, char *buf, int n) if (client->serverPort==-1) return TRUE; /* vncrec playing */ +#ifdef LIBVNCSERVER_WITH_CLIENT_TLS + if (client->tlsSession) { + /* WriteToTLS() will guarantee either everything is written, or error/eof returns */ + i = WriteToTLS(client, buf, n); + if (i <= 0) return FALSE; + + return TRUE; + } +#endif + while (i < n) { j = write(client->sock, buf + i, (n - i)); if (j <= 0) { |