01: package vicazh.hyperpool.stream.net.socks;
02:
03: import java.io.*;
04: import vicazh.hyperpool.stream.Connection;
05:
06: /**
07: * This class is the superclass of all socks client stream data
08: *
09: * @author Victor Zhigunov
10: * @version 0.3.14
11: */
12: public class ClientStream extends Stream {
13: public ClientStream() {
14: }
15:
16: /**
17: * @param connection
18: * parent connection
19: * @param outputstream
20: * linked output stream
21: */
22: public ClientStream(Connection connection, OutputStream outputstream) {
23: super (connection, outputstream);
24: }
25:
26: private byte[] auth;
27:
28: /**
29: * Set the authentication data
30: */
31: public void setAuth(byte[] auth) {
32: this .auth = auth;
33: }
34:
35: /**
36: * Get the authentication data
37: */
38: public byte[] getAuth() {
39: return auth;
40: }
41:
42: private int index;
43:
44: public void write(int b) throws IOException {
45: if (mode == Mode.AUTH) {
46: if (index == 1)
47: auth = new byte[b];
48: else if (index > 1) {
49: auth[index - 2] = (byte) b;
50: if (index == auth.length + 1) {
51: byte[] a = new byte[auth.length + 1];
52: a[0] = (byte) auth.length;
53: System.arraycopy(auth, 0, a, 1, auth.length);
54: auth(a);
55: }
56: }
57: index++;
58: } else
59: super.write(b);
60: }
61: }
|