MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / getTCPPorts

Method getTCPPorts

internal/firewalls/ddos_protection.go:447–463  ·  view source on GitHub ↗

获取规则中的端口号

(rules []*nftables.Rule)

Source from the content-addressed store, hash-verified

445
446// 获取规则中的端口号
447func (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// 检查端口是否一样
466func (this *DDoSProtectionManager) eqPorts(ports1 []int32, ports2 []int32) bool {

Callers 1

addTCPRulesMethod · 0.95

Calls 2

decodeUserDataMethod · 0.95
UserDataMethod · 0.80

Tested by

no test coverage detected