1 diff -ru vnc_javasrc/OptionsFrame.java proxy_vnc_javasrc/OptionsFrame.java
2 --- vnc_javasrc/OptionsFrame.java Fri Jul 5 08:17:23 2002
3 +++ proxy_vnc_javasrc/OptionsFrame.java Thu Aug 22 23:24:44 2002
6 Label[] labels = new Label[names.length];
7 Choice[] choices = new Choice[names.length];
9 + Label proxyHostLabel;
10 + TextField proxyHostEdit;
11 + Label proxyPortLabel;
12 + TextField proxyPortEdit;
25 // Constructor. Set up the labels and choices from the names and values
31 + // TODO: find a way to set these to defaults from browser
32 + proxyPort = viewer.readIntParameter("Use Proxy Port", -1);
34 + proxyHost = viewer.readParameter("Use Proxy Host", false);
35 + if(proxyHost == null)
36 + proxyHost = viewer.host;
38 + proxyHostLabel = new Label("Proxy Host");
40 + gridbag.setConstraints(proxyHostLabel,gbc);
41 + add(proxyHostLabel);
42 + proxyHostEdit = new TextField();
43 + gbc.gridwidth = GridBagConstraints.REMAINDER;
44 + gridbag.setConstraints(proxyHostEdit,gbc);
47 + proxyPortLabel = new Label("Proxy Port");
49 + gridbag.setConstraints(proxyPortLabel,gbc);
50 + add(proxyPortLabel);
51 + proxyPortEdit = new TextField();
52 + gbc.gridwidth = GridBagConstraints.REMAINDER;
53 + gridbag.setConstraints(proxyPortEdit,gbc);
57 closeButton = new Button("Close");
58 gbc.gridwidth = GridBagConstraints.REMAINDER;
59 gridbag.setConstraints(closeButton, gbc);
65 + proxyPortEdit.setText(Integer.toString(proxyPort));
66 + proxyHostEdit.setText(proxyHost);
69 // Make the booleans and encodings array correspond to the state of the GUI
75 public void actionPerformed(ActionEvent evt) {
76 - if (evt.getSource() == closeButton)
77 + if (evt.getSource() == closeButton) {
79 + proxyHost = proxyHostEdit.getText();
80 + proxyPort = Integer.parseInt(proxyPortEdit.getText());
81 + System.err.println("proxy is " + proxyHost + ":" + proxyPort);
86 diff -ru vnc_javasrc/RfbProto.java proxy_vnc_javasrc/RfbProto.java
87 --- vnc_javasrc/RfbProto.java Sun Aug 4 18:39:35 2002
88 +++ proxy_vnc_javasrc/RfbProto.java Thu Aug 22 22:53:53 2002
93 - sock = new Socket(host, port);
94 + if(viewer.options.proxyPort>-1)
95 + sock = new Socket(viewer.options.proxyHost, viewer.options.proxyPort);
97 + sock = new Socket(host, port);
98 is = new DataInputStream(new BufferedInputStream(sock.getInputStream(),
100 os = sock.getOutputStream();
101 + if(viewer.options.proxyPort>-1)
102 + negotiateProxy(host,port);
105 + // this is inefficient as hell, but only used once per connection
106 + String readLine() {
107 + byte[] ba = new byte[1];
108 + String s = new String("");
112 + while(ba[0] != 0xa) {
113 + ba[0] = (byte)is.readUnsignedByte();
114 + s += new String(ba);
116 + } catch(Exception e) {
117 + e.printStackTrace();
122 + void negotiateProxy(String realHost,int realPort) throws IOException {
125 + // this would be the correct way, but we want to trick strict proxies.
126 + // line = "CONNECT " + realHost + ":" + realPort + " HTTP/1.1\r\nHost: " + realHost + ":" + realPort + "\r\n\r\n";
127 + line = "GET " + realHost + ":" + realPort + "/proxied.connection HTTP/1.0\r\nPragma: No-Cache\r\nProxy-Connection: Keep-Alive\r\n\r\n";
128 + os.write(line.getBytes());
131 + System.err.println("Proxy said: " + line);
132 + if(!(line.substring(0,7)+line.substring(8,12)).equalsIgnoreCase("HTTP/1. 200")) {
133 + IOException e = new IOException(line);
136 + while(!line.equals("\r\n") && !line.equals("\n"))