comparison src/ch/ethz/ssh2/channel/DynamicAcceptThread.java @ 353:20412de44c06

update jsocks to 2011-03-19
author Carl Byington <carl@five-ten-sg.com>
date Fri, 01 Aug 2014 11:35:35 -0700
parents 1bf94d2bfafe
children
comparison
equal deleted inserted replaced
352:2bc6805cbc91 353:20412de44c06
65 public void run() { 65 public void run() {
66 try { 66 try {
67 startSession(); 67 startSession();
68 } 68 }
69 catch (IOException ioe) { 69 catch (IOException ioe) {
70 int error_code = Proxy.SOCKS_FAILURE; 70 int error_code = CProxy.SOCKS_FAILURE;
71 71
72 if (ioe instanceof SocksException) 72 if (ioe instanceof SocksException)
73 error_code = ((SocksException) ioe).errCode; 73 error_code = ((SocksException) ioe).errCode;
74 else if (ioe instanceof NoRouteToHostException) 74 else if (ioe instanceof NoRouteToHostException)
75 error_code = Proxy.SOCKS_HOST_UNREACHABLE; 75 error_code = CProxy.SOCKS_HOST_UNREACHABLE;
76 else if (ioe instanceof ConnectException) 76 else if (ioe instanceof ConnectException)
77 error_code = Proxy.SOCKS_CONNECTION_REFUSED; 77 error_code = CProxy.SOCKS_CONNECTION_REFUSED;
78 else if (ioe instanceof InterruptedIOException) 78 else if (ioe instanceof InterruptedIOException)
79 error_code = Proxy.SOCKS_TTL_EXPIRE; 79 error_code = CProxy.SOCKS_TTL_EXPIRE;
80 80
81 if (error_code > Proxy.SOCKS_ADDR_NOT_SUPPORTED 81 if (error_code > CProxy.SOCKS_ADDR_NOT_SUPPORTED
82 || error_code < 0) { 82 || error_code < 0) {
83 error_code = Proxy.SOCKS_FAILURE; 83 error_code = CProxy.SOCKS_FAILURE;
84 } 84 }
85 85
86 sendErrorMessage(error_code); 86 sendErrorMessage(error_code);
87 } 87 }
88 finally { 88 finally {
108 } 108 }
109 else if (version == 4) { 109 else if (version == 4) {
110 msg = new Socks4Message(push_in, false); 110 msg = new Socks4Message(push_in, false);
111 } 111 }
112 else { 112 else {
113 throw new SocksException(Proxy.SOCKS_FAILURE); 113 throw new SocksException(CProxy.SOCKS_FAILURE);
114 } 114 }
115 115
116 return msg; 116 return msg;
117 } 117 }
118 118
131 } 131 }
132 } 132 }
133 133
134 private void handleRequest(ProxyMessage msg) throws IOException { 134 private void handleRequest(ProxyMessage msg) throws IOException {
135 if (!auth.checkRequest(msg)) 135 if (!auth.checkRequest(msg))
136 throw new SocksException(Proxy.SOCKS_FAILURE); 136 throw new SocksException(CProxy.SOCKS_FAILURE);
137 137
138 switch (msg.command) { 138 switch (msg.command) {
139 case Proxy.SOCKS_CMD_CONNECT: 139 case CProxy.SOCKS_CMD_CONNECT:
140 onConnect(msg); 140 onConnect(msg);
141 break; 141 break;
142 142
143 default: 143 default:
144 throw new SocksException(Proxy.SOCKS_CMD_NOT_SUPPORTED); 144 throw new SocksException(CProxy.SOCKS_CMD_NOT_SUPPORTED);
145 } 145 }
146 } 146 }
147 147
148 private void startSession() throws IOException { 148 private void startSession() throws IOException {
149 sock.setSoTimeout(idleTimeout); 149 sock.setSoTimeout(idleTimeout);
174 Channel cn = null; 174 Channel cn = null;
175 StreamForwarder r2l = null; 175 StreamForwarder r2l = null;
176 StreamForwarder l2r = null; 176 StreamForwarder l2r = null;
177 177
178 if (msg instanceof Socks5Message) { 178 if (msg instanceof Socks5Message) {
179 response = new Socks5Message(Proxy.SOCKS_SUCCESS, (InetAddress)null, 0); 179 response = new Socks5Message(CProxy.SOCKS_SUCCESS, (InetAddress)null, 0);
180 } 180 }
181 else { 181 else {
182 response = new Socks4Message(Socks4Message.REPLY_OK, (InetAddress)null, 0); 182 response = new Socks4Message(Socks4Message.REPLY_OK, (InetAddress)null, 0);
183 } 183 }
184 184