feat: CAPTCHA

This commit is contained in:
Roi Feng
2025-02-15 02:40:20 -05:00
parent 3182a8f753
commit 07536a00d4
14 changed files with 471 additions and 82 deletions

View File

@ -10,25 +10,32 @@ const (
// Decision saves the result of the decision
type Decision struct {
HTTPCode string
State checkState
JumpIndex int
HTTPCode []byte
State checkState
ResponseData []byte
JumpIndex int
}
func NewDecision() *Decision {
return &Decision{HTTPCode: "200", State: Continue, JumpIndex: -1}
return &Decision{HTTPCode: []byte("200"), State: Continue, ResponseData: nil, JumpIndex: -1}
}
func (d *Decision) Set(state checkState) {
d.State = state
}
func (d *Decision) SetCode(state checkState, httpCode string) {
func (d *Decision) SetCode(state checkState, httpCode []byte) {
d.State = state
d.HTTPCode = httpCode
}
func (d *Decision) SetJump(state checkState, httpCode string, jumpIndex int) {
func (d *Decision) SetResponse(state checkState, httpCode []byte, responseData []byte) {
d.State = state
d.HTTPCode = httpCode
d.ResponseData = responseData
}
func (d *Decision) SetJump(state checkState, httpCode []byte, jumpIndex int) {
d.State = state
d.HTTPCode = httpCode
d.JumpIndex = jumpIndex