fix: harden rule and forwarding edge cases
This commit is contained in:
@@ -72,7 +72,12 @@ func postAlertPayload(cfg *config.AlertForwardConf, path string, payload []byte)
|
||||
if cfg.InternalKey != "" {
|
||||
req.Header.Set("X-Internal-Key", cfg.InternalKey)
|
||||
}
|
||||
client := &http.Client{Timeout: 10 * time.Second}
|
||||
client := &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
|
||||
return http.ErrUseLastResponse
|
||||
},
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return fmt.Errorf("发送 Alert 转发请求失败:%w", err)
|
||||
|
||||
@@ -665,7 +665,7 @@ func trapRuleMatches(rule *models.TrapRule, trapOID, varbindFP string) bool {
|
||||
if hasOID && !strings.HasPrefix(normOID(trapOID), normOID(rule.OIDPrefix)) {
|
||||
return false
|
||||
}
|
||||
if rule.VarbindMatchRegex != "" {
|
||||
if hasRE {
|
||||
re, err := regexp.Compile(rule.VarbindMatchRegex)
|
||||
if err != nil {
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user