获取规则中的端口号
(rules []*nftables.Rule)
| 445 | |
| 446 | // 获取规则中的端口号 |
| 447 | func (this *DDoSProtectionManager) getTCPPorts(rules []*nftables.Rule) []int32 { |
| 448 | var ports = []int32{} |
| 449 | for _, rule := range rules { |
| 450 | var pieces = this.decodeUserData(rule.UserData()) |
| 451 | if len(pieces) != 4 { |
| 452 | continue |
| 453 | } |
| 454 | if pieces[0] != "tcp" { |
| 455 | continue |
| 456 | } |
| 457 | var port = types.Int32(pieces[1]) |
| 458 | if port > 0 && !lists.ContainsInt32(ports, port) { |
| 459 | ports = append(ports, port) |
| 460 | } |
| 461 | } |
| 462 | return ports |
| 463 | } |
| 464 | |
| 465 | // 检查端口是否一样 |
| 466 | func (this *DDoSProtectionManager) eqPorts(ports1 []int32, ports2 []int32) bool { |
no test coverage detected