a pseudo HTTP request for tunnelling (also via strict Web Proxy) was added.

pull/1/head
dscho 21 years ago
parent 727b025799
commit c3e27a155d

Binary file not shown.

@ -0,0 +1,141 @@
diff -ru vnc_javasrc/OptionsFrame.java proxy_vnc_javasrc/OptionsFrame.java
--- vnc_javasrc/OptionsFrame.java Fri Jul 5 08:17:23 2002
+++ proxy_vnc_javasrc/OptionsFrame.java Thu Aug 22 23:24:44 2002
@@ -70,6 +70,12 @@
Label[] labels = new Label[names.length];
Choice[] choices = new Choice[names.length];
+
+ Label proxyHostLabel;
+ TextField proxyHostEdit;
+ Label proxyPortLabel;
+ TextField proxyPortEdit;
+
Button closeButton;
VncViewer viewer;
@@ -93,6 +99,9 @@
boolean shareDesktop;
boolean viewOnly;
+ String proxyHost;
+ int proxyPort;
+
//
// Constructor. Set up the labels and choices from the names and values
// arrays.
@@ -126,6 +135,32 @@
}
}
+ // TODO: find a way to set these to defaults from browser
+ proxyPort = viewer.readIntParameter("Use Proxy Port", -1);
+ if(proxyPort>-1) {
+ proxyHost = viewer.readParameter("Use Proxy Host", false);
+ if(proxyHost == null)
+ proxyHost = viewer.host;
+
+ proxyHostLabel = new Label("Proxy Host");
+ gbc.gridwidth = 1;
+ gridbag.setConstraints(proxyHostLabel,gbc);
+ add(proxyHostLabel);
+ proxyHostEdit = new TextField();
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints(proxyHostEdit,gbc);
+ add(proxyHostEdit);
+
+ proxyPortLabel = new Label("Proxy Port");
+ gbc.gridwidth = 1;
+ gridbag.setConstraints(proxyPortLabel,gbc);
+ add(proxyPortLabel);
+ proxyPortEdit = new TextField();
+ gbc.gridwidth = GridBagConstraints.REMAINDER;
+ gridbag.setConstraints(proxyPortEdit,gbc);
+ add(proxyPortEdit);
+ }
+
closeButton = new Button("Close");
gbc.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(closeButton, gbc);
@@ -161,6 +196,11 @@
}
}
+ if(proxyPort>-1) {
+ proxyPortEdit.setText(Integer.toString(proxyPort));
+ proxyHostEdit.setText(proxyHost);
+ }
+
// Make the booleans and encodings array correspond to the state of the GUI
setEncodings();
@@ -361,8 +401,12 @@
//
public void actionPerformed(ActionEvent evt) {
- if (evt.getSource() == closeButton)
+ if (evt.getSource() == closeButton) {
setVisible(false);
+ proxyHost = proxyHostEdit.getText();
+ proxyPort = Integer.parseInt(proxyPortEdit.getText());
+ System.err.println("proxy is " + proxyHost + ":" + proxyPort);
+ }
}
//
diff -ru vnc_javasrc/RfbProto.java proxy_vnc_javasrc/RfbProto.java
--- vnc_javasrc/RfbProto.java Sun Aug 4 18:39:35 2002
+++ proxy_vnc_javasrc/RfbProto.java Thu Aug 22 22:53:53 2002
@@ -119,12 +119,51 @@
viewer = v;
host = h;
port = p;
- sock = new Socket(host, port);
+ if(viewer.options.proxyPort>-1)
+ sock = new Socket(viewer.options.proxyHost, viewer.options.proxyPort);
+ else
+ sock = new Socket(host, port);
is = new DataInputStream(new BufferedInputStream(sock.getInputStream(),
16384));
os = sock.getOutputStream();
+ if(viewer.options.proxyPort>-1)
+ negotiateProxy(host,port);
}
+ // this is inefficient as hell, but only used once per connection
+ String readLine() {
+ byte[] ba = new byte[1];
+ String s = new String("");
+
+ ba[0]=0;
+ try {
+ while(ba[0] != 0xa) {
+ ba[0] = (byte)is.readUnsignedByte();
+ s += new String(ba);
+ }
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return s;
+ }
+
+ void negotiateProxy(String realHost,int realPort) throws IOException {
+ String line;
+
+ // this would be the correct way, but we want to trick strict proxies.
+ // line = "CONNECT " + realHost + ":" + realPort + " HTTP/1.1\r\nHost: " + realHost + ":" + realPort + "\r\n\r\n";
+ line = "GET " + realHost + ":" + realPort + "/proxied.connection HTTP/1.0\r\nPragma: No-Cache\r\nProxy-Connection: Keep-Alive\r\n\r\n";
+ os.write(line.getBytes());
+
+ line = readLine();
+ System.err.println("Proxy said: " + line);
+ if(!(line.substring(0,7)+line.substring(8,12)).equalsIgnoreCase("HTTP/1. 200")) {
+ IOException e = new IOException(line);
+ throw e;
+ }
+ while(!line.equals("\r\n") && !line.equals("\n"))
+ line = readLine();
+ }
void close() {
try {

@ -282,6 +282,7 @@ int main(int argc,char** argv)
rfbScreen->kbdAddEvent = dokey;
rfbScreen->newClientHook = newclient;
rfbScreen->httpDir = "./classes";
rfbScreen->httpEnableProxyConnect = TRUE;
initBuffer((unsigned char*)rfbScreen->frameBuffer);
rfbDrawString(rfbScreen,&radonFont,20,100,"Hello, World!",0xffffff);

@ -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++;

@ -544,6 +544,7 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
rfbScreen->rfbListenSock=-1;
rfbScreen->httpInitDone=FALSE;
rfbScreen->httpEnableProxyConnect=FALSE;
rfbScreen->httpPort=0;
rfbScreen->httpDir=NULL;
rfbScreen->httpListenSock=-1;

@ -292,6 +292,7 @@ typedef struct _rfbScreenInfo
/* http stuff */
Bool httpInitDone;
Bool httpEnableProxyConnect;
int httpPort;
char* httpDir;
SOCKET httpListenSock;
@ -634,9 +635,6 @@ extern void rfbSetClientColourMaps(rfbScreenInfoPtr rfbScreen, int firstColour,
/* httpd.c */
extern int httpPort;
extern char *httpDir;
extern void httpInitSockets(rfbScreenInfoPtr rfbScreen);
extern void httpCheckFds(rfbScreenInfoPtr rfbScreen);

Loading…
Cancel
Save