aboutsummaryrefslogtreecommitdiffstats
path: root/lib/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'lib/src/main/java/com')
-rw-r--r--lib/src/main/java/com/trilead/ssh2/channel/DynamicAcceptThread.java23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/src/main/java/com/trilead/ssh2/channel/DynamicAcceptThread.java b/lib/src/main/java/com/trilead/ssh2/channel/DynamicAcceptThread.java
index 33f8200..fee4529 100644
--- a/lib/src/main/java/com/trilead/ssh2/channel/DynamicAcceptThread.java
+++ b/lib/src/main/java/com/trilead/ssh2/channel/DynamicAcceptThread.java
@@ -128,13 +128,6 @@ public class DynamicAcceptThread extends Thread implements IChannelWorkerThread
if (!auth.checkRequest(msg))
throw new SocksException(Proxy.SOCKS_FAILURE);
- if (msg.ip == null) {
- if (msg instanceof Socks5Message) {
- msg.ip = InetAddress.getByName(msg.host);
- } else
- throw new SocksException(Proxy.SOCKS_FAILURE);
- }
-
switch (msg.command) {
case Proxy.SOCKS_CMD_CONNECT:
onConnect(msg);
@@ -175,24 +168,24 @@ public class DynamicAcceptThread extends Thread implements IChannelWorkerThread
StreamForwarder l2r = null;
if (msg instanceof Socks5Message) {
- response = new Socks5Message(Proxy.SOCKS_SUCCESS, sock
- .getLocalAddress(), sock.getLocalPort());
+ response = new Socks5Message(Proxy.SOCKS_SUCCESS, (InetAddress)null, 0);
} else {
- response = new Socks4Message(Socks4Message.REPLY_OK, sock
- .getLocalAddress(), sock.getLocalPort());
-
+ response = new Socks4Message(Socks4Message.REPLY_OK, (InetAddress)null, 0);
}
response.write(out);
+ String destHost = msg.host;
+ if (msg.ip != null)
+ destHost = msg.ip.getHostAddress();
+
try {
/*
* This may fail, e.g., if the remote port is closed (in
* optimistic terms: not open yet)
*/
- cn = cm.openDirectTCPIPChannel(msg.host, msg.port,
- sock.getInetAddress().getHostAddress(),
- sock.getPort());
+ cn = cm.openDirectTCPIPChannel(destHost, msg.port,
+ "127.0.0.1", 0);
} catch (IOException e) {
/*
href='#n188'>188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229