diff options
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 5cfc743..4dd8165 100644 --- a/libvncclient/sockets.c +++ b/libvncclient/sockets.c @@ -43,6 +43,7 @@ #include <arpa/inet.h> #include <netdb.h> #endif +#include "tls.h" void PrintInHex(char *buf, int len); @@ -127,7 +128,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 @@ -159,7 +169,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 @@ -213,6 +232,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) { |