github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/README.md (about) 1 # WAF 2 A basic WAF for TeaWeb. 3 4 ## Config Constructions 5 ~~~ 6 WAF 7 Inbound 8 Rule Groups 9 Rule Sets 10 Rules 11 Checkpoint Param <Operator> Value 12 Outbound 13 Rule Groups 14 ... 15 ~~~ 16 17 ## Apply WAF 18 ~~~ 19 Request --> WAF --> Backends 20 / 21 Response <-- WAF <---- 22 ~~~ 23 24 ## Coding 25 ~~~go 26 waf := teawaf.NewWAF() 27 28 // add rule groups here 29 30 err := waf.Init() 31 if err != nil { 32 return 33 } 34 waf.Start() 35 36 // match http request 37 // (req *http.Request, responseWriter http.ResponseWriter) 38 goNext, ruleSet, _ := waf.MatchRequest(req, responseWriter) 39 if ruleSet != nil { 40 log.Println("meet rule set:", ruleSet.Name, "action:", ruleSet.Action) 41 } 42 if !goNext { 43 return 44 } 45 46 // stop the waf 47 // waf.Stop() 48 ~~~