Documentation
¶
Index ¶
Constants ¶
View Source
const DefaultExpiredScanInterval = 60 * time.Second
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseCaptcha ¶
type BaseCaptcha struct {
// contains filtered or unexported fields
}
BaseCaptcha is a base implementation of a CAPTCHA.
All derivatives that embed this struct only need to implement an Image() method.
func NewBaseCaptcha ¶
func NewBaseCaptcha(expiry time.Duration) *BaseCaptcha
func (*BaseCaptcha) Answer ¶
func (c *BaseCaptcha) Answer() Answer
func (*BaseCaptcha) Expiry ¶
func (c *BaseCaptcha) Expiry() time.Time
func (*BaseCaptcha) IsSolved ¶
func (c *BaseCaptcha) IsSolved() bool
func (*BaseCaptcha) Solve ¶
func (c *BaseCaptcha) Solve(answer Answer) bool
type Captcha ¶
type Captcha interface {
// Image generates an image of a CAPTCHA according to a passed style
// and returns a pointer to it.
Image(style string) *image.Image
// Answer returns a pregenerated answer.
Answer() Answer
// Solve compares a stored answer with a passed one.
Solve(answer Answer) bool
// IsSolved returns if a CAPTCHA is solved or not.
IsSolved() bool
// Expiry returns a date after what CAPTCHA will expire.
Expiry() time.Time
}
Captcha interface that should be implemented by a CAPTCHA.
type DB ¶
type DB interface {
New(data string, captcha Captcha) (Captcha, ID)
GetExpiry() time.Duration
SetExpiry(expiry time.Duration)
Image(id ID, style string) *image.Image
Solve(id ID, answer Answer) bool
IsSolved(id ID) bool
Remove(id ID)
}
DB interface with all necessary methods.
Click to show internal directories.
Click to hide internal directories.