mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 11:27:17 +08:00
feat: 优化防火墙启停流程
This commit is contained in:
@@ -39,14 +39,32 @@ func (r *SafeController) SetFirewallStatus(ctx http.Context) http.Response {
|
||||
if ctx.Request().InputBool("status") {
|
||||
if tools.IsRHEL() {
|
||||
err = tools.ServiceStart("firewalld")
|
||||
if err == nil {
|
||||
err = tools.ServiceEnable("firewalld")
|
||||
}
|
||||
} else {
|
||||
_, err = tools.Exec("echo y | ufw enable")
|
||||
if err == nil {
|
||||
err = tools.ServiceStart("ufw")
|
||||
}
|
||||
if err == nil {
|
||||
err = tools.ServiceEnable("ufw")
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if tools.IsRHEL() {
|
||||
err = tools.ServiceStop("firewalld")
|
||||
if err == nil {
|
||||
err = tools.ServiceDisable("firewalld")
|
||||
}
|
||||
} else {
|
||||
_, err = tools.Exec("ufw disable")
|
||||
if err == nil {
|
||||
err = tools.ServiceStop("ufw")
|
||||
}
|
||||
if err == nil {
|
||||
err = tools.ServiceDisable("ufw")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -289,6 +289,8 @@ Init_Panel() {
|
||||
elif [ "${OS}" == "debian" ]; then
|
||||
apt-get install ufw -y
|
||||
echo y | ufw enable
|
||||
systemctl enable ufw
|
||||
systemctl start ufw
|
||||
ufw allow 22/tcp
|
||||
ufw allow 80/tcp
|
||||
ufw allow 443/tcp
|
||||
|
||||
Reference in New Issue
Block a user