Documentation ¶
Index ¶
- Constants
- func MakeFileName(id string) (fileName string)
- func MakeRecordFilePath(imagesFolder string, id string) (path string)
- type CaptchaManager
- func (cm *CaptchaManager) CheckCaptcha(req *models.CheckCaptchaRequest) (resp *models.CheckCaptchaResponse, err error)
- func (cm *CaptchaManager) ClearJunk() (err error)
- func (cm *CaptchaManager) CreateCaptcha() (resp *models.CreateCaptchaResponse, err error)
- func (cm *CaptchaManager) GetListenDsn() (dsn string)
- func (cm *CaptchaManager) Start() (err error)
- func (cm *CaptchaManager) Stop() (err error)
- type Registry
- func (r *Registry) AddRecord(id string, answer uint) (err error)
- func (r *Registry) CheckCaptcha(id string, value uint) (ok bool, err error)
- func (r *Registry) ClearJunk() (err error)
- func (r *Registry) GetImageFile(id string) (data []byte, err error)
- func (r *Registry) GetSize() (size int)
- func (r *Registry) IsIdRegistered(id string) (isRegistered bool)
- type RegistryRecord
Constants ¶
View Source
const ( ImageFileExt = "png" ImageFormat = "PNG" ImageMimeType = "image/png" QueryKeyId = "id" RUIDPrefix = "RCS-" )
View Source
const ( MsgCleaningImagesFolder = "Cleaning the images folder ... " MsgDone = "Done" MsgCaptchaManagerStart = "Captcha manager has started" MsgCaptchaManagerStop = "Captcha manager has been stopped" )
View Source
const ( ErrFDuplicateId = "duplicate id: %v" ErrFAbsentId = "absent id: %v" ErrFileIsNotFound = "file is not found" )
Variables ¶
This section is empty.
Functions ¶
func MakeFileName ¶
func MakeRecordFilePath ¶
Types ¶
type CaptchaManager ¶
type CaptchaManager struct {
// contains filtered or unexported fields
}
CaptchaManager is a captcha manager.
func NewCaptchaManager ¶
func NewCaptchaManager(s *models.CaptchaManagerSettings) (cm *CaptchaManager, err error)
func (*CaptchaManager) CheckCaptcha ¶
func (cm *CaptchaManager) CheckCaptcha(req *models.CheckCaptchaRequest) (resp *models.CheckCaptchaResponse, err error)
func (*CaptchaManager) ClearJunk ¶
func (cm *CaptchaManager) ClearJunk() (err error)
func (*CaptchaManager) CreateCaptcha ¶
func (cm *CaptchaManager) CreateCaptcha() (resp *models.CreateCaptchaResponse, err error)
func (*CaptchaManager) GetListenDsn ¶
func (cm *CaptchaManager) GetListenDsn() (dsn string)
func (*CaptchaManager) Start ¶ added in v0.8.0
func (cm *CaptchaManager) Start() (err error)
func (*CaptchaManager) Stop ¶
func (cm *CaptchaManager) Stop() (err error)
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func (*Registry) CheckCaptcha ¶
func (*Registry) IsIdRegistered ¶
type RegistryRecord ¶
type RegistryRecord struct { Id string Answer uint TTL float64 // TTL is set in seconds. ToC time.Time // Time of creation. }
RegistryRecord stores an answer and timing information.
func NewRegistryRecord ¶
func NewRegistryRecord(id string, answer uint, ttl float64) *RegistryRecord
func (*RegistryRecord) IsExpired ¶
func (rr *RegistryRecord) IsExpired() bool
Click to show internal directories.
Click to hide internal directories.