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

Method Init

internal/waf/waf.go:75–127  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75func (this *WAF) Init() (resultErrors []error) {
76 // checkpoint
77 this.checkpointsMap = map[string]checkpoints.CheckpointInterface{}
78 for _, def := range checkpoints.AllCheckpoints {
79 instance := reflect.New(reflect.Indirect(reflect.ValueOf(def.Instance)).Type()).Interface().(checkpoints.CheckpointInterface)
80 instance.Init()
81 instance.SetPriority(def.Priority)
82 this.checkpointsMap[def.Prefix] = instance
83 }
84
85 // action map
86 this.actionMap = map[int64]ActionInterface{}
87
88 // rules
89 this.hasInboundRules = len(this.Inbound) > 0
90 this.hasOutboundRules = len(this.Outbound) > 0
91
92 if this.hasInboundRules {
93 for _, group := range this.Inbound {
94 // finder
95 for _, set := range group.RuleSets {
96 for _, rule := range set.Rules {
97 rule.SetCheckpointFinder(this.FindCheckpointInstance)
98 }
99 }
100
101 err := group.Init(this)
102 if err != nil {
103 // 这里我们不阻止其他规则正常加入
104 resultErrors = append(resultErrors, fmt.Errorf("init group '%d' failed: %w", group.Id, err))
105 }
106 }
107 }
108
109 if this.hasOutboundRules {
110 for _, group := range this.Outbound {
111 // finder
112 for _, set := range group.RuleSets {
113 for _, rule := range set.Rules {
114 rule.SetCheckpointFinder(this.FindCheckpointInstance)
115 }
116 }
117
118 err := group.Init(this)
119 if err != nil {
120 // 这里我们不阻止其他规则正常加入
121 resultErrors = append(resultErrors, err)
122 }
123 }
124 }
125
126 return nil
127}
128
129func (this *WAF) AddRuleGroup(ruleGroup *RuleGroup) {
130 if ruleGroup.IsInbound {

Callers

nothing calls this directly

Calls 5

SetCheckpointFinderMethod · 0.80
ErrorfMethod · 0.80
TypeMethod · 0.65
InitMethod · 0.65
SetPriorityMethod · 0.65

Tested by

no test coverage detected