diff options
author | dscho <dscho> | 2002-08-22 20:35:13 +0000 |
---|---|---|
committer | dscho <dscho> | 2002-08-22 20:35:13 +0000 |
commit | c3e27a155d5d08c33e64486141c947aefceb2687 (patch) | |
tree | 1491b00d88870cf05099bf87e924169f5f70b5a8 /httpd.c | |
parent | 727b025799f7c5c37f32c4b57c892faa1e03ba72 (diff) | |
download | libtdevnc-c3e27a155d5d08c33e64486141c947aefceb2687.tar.gz libtdevnc-c3e27a155d5d08c33e64486141c947aefceb2687.zip |
a pseudo HTTP request for tunnelling (also via strict Web Proxy) was added.
Diffstat (limited to 'httpd.c')
-rw-r--r-- | httpd.c | 39 |
1 files changed, 36 insertions, 3 deletions
@@ -22,6 +22,7 @@ */ #include <stdio.h> +#include <ctype.h> #include <unistd.h> #include <sys/types.h> #ifdef WIN32 @@ -50,6 +51,10 @@ "<HEAD><TITLE>File Not Found</TITLE></HEAD>\n" \ "<BODY><H1>File Not Found</H1></BODY>\n" +#define INVALID_REQUEST_STR "HTTP/1.0 400 Invalid Request\n\n" \ + "<HEAD><TITLE>Invalid Request</TITLE></HEAD>\n" \ + "<BODY><H1>Invalid request</H1></BODY>\n" + #define OK_STR "HTTP/1.0 200 OK\nContent-Type: text/html\n\n" static void httpProcessInput(); @@ -253,6 +258,36 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) /* Process the request. */ + if(rfbScreen->httpEnableProxyConnect) { + const static char* PROXY_OK_STR = "HTTP/1.0 200 OK\r\nContent-Type: octet-stream\r\nPragma: no-cache\r\n\r\n"; + if(!strncmp(buf, "CONNECT ", 8)) { + if(atoi(strchr(buf, ':')+1)!=rfbScreen->rfbPort) { + rfbLog("httpd: CONNECT format invalid.\n"); + WriteExact(&cl,INVALID_REQUEST_STR, strlen(INVALID_REQUEST_STR)); + httpCloseSock(rfbScreen); + return; + } + // proxy connection + rfbLog("httpd: client asked for CONNECT\n"); + WriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR)); + rfbNewClient(rfbScreen,rfbScreen->httpSock); + // don't fclose(rfbScreen->httpFP), because this would kill the connection + rfbScreen->httpFP = NULL; + rfbScreen->httpSock = -1; + return; + } + if (!strncmp(buf, "GET ",4) && !strncmp(strchr(buf,'/'),"/proxied.connection HTTP/1.", 27)) { + // proxy connection + rfbLog("httpd: client asked for /proxied.connection\n"); + WriteExact(&cl,PROXY_OK_STR,strlen(PROXY_OK_STR)); + rfbNewClient(rfbScreen,rfbScreen->httpSock); + // don't fclose(rfbScreen->httpFP), because this would kill the connection + rfbScreen->httpFP = NULL; + rfbScreen->httpSock = -1; + return; + } + } + if (strncmp(buf, "GET ", 4)) { rfbLog("httpd: no GET line\n"); httpCloseSock(rfbScreen); @@ -400,10 +435,8 @@ httpProcessInput(rfbScreenInfoPtr rfbScreen) #endif WriteExact(&cl, "?", 1); } else if (compareAndSkip(&ptr, "$PARAMS")) { - if (params[0] != '\0') - WriteExact(httpSock, params, strlen(params)); - + WriteExact(&cl, params, strlen(params)); } else { if (!compareAndSkip(&ptr, "$$")) ptr++; |