mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 06:47:20 +08:00
fix: lint
This commit is contained in:
@@ -231,7 +231,7 @@ func (s *App) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
rule := str.Cut(raw, "# "+req.Name+"-START", "# "+req.Name+"-END")
|
||||
raw = strings.Replace(raw, "\n# "+req.Name+"-START"+rule+"# "+req.Name+"-END", "", -1)
|
||||
raw = strings.ReplaceAll(raw, "\n# "+req.Name+"-START"+rule+"# "+req.Name+"-END", "")
|
||||
raw = strings.TrimSpace(raw)
|
||||
if err := io.Write("/etc/fail2ban/jail.local", raw, 0644); err != nil {
|
||||
service.Error(w, http.StatusInternalServerError, "写入Fail2ban规则失败")
|
||||
|
||||
@@ -159,7 +159,7 @@ func (s *App) Delete(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
module := str.Cut(config, "# "+req.Name+"-START", "# "+req.Name+"-END")
|
||||
config = strings.Replace(config, "\n# "+req.Name+"-START"+module+"# "+req.Name+"-END", "", -1)
|
||||
config = strings.ReplaceAll(config, "\n# "+req.Name+"-START"+module+"# "+req.Name+"-END", "")
|
||||
|
||||
match := regexp.MustCompile(`auth users = ([^\n]+)`).FindStringSubmatch(module)
|
||||
if len(match) == 2 {
|
||||
@@ -211,7 +211,7 @@ secrets file = /etc/rsyncd.secrets
|
||||
# ` + req.Name + `-END`
|
||||
|
||||
module := str.Cut(config, "# "+req.Name+"-START", "# "+req.Name+"-END")
|
||||
config = strings.Replace(config, "# "+req.Name+"-START"+module+"# "+req.Name+"-END", newConf, -1)
|
||||
config = strings.ReplaceAll(config, "# "+req.Name+"-START"+module+"# "+req.Name+"-END", newConf)
|
||||
|
||||
match := regexp.MustCompile(`auth users = ([^\n]+)`).FindStringSubmatch(module)
|
||||
if len(match) == 2 {
|
||||
|
||||
@@ -574,19 +574,10 @@ func (r *backupRepo) FixPanel() error {
|
||||
}
|
||||
|
||||
// 检查关键文件是否正常
|
||||
flag := false
|
||||
if !io.Exists("/usr/local/etc/panel/config.yml") {
|
||||
flag = true
|
||||
}
|
||||
if !io.Exists(filepath.Join(app.Root, "panel", "web")) {
|
||||
flag = true
|
||||
}
|
||||
if !io.Exists(filepath.Join(app.Root, "panel", "storage", "app.db")) {
|
||||
flag = true
|
||||
}
|
||||
if io.Exists("/tmp/panel-storage.zip") {
|
||||
flag = true
|
||||
}
|
||||
flag := !io.Exists("/usr/local/etc/panel/config.yml") ||
|
||||
!io.Exists(filepath.Join(app.Root, "panel", "web")) ||
|
||||
!io.Exists(filepath.Join(app.Root, "panel", "storage", "app.db")) ||
|
||||
io.Exists("/tmp/panel-storage.zip")
|
||||
// 检查数据库连接
|
||||
if err := r.db.Exec("VACUUM").Error; err != nil {
|
||||
flag = true
|
||||
|
||||
@@ -426,15 +426,16 @@ func (s *FileService) List(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.Sort == "asc" {
|
||||
slices.SortFunc(list, func(a, b stdos.DirEntry) int {
|
||||
return strings.Compare(strings.ToLower(b.Name()), strings.ToLower(a.Name()))
|
||||
})
|
||||
} else if req.Sort == "desc" {
|
||||
switch req.Sort {
|
||||
case "asc":
|
||||
slices.SortFunc(list, func(a, b stdos.DirEntry) int {
|
||||
return strings.Compare(strings.ToLower(a.Name()), strings.ToLower(b.Name()))
|
||||
})
|
||||
} else {
|
||||
case "desc":
|
||||
slices.SortFunc(list, func(a, b stdos.DirEntry) int {
|
||||
return strings.Compare(strings.ToLower(b.Name()), strings.ToLower(a.Name()))
|
||||
})
|
||||
default:
|
||||
slices.SortFunc(list, func(a, b stdos.DirEntry) int {
|
||||
if a.IsDir() && !b.IsDir() {
|
||||
return -1
|
||||
|
||||
@@ -75,11 +75,12 @@ func (s *FirewallService) GetRules(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
isUse := false
|
||||
for port := rule.PortStart; port <= rule.PortEnd; port++ {
|
||||
if rule.Protocol == firewall.ProtocolTCP {
|
||||
switch rule.Protocol {
|
||||
case firewall.ProtocolTCP:
|
||||
isUse = os.TCPPortInUse(port)
|
||||
} else if rule.Protocol == firewall.ProtocolUDP {
|
||||
case firewall.ProtocolUDP:
|
||||
isUse = os.UDPPortInUse(port)
|
||||
} else {
|
||||
default:
|
||||
isUse = os.TCPPortInUse(port) || os.UDPPortInUse(port)
|
||||
}
|
||||
if isUse {
|
||||
|
||||
Reference in New Issue
Block a user