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

feat: 优化注销时session处理

This commit is contained in:
2025-07-07 16:49:53 +08:00
parent 11e206b41a
commit 05721dbb47
6 changed files with 31 additions and 28 deletions

View File

@@ -19,6 +19,7 @@ import (
"github.com/tnb-labs/panel/pkg/firewall"
"github.com/tnb-labs/panel/pkg/io"
"github.com/tnb-labs/panel/pkg/os"
"github.com/tnb-labs/panel/pkg/systemctl"
"github.com/tnb-labs/panel/pkg/types"
)
@@ -310,6 +311,20 @@ func (r *settingRepo) UpdatePanel(req *request.SettingPanel) (bool, error) {
if os.TCPPortInUse(req.Port) {
return false, errors.New(r.t.Get("port is already in use"))
}
// 放行端口
if ok, _ := systemctl.IsEnabled("firewalld"); ok {
fw := firewall.NewFirewall()
err = fw.Port(firewall.FireInfo{
Type: firewall.TypeNormal,
PortStart: config.HTTP.Port,
PortEnd: config.HTTP.Port,
Direction: firewall.DirectionIn,
Strategy: firewall.StrategyAccept,
}, firewall.OperationAdd)
if err != nil {
return false, err
}
}
}
config.App.Locale = req.Locale
@@ -321,19 +336,6 @@ func (r *settingRepo) UpdatePanel(req *request.SettingPanel) (bool, error) {
config.HTTP.BindUA = req.BindUA
config.Session.Lifetime = req.Lifetime
// 放行端口
fw := firewall.NewFirewall()
err = fw.Port(firewall.FireInfo{
Type: firewall.TypeNormal,
PortStart: config.HTTP.Port,
PortEnd: config.HTTP.Port,
Direction: firewall.DirectionIn,
Strategy: firewall.StrategyAccept,
}, firewall.OperationAdd)
if err != nil {
return false, err
}
encoded, err := yaml.Marshal(config)
if err != nil {
return false, err