From 1a2f49f29cd051d27cc87c08c4da67175b2ea3fe Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 11 Nov 2008 07:18:26 +0000 Subject: * Add compression option to hosts --- src/com/trilead/ssh2/Connection.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/com/trilead/ssh2/Connection.java') diff --git a/src/com/trilead/ssh2/Connection.java b/src/com/trilead/ssh2/Connection.java index 2b244c2..1741a4c 100644 --- a/src/com/trilead/ssh2/Connection.java +++ b/src/com/trilead/ssh2/Connection.java @@ -89,6 +89,7 @@ public class Connection private AuthenticationManager am; private boolean authenticated = false; + private boolean compression = false; private ChannelManager cm; private CryptoWishList cryptoWishList = new CryptoWishList(); @@ -574,6 +575,20 @@ public class Connection tm.setConnectionMonitors(connectionMonitors); } + /** + * Controls whether compression is used on the link or not. + *

+ * Note: This can only be called before connect() + * @param enabled whether to enable compression + * @throws IOException + */ + public synchronized void setCompression(boolean enabled) throws IOException { + if (tm != null) + throw new IOException("Connection to " + hostname + " is already in connected state!"); + + compression = enabled; + } + /** * Close the connection to the SSH-2 server. All assigned sessions will be * closed, too. Can be called at any time. Don't forget to call this once @@ -735,6 +750,12 @@ public class Connection tm.setConnectionMonitors(connectionMonitors); + // Don't offer compression if not requested + if (!compression) { + cryptoWishList.c2s_comp_algos = new String[] { "none" }; + cryptoWishList.s2c_comp_algos = new String[] { "none" }; + } + /* * Make sure that the runnable below will observe the new value of "tm" * and "state" (the runnable will be executed in a different thread, -- cgit v1.2.3