35 lines
687 B
Go
35 lines
687 B
Go
package captcha
|
|
|
|
import (
|
|
"image"
|
|
"justcaptcha/pkg/captcha"
|
|
"time"
|
|
)
|
|
|
|
var captchaDb captcha.CaptchaDB = captcha.CaptchaDB{
|
|
DB: make(map[captcha.ID]captcha.ICaptcha)}
|
|
|
|
func Init(expiry time.Duration) {
|
|
captchaDb.SetExpiry(expiry)
|
|
}
|
|
|
|
func New(data string, captcha captcha.ICaptcha) (captcha.ICaptcha, captcha.ID) {
|
|
return captchaDb.New(data, captcha)
|
|
}
|
|
|
|
func Image(id captcha.ID) (*image.Image, error) {
|
|
return captchaDb.Image(id)
|
|
}
|
|
|
|
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 GetExpiry() time.Duration {
|
|
return captchaDb.GetExpiry()
|
|
}
|