39 lines
748 B
Go
39 lines
748 B
Go
package captcha
|
|
|
|
import (
|
|
"image"
|
|
"justcaptcha/pkg/captcha"
|
|
"time"
|
|
)
|
|
|
|
var captchaDb captcha.CaptchaDB
|
|
|
|
func Init(expiry time.Duration) {
|
|
captchaDb = captcha.NewInMemoryCaptchaDB(expiry)
|
|
}
|
|
|
|
func New(data string) (captcha.Captcha, captcha.ID) {
|
|
dc := NewDwellingCaptcha(captchaDb.GetExpiry())
|
|
return captchaDb.New(data, dc)
|
|
}
|
|
|
|
func Image(id captcha.ID, style string) (*image.Image, error) {
|
|
return captchaDb.Image(id, style)
|
|
}
|
|
|
|
func Solve(id captcha.ID, answer captcha.Answer) (bool, error) {
|
|
return captchaDb.Solve(id, answer)
|
|
}
|
|
|
|
func IsSolved(id captcha.ID) (bool, error) {
|
|
return captchaDb.IsSolved(id)
|
|
}
|
|
|
|
func Remove(id captcha.ID) error {
|
|
return captchaDb.Remove(id)
|
|
}
|
|
|
|
func GetExpiry() time.Duration {
|
|
return captchaDb.GetExpiry()
|
|
}
|