2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

refactor: 重构防火墙

This commit is contained in:
耗子
2024-10-18 02:08:55 +08:00
parent 905e206f9c
commit e9cbc8e945
19 changed files with 1399 additions and 373 deletions

View File

@@ -22,7 +22,7 @@ func Execf(shell string, args ...any) (string, error) {
err := cmd.Run()
if err != nil {
return "", errors.New(strings.TrimSpace(stderr.String()))
return strings.TrimSpace(stdout.String()), errors.New(strings.TrimSpace(stderr.String()))
}
return strings.TrimSpace(stdout.String()), err
@@ -71,10 +71,10 @@ func ExecfWithTimeout(timeout time.Duration, shell string, args ...any) (string,
select {
case <-time.After(timeout):
_ = cmd.Process.Kill()
return "", errors.New("执行超时")
return strings.TrimSpace(stdout.String()), errors.New("执行超时")
case err = <-done:
if err != nil {
return "", errors.New(strings.TrimSpace(stderr.String()))
return strings.TrimSpace(stdout.String()), errors.New(strings.TrimSpace(stderr.String()))
}
}