diff options
author | David Ostrovsky <david@ostrovsky.org> | 2014-03-14 00:34:50 +0100 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2014-04-10 18:58:08 -0400 |
commit | bf4fc5c25ec31566b0fc1ee2e5e8bc15e5512893 (patch) | |
tree | ede724e915e957c33599631710a7f377afa4d455 /src | |
parent | 9ba6bc127276f4b092849336f793aac2135f7887 (diff) | |
download | gitblit-bf4fc5c25ec31566b0fc1ee2e5e8bc15e5512893.tar.gz gitblit-bf4fc5c25ec31566b0fc1ee2e5e8bc15e5512893.zip |
Add support for NIO2 IoSession
Starting from version 0.9.0 Apache SSHD project added support for NIO2
IoSession. To use the new NIO2 session the `backend` option must be set
to `NIO2`.
By default, `NIO2`.
Change-Id: I06cf92b02e80ecf9e8bfbd9f6d6d623dfe3ccff3
Diffstat (limited to 'src')
-rw-r--r-- | src/main/distrib/data/gitblit.properties | 5 | ||||
-rw-r--r-- | src/main/java/com/gitblit/transport/ssh/SshDaemon.java | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties index 2338cc5b..64a52f5c 100644 --- a/src/main/distrib/data/gitblit.properties +++ b/src/main/distrib/data/gitblit.properties @@ -124,6 +124,11 @@ git.sshKeysManager = com.gitblit.transport.ssh.FileKeyManager # SINCE 1.5.0
git.sshKeysFolder= ${baseFolder}/ssh
+# SSH backend NIO2|MINA.
+#
+# SINCE 1.5.0
+git.sshBackend = NIO2
+
# Allow push/pull over http/https with JGit servlet.
# If you do NOT want to allow Git clients to clone/push to Gitblit set this
# to false. You might want to do this if you are only using ssh:// or git://.
diff --git a/src/main/java/com/gitblit/transport/ssh/SshDaemon.java b/src/main/java/com/gitblit/transport/ssh/SshDaemon.java index 5bd397d7..f0429a7c 100644 --- a/src/main/java/com/gitblit/transport/ssh/SshDaemon.java +++ b/src/main/java/com/gitblit/transport/ssh/SshDaemon.java @@ -24,6 +24,12 @@ import java.util.concurrent.atomic.AtomicBoolean; import javax.inject.Singleton; import org.apache.sshd.SshServer; +import org.apache.sshd.common.io.IoServiceFactory; +import org.apache.sshd.common.io.IoServiceFactoryFactory; +import org.apache.sshd.common.io.mina.MinaServiceFactory; +import org.apache.sshd.common.io.mina.MinaServiceFactoryFactory; +import org.apache.sshd.common.io.nio2.Nio2ServiceFactory; +import org.apache.sshd.common.io.nio2.Nio2ServiceFactoryFactory; import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider; import org.eclipse.jgit.internal.JGitText; import org.slf4j.Logger; @@ -59,6 +65,10 @@ public class SshDaemon { private final Logger log = LoggerFactory.getLogger(SshDaemon.class); + public static enum SshSessionBackend { + MINA, NIO2 + } + /** * 22: IANA assigned port number for ssh. Note that this is a distinct * concept from gitblit's default conf for ssh port -- this "default" is @@ -90,6 +100,14 @@ public class SshDaemon { "localhost"); IKeyManager keyManager = getKeyManager(); + + String sshBackendStr = settings.getString(Keys.git.sshBackend, + SshSessionBackend.NIO2.name()); + SshSessionBackend backend = SshSessionBackend.valueOf(sshBackendStr); + System.setProperty(IoServiceFactoryFactory.class.getName(), + backend == SshSessionBackend.MINA + ? MinaServiceFactoryFactory.class.getName() + : Nio2ServiceFactoryFactory.class.getName()); InetSocketAddress addr; if (StringUtils.isEmpty(bindInterface)) { |