captcha

package
v0.0.0-...-ba0f816 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2022 License: MIT, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextNameImage = ContextName("image")
View Source
var ContextNameSign = ContextName("sign")
View Source
var ContextNameSubmited = ContextName("submited")
View Source
var ContextNameTimestamp = ContextName("timestamp")
View Source
var ContextNameToken = ContextName("token")
View Source
var ContextNameWanted = ContextName("wanted")
View Source
var DefaultScene = Scene("")
View Source
var ErrByteNotAvaliable = errors.New("captcha: byte not avaliable")

Functions

This section is empty.

Types

type Captcha

type Captcha struct {
	Driver
}

func New

func New() *Captcha

func (*Captcha) DoCaptcha

func (c *Captcha) DoCaptcha(ctx Context) (bool, error)

type Collection

type Collection map[ContextName]ContextData

func NewCollection

func NewCollection() *Collection

func (*Collection) GetCaptchaData

func (c *Collection) GetCaptchaData(n ContextName) (ContextData, error)

func (*Collection) SetCaptchaData

func (c *Collection) SetCaptchaData(n ContextName, v ContextData) error

type Context

type Context interface {
	SetCaptchaData(ContextName, ContextData) error
	GetCaptchaData(ContextName) (ContextData, error)
	CaptchaScene() (Scene, error)
	CaptchaTrusted() (bool, error)
}

type ContextData

type ContextData []byte

func (ContextData) Equal

func (d ContextData) Equal(data ContextData) bool

type ContextName

type ContextName string

type ContextValue

type ContextValue struct {
	Name ContextName
	Data ContextData
}

type Driver

type Driver interface {
	DoCaptcha(Context) (bool, error)
	Challenge(Context) error
}

type PlainContext

type PlainContext struct {
	Scene   Scene
	Trusted bool
	*Collection
}

func NewPlainContext

func NewPlainContext() *PlainContext

func (*PlainContext) CaptchaScene

func (c *PlainContext) CaptchaScene() (Scene, error)

func (*PlainContext) CaptchaTrusted

func (c *PlainContext) CaptchaTrusted() (bool, error)

type Scene

type Scene string

type Wanted

type Wanted struct {
	Min          int
	Max          int
	OptionalByte []byte
}

func NewWanted

func NewWanted() *Wanted

func (*Wanted) Challenge

func (w *Wanted) Challenge(c Context) error

func (*Wanted) DoCaptcha

func (w *Wanted) DoCaptcha(c Context) (bool, error)

func (*Wanted) NewWantedBytes

func (w *Wanted) NewWantedBytes() []byte

func (*Wanted) ToIndexBytes

func (w *Wanted) ToIndexBytes(data []byte) ([]byte, error)

Directories

Path Synopsis
drivers

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL