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

Method showOneClickForm

internal/waf/captcha_validator.go:398–511  ·  view source on GitHub ↗
(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter)

Source from the content-addressed store, hash-verified

396}
397
398func (this *CaptchaValidator) showOneClickForm(actionConfig *CaptchaAction, req requests.Request, writer http.ResponseWriter) {
399 var lang = actionConfig.Lang
400 if len(lang) == 0 {
401 var acceptLanguage = req.WAFRaw().Header.Get("Accept-Language")
402 if len(acceptLanguage) > 0 {
403 langIndex := strings.Index(acceptLanguage, ",")
404 if langIndex > 0 {
405 lang = acceptLanguage[:langIndex]
406 }
407 }
408 }
409 if len(lang) == 0 {
410 lang = "en-US"
411 }
412
413 var msgTitle string
414 var msgPrompt string
415 var msgRequestId string
416
417 switch lang {
418 case "zh-CN":
419 msgTitle = "身份验证"
420 msgPrompt = "我不是机器人"
421 msgRequestId = "请求ID"
422 case "zh-TW":
423 msgTitle = "身份驗證"
424 msgPrompt = "我不是機器人"
425 msgRequestId = "請求ID"
426 default:
427 msgTitle = "Verify Yourself"
428 msgPrompt = "I'm not a robot"
429 msgRequestId = "Request ID"
430 }
431
432 var msgCss = ""
433 var requestIdBox = `<address>` + msgRequestId + `: ` + req.Format("${requestId}") + `</address>`
434 var msgFooter = ""
435
436 // 默认设置
437 if actionConfig.OneClickUIIsOn {
438 if len(actionConfig.OneClickUIPrompt) > 0 {
439 msgPrompt = actionConfig.OneClickUIPrompt
440 }
441 if len(actionConfig.OneClickUITitle) > 0 {
442 msgTitle = actionConfig.OneClickUITitle
443 }
444 if len(actionConfig.OneClickUICss) > 0 {
445 msgCss = actionConfig.OneClickUICss
446 }
447 if !actionConfig.OneClickUIShowRequestId {
448 requestIdBox = ""
449 }
450 if len(actionConfig.OneClickUIFooter) > 0 {
451 msgFooter = actionConfig.OneClickUIFooter
452 }
453 }
454
455 var captchaId = stringutil.Md5(req.WAFRemoteIP() + "@" + stringutil.Rand(32))

Callers 1

showMethod · 0.95

Calls 12

NowFunction · 0.92
UnixMethod · 0.80
WAFRawMethod · 0.65
FormatMethod · 0.65
WAFRemoteIPMethod · 0.65
WriteMethod · 0.65
WriteHeaderMethod · 0.65
GetMethod · 0.45
StringMethod · 0.45
HeaderMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected