[1078] 去除ftp配置中的ip配置 从连接中获取
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.conf;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.web.context.WebServerInitializedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
@@ -9,17 +10,14 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class ServiceInfo implements ApplicationListener<WebServerInitializedEvent> {
|
||||
|
||||
@Getter
|
||||
private static int serverPort;
|
||||
|
||||
public static int getServerPort() {
|
||||
return serverPort;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(WebServerInitializedEvent event) {
|
||||
// 项目启动获取启动的端口号
|
||||
ServiceInfo.serverPort = event.getWebServer().getPort();
|
||||
log.info("项目启动获取启动的端口号: " + ServiceInfo.serverPort);
|
||||
log.info("项目启动获取启动的端口号: {}", ServiceInfo.serverPort);
|
||||
}
|
||||
|
||||
public void setServerPort(int serverPort) {
|
||||
|
||||
@@ -16,7 +16,6 @@ public class FtpSetting {
|
||||
|
||||
private Boolean enable = Boolean.FALSE;
|
||||
|
||||
private String ip;
|
||||
private int port = 21;
|
||||
private String username = "admin";
|
||||
private String password = "admin";
|
||||
|
||||
@@ -25,6 +25,7 @@ public class Ftplet extends DefaultFtplet {
|
||||
|
||||
@Override
|
||||
public FtpletResult beforeCommand(FtpSession session, FtpRequest request) throws FtpException, IOException {
|
||||
System.out.println("beforeCommand");
|
||||
if (request.getCommand().equalsIgnoreCase("USER") && !username.equals(request.getArgument())) {
|
||||
return FtpletResult.DISCONNECT;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public class UserManager implements org.apache.ftpserver.ftplet.UserManager {
|
||||
|
||||
@Override
|
||||
public User getUserByName(String username) throws FtpException {
|
||||
System.out.println("getUserByName");
|
||||
if (!username.equals(this.username)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user