diff --git a/backend/app/service/ftp.go b/backend/app/service/ftp.go index 22664b920..c41f1065f 100644 --- a/backend/app/service/ftp.go +++ b/backend/app/service/ftp.go @@ -104,8 +104,8 @@ func (f *FtpService) Sync() error { for _, itemInDB := range listsInDB { if item.User == itemInDB.User { sameData[item.User] = struct{}{} - if item.Path != itemInDB.Path { - _ = ftpRepo.Update(itemInDB.ID, map[string]interface{}{"path": item.Path, "status": constant.StatusDisable}) + if item.Path != itemInDB.Path || item.Status != itemInDB.Status { + _ = ftpRepo.Update(itemInDB.ID, map[string]interface{}{"path": item.Path, "status": item.Status}) } break } @@ -113,7 +113,7 @@ func (f *FtpService) Sync() error { } for _, item := range lists { if _, ok := sameData[item.User]; !ok { - _ = ftpRepo.Create(&model.Ftp{User: item.User, Path: item.Path, Status: constant.StatusDisable}) + _ = ftpRepo.Create(&model.Ftp{User: item.User, Path: item.Path, Status: item.Status}) } } for _, item := range listsInDB { @@ -127,7 +127,7 @@ func (f *FtpService) Sync() error { func (f *FtpService) Create(req dto.FtpCreate) (uint, error) { if _, err := os.Stat(req.Path); err != nil { if os.IsNotExist(err) { - if err := os.MkdirAll(req.Path, os.ModePerm); err != nil { + if err := os.MkdirAll(req.Path, os.ModePerm); err != nil { return 0, err } } else { diff --git a/backend/utils/toolbox/pure-ftpd.go b/backend/utils/toolbox/pure-ftpd.go index cbfc22af9..e4a1038dd 100644 --- a/backend/utils/toolbox/pure-ftpd.go +++ b/backend/utils/toolbox/pure-ftpd.go @@ -11,6 +11,7 @@ import ( "time" "github.com/1Panel-dev/1Panel/backend/constant" + "github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/utils/cmd" "github.com/1Panel-dev/1Panel/backend/utils/systemctl" ) @@ -152,14 +153,25 @@ func (f *Ftp) LoadList() ([]FtpList, error) { if len(parts) < 2 { continue } - lists = append(lists, FtpList{User: parts[0], Path: strings.ReplaceAll(parts[1], "/./", "")}) + std2, err := cmd.Execf("pure-pw show %s | grep 'Allowed client IPs :'", parts[0]) + if err != nil { + global.LOG.Errorf("handle pure-pw show %s faile, err: %v", parts[0], std2) + continue + } + status := constant.StatusDisable + itemStd := strings.ReplaceAll(std2, "\n", "") + if len(strings.TrimSpace(strings.ReplaceAll(itemStd, "Allowed client IPs :", ""))) == 0 { + status = constant.StatusEnable + } + lists = append(lists, FtpList{User: parts[0], Path: strings.ReplaceAll(parts[1], "/./", ""), Status: status}) } return lists, nil } type FtpList struct { - User string - Path string + User string + Path string + Status string } func (f *Ftp) Reload() error { diff --git a/frontend/src/views/toolbox/ftp/index.vue b/frontend/src/views/toolbox/ftp/index.vue index b9eda33d1..3b28e5a48 100644 --- a/frontend/src/views/toolbox/ftp/index.vue +++ b/frontend/src/views/toolbox/ftp/index.vue @@ -122,12 +122,11 @@ - + + + { }); }; +const onChange = async (row: any) => { + await await updateFtp(row); + MsgSuccess(i18n.global.t('commons.msg.operationSuccess')); +}; + const onOpenDialog = async (title: string, rowData: Partial = {}) => { let params = { title,