|
32 | 32 | import java.util.Collection; |
33 | 33 | import java.util.Collections; |
34 | 34 | import java.util.EnumSet; |
| 35 | +import java.util.HashMap; |
35 | 36 | import java.util.Iterator; |
36 | 37 | import java.util.List; |
37 | 38 | import java.util.Set; |
|
42 | 43 | import org.apache.sshd.client.auth.AuthenticationIdentitiesProvider; |
43 | 44 | import org.apache.sshd.client.config.hosts.HostConfigEntry; |
44 | 45 | import org.apache.sshd.client.session.ClientSession; |
| 46 | +import org.apache.sshd.common.PropertyResolver; |
45 | 47 | import org.apache.sshd.common.SshConstants; |
46 | 48 | import org.apache.sshd.common.session.Session; |
47 | 49 | import org.apache.sshd.common.util.GenericUtils; |
48 | 50 | import org.apache.sshd.common.util.ReflectionUtils; |
49 | 51 | import org.apache.sshd.common.util.io.input.NoCloseInputStream; |
50 | 52 | import org.apache.sshd.common.util.threads.ThreadUtils; |
| 53 | +import org.apache.sshd.core.CoreModuleProperties; |
51 | 54 | import org.apache.sshd.scp.client.ScpClient; |
52 | 55 | import org.apache.sshd.scp.client.ScpClient.Option; |
53 | 56 | import org.apache.sshd.scp.client.ScpClientCreator; |
|
61 | 64 | import org.apache.sshd.scp.common.helpers.ScpTimestampCommandDetails; |
62 | 65 | import org.slf4j.Logger; |
63 | 66 |
|
| 67 | +import static org.apache.sshd.common.PropertyResolverUtils.toPropertyResolver; |
| 68 | + |
64 | 69 | /** |
65 | 70 | * @see <A HREF="https://man7.org/linux/man-pages/man1/scp.1.html">SCP(1) - manual page</A> |
66 | 71 | * @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a> |
@@ -151,7 +156,7 @@ public static String[] normalizeCommandArguments(PrintStream stdout, PrintStream |
151 | 156 | return null; |
152 | 157 | } |
153 | 158 |
|
154 | | - return effective.toArray(new String[effective.size()]); |
| 159 | + return effective.toArray(new String[0]); |
155 | 160 | } |
156 | 161 |
|
157 | 162 | /* -------------------------------------------------------------------------------- */ |
@@ -248,11 +253,11 @@ public static void showUsageMessage(PrintStream stderr) { |
248 | 253 | public static void xferLocalToRemote( |
249 | 254 | BufferedReader stdin, PrintStream stdout, PrintStream stderr, String[] args, |
250 | 255 | ScpLocation source, ScpLocation target, Collection<Option> options, |
251 | | - OutputStream logStream, Level level, boolean quiet) |
| 256 | + OutputStream logStream, Level level, boolean quiet, PropertyResolver defaultOptions) |
252 | 257 | throws Exception { |
253 | 258 | ScpClientCreator creator = resolveScpClientCreator(stderr, args); |
254 | 259 | ClientSession session = ((logStream == null) || (creator == null) || GenericUtils.isEmpty(args)) |
255 | | - ? null : setupClientSession(SCP_PORT_OPTION, stdin, level, stdout, stderr, args); |
| 260 | + ? null : setupClientSession(SCP_PORT_OPTION, stdin, level, stdout, stderr, args, defaultOptions); |
256 | 261 | if (session == null) { |
257 | 262 | showUsageMessage(stderr); |
258 | 263 | System.exit(-1); |
@@ -330,10 +335,10 @@ private void logEvent( |
330 | 335 | public static void xferRemoteToRemote( |
331 | 336 | BufferedReader stdin, PrintStream stdout, PrintStream stderr, String[] args, |
332 | 337 | ScpLocation source, ScpLocation target, Collection<Option> options, |
333 | | - OutputStream logStream, Level level, boolean quiet) |
| 338 | + OutputStream logStream, Level level, boolean quiet, PropertyResolver defaultOptions) |
334 | 339 | throws Exception { |
335 | 340 | ClientSession srcSession = ((logStream == null) || GenericUtils.isEmpty(args)) |
336 | | - ? null : setupClientSession(SCP_PORT_OPTION, stdin, level, stdout, stderr, args); |
| 341 | + ? null : setupClientSession(SCP_PORT_OPTION, stdin, level, stdout, stderr, args, defaultOptions); |
337 | 342 | if (srcSession == null) { |
338 | 343 | showUsageMessage(stderr); |
339 | 344 | System.exit(-1); |
@@ -444,6 +449,10 @@ public static void main(String[] args) throws Exception { |
444 | 449 | new InputStreamReader(new NoCloseInputStream(System.in), Charset.defaultCharset()))) { |
445 | 450 | args = normalizeCommandArguments(stdout, stderr, args); |
446 | 451 |
|
| 452 | + PropertyResolver defaultOptions = toPropertyResolver(new HashMap<>()); |
| 453 | + CoreModuleProperties.NO_FLOW_CONTROL.set(defaultOptions, Boolean.TRUE); |
| 454 | + CoreModuleProperties.WINDOW_SIZE.set(defaultOptions, 1024L * 1024L * 1024L); |
| 455 | + |
447 | 456 | Level level = Level.SEVERE; |
448 | 457 | int numArgs = GenericUtils.length(args); |
449 | 458 | // see the way normalizeCommandArguments works... |
@@ -472,9 +481,11 @@ public static void main(String[] args) throws Exception { |
472 | 481 | } |
473 | 482 |
|
474 | 483 | if (threeWay) { |
475 | | - xferRemoteToRemote(stdin, stdout, stderr, args, source, target, options, logStream, level, quiet); |
| 484 | + xferRemoteToRemote(stdin, stdout, stderr, args, source, target, options, logStream, level, quiet, |
| 485 | + defaultOptions); |
476 | 486 | } else { |
477 | | - xferLocalToRemote(stdin, stdout, stderr, args, source, target, options, logStream, level, quiet); |
| 487 | + xferLocalToRemote(stdin, stdout, stderr, args, source, target, options, logStream, level, quiet, |
| 488 | + defaultOptions); |
478 | 489 | } |
479 | 490 | } finally { |
480 | 491 | if ((logStream != stdout) && (logStream != stderr)) { |
|
0 commit comments