|
@@ -57,6 +57,7 @@ public class DocFtpServer {
|
|
|
if (enable()) {
|
|
|
int port = Integer.parseInt(environment.getProperty("ftp.port"));
|
|
|
String passivePorts = environment.getProperty("ftp.passivePorts");
|
|
|
+ String ip = environment.getProperty("ftp.ip");
|
|
|
System.err.println();
|
|
|
FtpServerFactory serverFactory = new FtpServerFactory();
|
|
|
ListenerFactory listenerFactory = new ListenerFactory();
|
|
@@ -65,6 +66,8 @@ public class DocFtpServer {
|
|
|
//2、设置被动模式数据上传的接口范围,云服务器需要开放对应区间的端口给客户端
|
|
|
DataConnectionConfigurationFactory dataConnectionConfFactory = new DataConnectionConfigurationFactory();
|
|
|
dataConnectionConfFactory.setPassivePorts(passivePorts);
|
|
|
+ //返回给客户端可以通信的IP地址
|
|
|
+ dataConnectionConfFactory.setPassiveExternalAddress(ip);
|
|
|
listenerFactory.setDataConnectionConfiguration(dataConnectionConfFactory.createDataConnectionConfiguration());
|
|
|
//3、增加SSL安全配置
|
|
|
// SslConfigurationFactory ssl = new SslConfigurationFactory();
|
|
@@ -76,10 +79,10 @@ public class DocFtpServer {
|
|
|
// listenerFactory.setImplicitSsl(true);
|
|
|
//4、替换默认的监听器
|
|
|
Listener listener = listenerFactory.createListener();
|
|
|
- serverFactory.addListener("default", listener);
|
|
|
+ serverFactory.addListener("default" , listener);
|
|
|
//5、配置自定义用户事件
|
|
|
Map<String, Ftplet> ftpLets = new HashMap(16);
|
|
|
- ftpLets.put("ftpService", new DocFtpLet());
|
|
|
+ ftpLets.put("ftpService" , new DocFtpLet());
|
|
|
serverFactory.setFtplets(ftpLets);
|
|
|
//6、读取用户的配置信息
|
|
|
//注意:配置文件位于resources目录下,如果项目使用内置容器打成jar包发布,FTPServer无法直接直接读取Jar包中的配置文件。
|