annotate src/net/sourceforge/jsocks/server/ServerAuthenticatorNone.java @ 369:7a5943a514d5

debug kex error
author Carl Byington <carl@five-ten-sg.com>
date Mon, 04 Aug 2014 11:39:58 -0700
parents 72de889ecfe7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
350
72de889ecfe7 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 349
diff changeset
1 package net.sourceforge.jsocks.server;
349
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
2 import net.sourceforge.jsocks.ProxyMessage;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
3 import net.sourceforge.jsocks.UDPEncapsulation;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
4
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
5 import java.io.IOException;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
6 import java.io.InputStream;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
7 import java.io.DataInputStream;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
8 import java.io.OutputStream;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
9 import java.io.PushbackInputStream;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
10 import java.net.Socket;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
11
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
12 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
13 An implementation of ServerAuthenticator, which does <b>not</b> do
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
14 any authentication.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
15 <P>
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
16 <FONT size="+3" color ="FF0000"> Warning!!</font><br> Should not be
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
17 used on machines which are not behind the firewall.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
18 <p>
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
19 It is only provided to make implementing other authentication schemes
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
20 easier.<br>
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
21 For Example: <tt><pre>
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
22 class MyAuth extends socks.server.ServerAuthenticator{
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
23 ...
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
24 public ServerAuthenticator startSession(java.net.Socket s){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
25 if(!checkHost(s.getInetAddress()) return null;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
26 return super.startSession(s);
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
27 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
28
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
29 boolean checkHost(java.net.Inetaddress addr){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
30 boolean allow;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
31 //Do it somehow
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
32 return allow;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
33 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
34 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
35 </pre></tt>
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
36 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
37 public class ServerAuthenticatorNone implements ServerAuthenticator{
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
38
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
39 static final byte[] socks5response = {5,0};
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
40
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
41 InputStream in;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
42 OutputStream out;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
43
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
44 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
45 Creates new instance of the ServerAuthenticatorNone.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
46 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
47 public ServerAuthenticatorNone(){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
48 this.in = null;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
49 this.out = null;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
50 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
51 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
52 Constructs new ServerAuthenticatorNone object suitable for returning
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
53 from the startSession function.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
54 @param in Input stream to return from getInputStream method.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
55 @param out Output stream to return from getOutputStream method.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
56 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
57 public ServerAuthenticatorNone(InputStream in, OutputStream out){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
58 this.in = in;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
59 this.out = out;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
60 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
61 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
62 Grants access to everyone.Removes authentication related bytes from
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
63 the stream, when a SOCKS5 connection is being made, selects an
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
64 authentication NONE.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
65 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
66 public ServerAuthenticator startSession(Socket s)
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
67 throws IOException{
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
68
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
69 PushbackInputStream in = new PushbackInputStream(s.getInputStream());
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
70 OutputStream out = s.getOutputStream();
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
71
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
72 int version = in.read();
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
73 if(version == 5){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
74 if(!selectSocks5Authentication(in,out,0))
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
75 return null;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
76 }else if(version == 4){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
77 //Else it is the request message allready, version 4
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
78 in.unread(version);
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
79 }else
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
80 return null;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
81
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
82
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
83 return new ServerAuthenticatorNone(in,out);
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
84 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
85
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
86 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
87 Get input stream.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
88 @return Input stream speciefied in the constructor.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
89 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
90 public InputStream getInputStream(){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
91 return in;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
92 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
93 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
94 Get output stream.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
95 @return Output stream speciefied in the constructor.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
96 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
97 public OutputStream getOutputStream(){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
98 return out;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
99 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
100 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
101 Allways returns null.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
102 @return null
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
103 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
104 public UDPEncapsulation getUdpEncapsulation(){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
105 return null;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
106 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
107
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
108 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
109 Allways returns true.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
110 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
111 public boolean checkRequest(ProxyMessage msg){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
112 return true;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
113 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
114
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
115 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
116 Allways returns true.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
117 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
118 public boolean checkRequest(java.net.DatagramPacket dp, boolean out){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
119 return true;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
120 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
121
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
122 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
123 Does nothing.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
124 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
125 public void endSession(){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
126 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
127
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
128 /**
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
129 Convinience routine for selecting SOCKSv5 authentication.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
130 <p>
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
131 This method reads in authentication methods that client supports,
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
132 checks wether it supports given method. If it does, the notification
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
133 method is written back to client, that this method have been chosen
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
134 for authentication. If given method was not found, authentication
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
135 failure message is send to client ([5,FF]).
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
136 @param in Input stream, version byte should be removed from the stream
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
137 before calling this method.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
138 @param out Output stream.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
139 @param methodId Method which should be selected.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
140 @return true if methodId was found, false otherwise.
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
141 */
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
142 static public boolean selectSocks5Authentication(InputStream in,
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
143 OutputStream out,
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
144 int methodId)
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
145 throws IOException{
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
146
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
147 int num_methods = in.read();
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
148 if (num_methods <= 0) return false;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
149 byte method_ids[] = new byte[num_methods];
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
150 byte response[] = new byte[2];
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
151 boolean found = false;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
152
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
153 response[0] = (byte) 5; //SOCKS version
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
154 response[1] = (byte) 0xFF; //Not found, we are pessimistic
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
155
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
156 int bread = 0; //bytes read so far
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
157 while(bread < num_methods)
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
158 bread += in.read(method_ids,bread,num_methods-bread);
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
159
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
160 for(int i=0;i<num_methods;++i)
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
161 if(method_ids[i] == methodId){
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
162 found = true;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
163 response[1] = (byte) methodId;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
164 break;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
165 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
166
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
167 out.write(response);
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
168 return found;
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
169 }
205ee2873330 update jsocks to 2011-03-19
Carl Byington <carl@five-ten-sg.com>
parents: 0
diff changeset
170 }