Skip to content

Commit

Permalink
Merge pull request #232 from scireum/jmu/ftp-passive-ports
Browse files Browse the repository at this point in the history
Allow to set the ports to use in FTP passive mode
  • Loading branch information
andyHa authored Dec 18, 2018
2 parents a1ef437 + 548af29 commit 49912b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/sirius/biz/vfs/ftp/FTPBridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package sirius.biz.vfs.ftp;

import org.apache.ftpserver.DataConnectionConfigurationFactory;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.FtpException;
Expand Down Expand Up @@ -38,6 +39,9 @@ public class FTPBridge {
@ConfigValue("vfs.ftp.port")
private int ftpPort;

@ConfigValue("vfs.ftp.passivePorts")
private String passivePorts;

@ConfigValue("vfs.ftp.bindAddress")
private String bindAddress;

Expand Down Expand Up @@ -122,9 +126,19 @@ private void createFTPServer() {
private void setupNetwork(ListenerFactory factory) {
factory.setPort(ftpPort);
factory.setIdleTimeout((int) idleTimeout.getSeconds());

if (Strings.isFilled(bindAddress)) {
factory.setServerAddress(bindAddress);
}

if (Strings.isFilled(passivePorts)) {
DataConnectionConfigurationFactory dataConnectionConfigurationFactory =
new DataConnectionConfigurationFactory();

dataConnectionConfigurationFactory.setPassivePorts(passivePorts);

factory.setDataConnectionConfiguration(dataConnectionConfigurationFactory.createDataConnectionConfiguration());
}
}

private void setupFtplets(FtpServerFactory serverFactory) {
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/component-biz.conf
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,14 @@ vfs {
# Specifies the port to listen on. Use 0 to disable the server or 21 to run it on the common FTP port.
port = 0

# Specifies the port range to listen on for the data connection in passive mode, use any by default
# Examples:
# 2300 only use port 2300 as the passive port
# 2300-2399 use all ports in the range
# 2300- use all ports larger than 2300
# 2300, 2305, 2400- use 2300 or 2305 or any port larger than 2400
passivePorts = ""

# Specifies the IP address to bind to. Leave empty to use all IP addresses.
bindAddress = ""

Expand Down

0 comments on commit 49912b7

Please sign in to comment.