mirror of
https://github.com/acepanel/panel.git
synced 2026-02-04 10:17:17 +08:00
Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -65,6 +65,7 @@ func MustLogin(t *gotext.Locale, session *sessions.Manager, userToken biz.UserTo
|
||||
ip, _, _ := net.SplitHostPort(strings.TrimSpace(r.RemoteAddr))
|
||||
clientHash := fmt.Sprintf("%x", sha256.Sum256([]byte(ip)))
|
||||
if safeClientHash != clientHash || safeClientHash == "" {
|
||||
sess.Forget("user_id") // 清除 user_id,否则会来回跳转
|
||||
Abort(w, http.StatusUnauthorized, t.Get("client ip/ua changed, please login again"))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package service
|
||||
import (
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/go-rat/chix"
|
||||
|
||||
@@ -179,15 +178,11 @@ func (s *FirewallService) CreateIPRule(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// rich rule 下,address 不支持多个地址,需要单独添加
|
||||
addresses := strings.Split(req.Address, ",")
|
||||
for address := range slices.Values(addresses) {
|
||||
if err = s.firewall.RichRules(firewall.FireInfo{
|
||||
Family: req.Family, Address: address, Protocol: firewall.Protocol(req.Protocol), Strategy: firewall.Strategy(req.Strategy), Direction: firewall.Direction(req.Direction),
|
||||
}, firewall.OperationAdd); err != nil {
|
||||
Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
if err = s.firewall.RichRules(firewall.FireInfo{
|
||||
Family: req.Family, Address: req.Address, Protocol: firewall.Protocol(req.Protocol), Strategy: firewall.Strategy(req.Strategy), Direction: firewall.Direction(req.Direction),
|
||||
}, firewall.OperationAdd); err != nil {
|
||||
Error(w, http.StatusInternalServerError, "%v", err)
|
||||
return
|
||||
}
|
||||
|
||||
Success(w, nil)
|
||||
|
||||
Reference in New Issue
Block a user