summaryrefslogtreecommitdiffstats
path: root/libvncclient/sockets.c
diff options
context:
space:
mode:
authorVic Lee <llyzs@163.com>2009-10-01 20:22:36 +0800
committerJohannes Schindelin <johannes.schindelin@gmx.de>2009-10-02 11:52:05 +0200
commit58a8df6ff2bffa46d96b057603c93d824f1c8591 (patch)
tree22b343f454cd04530de84d42320aa1d390a602ea /libvncclient/sockets.c
parent0c061f2a2757384fb4f43c2462f649a1ba5a6c9e (diff)
downloadlibtdevnc-58a8df6ff2bffa46d96b057603c93d824f1c8591.tar.gz
libtdevnc-58a8df6ff2bffa46d96b057603c93d824f1c8591.zip
Add anonymous TLS support in libvncclient
Signed-off-by: Vic Lee <llyzs@163.com>
Diffstat (limited to 'libvncclient/sockets.c')
-rw-r--r--libvncclient/sockets.c33
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) {