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

Method Run

internal/waf/captcha_validator.go:41–172  ·  view source on GitHub ↗
(req requests.Request, writer http.ResponseWriter, defaultCaptchaType firewallconfigs.ServerCaptchaType)

Source from the content-addressed store, hash-verified

39}
40
41func (this *CaptchaValidator) Run(req requests.Request, writer http.ResponseWriter, defaultCaptchaType firewallconfigs.ServerCaptchaType) {
42 var realURL string
43 var urlObj = req.WAFRaw().URL
44 if urlObj != nil {
45 realURL = urlObj.Query().Get("from")
46 }
47
48 var info = req.WAFRaw().URL.Query().Get("info")
49 if len(info) == 0 {
50 if len(realURL) > 0 {
51 req.ProcessResponseHeaders(writer.Header(), http.StatusTemporaryRedirect)
52 http.Redirect(writer, req.WAFRaw(), realURL, http.StatusTemporaryRedirect)
53 } else {
54 req.ProcessResponseHeaders(writer.Header(), http.StatusBadRequest)
55 writer.WriteHeader(http.StatusBadRequest)
56 _, _ = writer.Write([]byte("invalid request (001)"))
57 }
58 return
59 }
60
61 var success bool
62 var actionId int64
63 var setId int64
64 var originURL string
65 var policyId int64
66 var groupId int64
67 var useLocalFirewall bool
68 var timestamp int64
69
70 var infoArg = &InfoArg{}
71 decodeErr := infoArg.Decode(info)
72 if decodeErr == nil && infoArg.IsValid() {
73 success = true
74
75 actionId = infoArg.ActionId
76 setId = infoArg.SetId
77 originURL = infoArg.URL
78 policyId = infoArg.PolicyId
79 groupId = infoArg.GroupId
80 useLocalFirewall = infoArg.UseLocalFirewall
81 timestamp = infoArg.Timestamp
82 } else {
83 // 兼容老版本
84 m, decodeMapErr := utils.SimpleDecryptMap(info)
85 if decodeMapErr == nil {
86 success = true
87
88 actionId = m.GetInt64("actionId")
89 setId = m.GetInt64("setId")
90 originURL = m.GetString("url")
91 policyId = m.GetInt64("policyId")
92 groupId = m.GetInt64("groupId")
93 useLocalFirewall = m.GetBool("useLocalFirewall")
94 timestamp = m.GetInt64("timestamp")
95 }
96 }
97
98 if !success {

Callers

nothing calls this directly

Calls 15

validateOneClickFormMethod · 0.95
validateSlideFormMethod · 0.95
validateGeeTestFormMethod · 0.95
showImageMethod · 0.95
showMethod · 0.95
NowFunction · 0.92
CaptchaIncreaseFailsFunction · 0.85
RedirectMethod · 0.80
IsValidMethod · 0.80
UnixMethod · 0.80
FindWAFMethod · 0.80

Tested by

no test coverage detected