From 58f6c79338ab73305dfefb55ca2a151ac19b0b87 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 25 Jul 2024 12:34:58 +0200 Subject: [PATCH] Implement no-flow-control extension (fixes #539) --- CHANGES.md | 1 + .../sshd/cli/client/ScpCommandMain.java | 25 +- .../sshd/cli/client/SftpCommandMain.java | 11 +- .../sshd/cli/client/SshClientCliSupport.java | 13 +- .../kex/extension/parser/NoFlowControl.java | 3 + .../sshd/common/channel/LocalWindow.java | 5 + .../sshd/common/channel/RemoteWindow.java | 5 + .../apache/sshd/common/channel/Window.java | 5 + .../DefaultClientKexExtensionHandler.java | 22 +- .../DefaultServerKexExtensionHandler.java | 32 +- .../apache/sshd/common/session/Session.java | 6 + .../helpers/AbstractConnectionService.java | 7 + .../session/helpers/AbstractSession.java | 18 + .../helpers/KeyExchangeMessageHandler.java | 3 +- .../sshd/core/CoreModuleProperties.java | 8 + .../org/apache/sshd/NoFlowControlTest.java | 352 ++++++++++++++++++ 16 files changed, 503 insertions(+), 13 deletions(-) create mode 100644 sshd-core/src/test/java/org/apache/sshd/NoFlowControlTest.java diff --git a/CHANGES.md b/CHANGES.md index 09d2d4c15..6b7239fdc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -43,6 +43,7 @@ ## New Features * New utility methods `SftpClient.put(Path localFile, String remoteFileName)` and `SftpClient.put(InputStream in, String remoteFileName)` facilitate SFTP file uploading. +* [GH-539](https://github.com/apache/mina-sshd/issues/539) Implement no-flow-control extension ## Potential compatibility issues diff --git a/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java b/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java index 72102c8cf..977b7ce8f 100644 --- a/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java +++ b/sshd-cli/src/main/java/org/apache/sshd/cli/client/ScpCommandMain.java @@ -32,6 +32,7 @@ import java.util.Collection; import java.util.Collections; import java.util.EnumSet; +import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Set; @@ -42,12 +43,14 @@ import org.apache.sshd.client.auth.AuthenticationIdentitiesProvider; import org.apache.sshd.client.config.hosts.HostConfigEntry; import org.apache.sshd.client.session.ClientSession; +import org.apache.sshd.common.PropertyResolver; import org.apache.sshd.common.SshConstants; import org.apache.sshd.common.session.Session; import org.apache.sshd.common.util.GenericUtils; import org.apache.sshd.common.util.ReflectionUtils; import org.apache.sshd.common.util.io.input.NoCloseInputStream; import org.apache.sshd.common.util.threads.ThreadUtils; +import org.apache.sshd.core.CoreModuleProperties; import org.apache.sshd.scp.client.ScpClient; import org.apache.sshd.scp.client.ScpClient.Option; import org.apache.sshd.scp.client.ScpClientCreator; @@ -61,6 +64,8 @@ import org.apache.sshd.scp.common.helpers.ScpTimestampCommandDetails; import org.slf4j.Logger; +import static org.apache.sshd.common.PropertyResolverUtils.toPropertyResolver; + /** * @see SCP(1) - manual page * @author Apache MINA SSHD Project @@ -151,7 +156,7 @@ public static String[] normalizeCommandArguments(PrintStream stdout, PrintStream return null; } - return effective.toArray(new String[effective.size()]); + return effective.toArray(new String[0]); } /* -------------------------------------------------------------------------------- */ @@ -248,11 +253,11 @@ public static void showUsageMessage(PrintStream stderr) { public static void xferLocalToRemote( BufferedReader stdin, PrintStream stdout, PrintStream stderr, String[] args, ScpLocation source, ScpLocation target, Collection