captcha

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMathGenerator

func NewMathGenerator(config frameCaptcha.MathConfig) frameCaptcha.Generator

NewMathGenerator 创建数学验证码生成器

func NewRedisRateLimiter

func NewRedisRateLimiter(client *redis.Client, config *frameCaptcha.Config) frameCaptcha.RateLimiter

NewRedisRateLimiter 创建 Redis 限流器

func NewRedisStore

func NewRedisStore(client *redis.Client) frameCaptcha.Store

NewRedisStore 创建 Redis 存储

func NewService

func NewService(
	store frameCaptcha.Store,
	generator frameCaptcha.Generator,
	rateLimiter frameCaptcha.RateLimiter,
	config *frameCaptcha.Config,
) frameCaptcha.Service

NewService 创建验证码服务

Types

type MathGenerator

type MathGenerator struct {
	// contains filtered or unexported fields
}

MathGenerator 数学验证码生成器

func (*MathGenerator) Generate

type RedisRateLimiter

type RedisRateLimiter struct {
	// contains filtered or unexported fields
}

RedisRateLimiter Redis 限流器

func (*RedisRateLimiter) AllowGenerate

func (r *RedisRateLimiter) AllowGenerate(ctx context.Context, identifier string) error

func (*RedisRateLimiter) AllowVerify

func (r *RedisRateLimiter) AllowVerify(ctx context.Context, identifier string) error

func (*RedisRateLimiter) RecordFailure

func (r *RedisRateLimiter) RecordFailure(ctx context.Context, identifier string) error

func (*RedisRateLimiter) Reset

func (r *RedisRateLimiter) Reset(ctx context.Context, identifier string) error

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore Redis 存储实现

func (*RedisStore) Delete

func (s *RedisStore) Delete(ctx context.Context, id string) error

func (*RedisStore) Exists

func (s *RedisStore) Exists(ctx context.Context, id string) (bool, error)

func (*RedisStore) Get

func (s *RedisStore) Get(ctx context.Context, id string) (string, error)

func (*RedisStore) Save

func (s *RedisStore) Save(ctx context.Context, id string, answer string, ttl time.Duration) error

Jump to

Keyboard shortcuts

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