根据参数检查规则是否存在
(rules []*nftables.Rule, attrs []string)
| 421 | |
| 422 | // 根据参数检查规则是否存在 |
| 423 | func (this *DDoSProtectionManager) existsRule(rules []*nftables.Rule, attrs []string) (exists bool) { |
| 424 | if len(attrs) == 0 { |
| 425 | return false |
| 426 | } |
| 427 | for _, oldRule := range rules { |
| 428 | var pieces = this.decodeUserData(oldRule.UserData()) |
| 429 | if len(attrs) != len(pieces) { |
| 430 | continue |
| 431 | } |
| 432 | var isSame = true |
| 433 | for index, piece := range pieces { |
| 434 | if strings.TrimSpace(piece) != attrs[index] { |
| 435 | isSame = false |
| 436 | break |
| 437 | } |
| 438 | } |
| 439 | if isSame { |
| 440 | return true |
| 441 | } |
| 442 | } |
| 443 | return false |
| 444 | } |
| 445 | |
| 446 | // 获取规则中的端口号 |
| 447 | func (this *DDoSProtectionManager) getTCPPorts(rules []*nftables.Rule) []int32 { |
no test coverage detected