diff --git a/README.md b/README.md index 229be3e..fe73df2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Fake SFTP Server Rule is available from com.github.stefanbirkner fake-sftp-server-rule - 2.0.1 + 2.1.1 If you upgrade from a version < 2.x to the newest version please read the last diff --git a/pom.xml b/pom.xml index 67d5baf..bd2d02e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ fake-sftp-server-rule - 2.1.0-SNAPSHOT + 2.1.1 jar Fake SFTP Server Rule diff --git a/src/main/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRule.java b/src/main/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRule.java index f8d0a41..2880de6 100644 --- a/src/main/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRule.java +++ b/src/main/java/com/github/stefanbirkner/fakesftpserver/rule/FakeSftpServerRule.java @@ -1,5 +1,6 @@ package com.github.stefanbirkner.fakesftpserver.rule; +import java.util.function.Consumer; import org.apache.sshd.server.SshServer; import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider; import org.apache.sshd.server.session.ServerSession; @@ -182,6 +183,23 @@ public FileVisitResult postVisitDirectory( private FileSystem fileSystem; private SshServer server; + private Consumer sshServerConsumer = (sshServer) -> {}; + + /** + * Configures the internal SFTP server of the Apache SSHD project. + * If you need personal changes in internal SFTP server that + * are not supported by the rule, you can use this method to get the inner + * internal SFTP server of the rule before construction and change it to + * suit your needs. + * (Correct use of this feature is the responsibility of the user) + * + * @param sshServerConsumer internal SFTP server consumer + * @return the rule itself. + */ + public FakeSftpServerRule configureInternalSshServer(Consumer sshServerConsumer) { + this.sshServerConsumer = sshServerConsumer; + return this; + } /** * Returns the port of the SFTP server. If the SFTP server listens on an @@ -435,6 +453,7 @@ private SshServer startServer( * have to use a file system wrapper whose close() does nothing. */ server.setFileSystemFactory(session -> new DoNotClose(fileSystem)); + sshServerConsumer.accept(server); server.start(); this.server = server; return server;