You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by gn...@apache.org on 2014/06/03 21:44:00 UTC
git commit: [SSHD-321] The server Direct TcpIp Channel does not
consume the local window leading to waiting forever
Repository: mina-sshd
Updated Branches:
refs/heads/master 569fac2a3 -> 1a84ede6b
[SSHD-321] The server Direct TcpIp Channel does not consume the local window leading to waiting forever
Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/1a84ede6
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/1a84ede6
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/1a84ede6
Branch: refs/heads/master
Commit: 1a84ede6bcdc7b93338bef8427c4a3fee96ad61f
Parents: 569fac2
Author: Guillaume Nodet <gn...@apache.org>
Authored: Tue Jun 3 21:43:43 2014 +0200
Committer: Guillaume Nodet <gn...@apache.org>
Committed: Tue Jun 3 21:43:43 2014 +0200
----------------------------------------------------------------------
.../sshd/common/forward/TcpipServerChannel.java | 1 +
.../org/apache/sshd/PortForwardingTest.java | 54 ++++++++++++++++++++
2 files changed, 55 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1a84ede6/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
index 6709e7e..667876a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/forward/TcpipServerChannel.java
@@ -183,6 +183,7 @@ public class TcpipServerChannel extends AbstractServerChannel {
}
protected void doWriteData(byte[] data, int off, int len) throws IOException {
+ localWindow.consumeAndCheck(len);
// Make sure we copy the data as the incoming buffer may be reused
Buffer buf = new Buffer(data, off, len);
buf = new Buffer(buf.getCompactData());
http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/1a84ede6/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
index 63db60b..43303ea 100644
--- a/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/PortForwardingTest.java
@@ -71,6 +71,8 @@ public class PortForwardingTest extends BaseTest {
echoPort = getFreePort();
sshd = SshServer.setUpDefaultServer();
+ sshd.getProperties().put(SshServer.WINDOW_SIZE, "2048");
+ sshd.getProperties().put(SshServer.MAX_PACKET_SIZE, "256");
sshd.setPort(sshPort);
sshd.setKeyPairProvider(Utils.createTestHostKeyProvider());
sshd.setShellFactory(new EchoShellFactory());
@@ -154,6 +156,32 @@ public class PortForwardingTest extends BaseTest {
}
@Test
+ public void testRemoteForwardingNativeBigPayload() throws Exception {
+ ClientSession session = createNativeSession();
+
+ int forwardedPort = getFreePort();
+ SshdSocketAddress remote = new SshdSocketAddress("", forwardedPort);
+ SshdSocketAddress local = new SshdSocketAddress("localhost", echoPort);
+
+ session.startRemotePortForwarding(remote, local);
+
+ byte[] buf = new byte[1024];
+
+ Socket s = new Socket(remote.getHostName(), remote.getPort());
+ for (int i = 0; i < 1000; i++) {
+ s.getOutputStream().write("0123456789".getBytes());
+ s.getOutputStream().flush();
+ int n = s.getInputStream().read(buf);
+ String res = new String(buf, 0, n);
+ assertEquals("0123456789", res);
+ }
+ s.close();
+
+ session.stopRemotePortForwarding(remote);
+ session.close(false).await();
+ }
+
+ @Test
public void testRemoteForwardingNativeNoExplicitPort() throws Exception {
ClientSession session = createNativeSession();
@@ -218,6 +246,30 @@ public class PortForwardingTest extends BaseTest {
}
@Test
+ public void testLocalForwardingNativeBigPayload() throws Exception {
+ ClientSession session = createNativeSession();
+
+ SshdSocketAddress local = new SshdSocketAddress("", getFreePort());
+ SshdSocketAddress remote = new SshdSocketAddress("localhost", echoPort);
+
+ SshdSocketAddress bound = session.startLocalPortForwarding(local, remote);
+
+ byte[] buf = new byte[1024];
+ Socket s = new Socket(bound.getHostName(), bound.getPort());
+ for (int i = 0; i < 1000; i++) {
+ s.getOutputStream().write("Hello".getBytes());
+ s.getOutputStream().flush();
+ int n = s.getInputStream().read(buf);
+ String res = new String(buf, 0, n);
+ assertEquals("Hello", res);
+ }
+ s.close();
+
+ session.stopLocalPortForwarding(bound);
+ session.close(false).await();
+ }
+
+ @Test
public void testForwardingChannel() throws Exception {
ClientSession session = createNativeSession();
@@ -366,6 +418,8 @@ public class PortForwardingTest extends BaseTest {
protected ClientSession createNativeSession() throws Exception {
client = SshClient.setUpDefaultClient();
+ client.getProperties().put(SshServer.WINDOW_SIZE, "2048");
+ client.getProperties().put(SshServer.MAX_PACKET_SIZE, "256");
client.setTcpipForwardingFilter(new BogusForwardingFilter());
client.start();
ConnectFuture sessionFuture = client.connect("localhost", sshPort);