captcha

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Captcha

type Captcha struct {
	*base64Captcha.Captcha
}

Captcha Package github.com/mojocn/base64Captcha

func (*Captcha) WithLogger

func (captcha *Captcha) WithLogger(logger ILogger) *Captcha

WithLogger Set up the logger required by this package

type DefaultLogger

type DefaultLogger struct {
}

DefaultLogger The default logger implementation

func NewDefaultLogger

func NewDefaultLogger() *DefaultLogger

NewDefaultLogger default logger

func (DefaultLogger) Error

func (d DefaultLogger) Error(args ...interface{})

type DriverConfig

type DriverConfig struct {
	CaptchaType string `mapstructure:"captcha_type"`
	Length      int    `mapstructure:"length"`
	Height      int    `mapstructure:"height"`
	Width       int    `mapstructure:"width"`
	NoiseCount  int    `mapstructure:"noise_count"`

	//string
	ShowLineOptions int         `mapstructure:"show_line_options"` // 2 or 4 or 8
	Source          string      `mapstructure:"source"`
	BackgroundColor *color.RGBA `mapstructure:"background"`
	Fonts           []string    `mapstructure:"fonts"`

	// audio
	Language string `mapstructure:"language"`

	// digit
	MaxSkew  float64 `mapstructure:"max_skew"`
	DotCount int     `mapstructure:"dot_count"`
}

DriverConfig Configuration parameters of the captcha

func (DriverConfig) NewDriver

func (config DriverConfig) NewDriver() base64Captcha.Driver

NewDriver generate a base64Captcha.Driver instance according to the configuration

type ILogger

type ILogger interface {
	Error(args ...interface{})
}

ILogger Log interface required by this package

type Loader

type Loader struct {
	Driver DriverConfig `mapstructure:"driver"`
	Store  StoreConfig  `mapstructure:"store"`
	// contains filtered or unexported fields
}

Loader Loader, this will be the first structure that should be derived from this package

func NewCaptcha

func NewCaptcha() *Loader

NewCaptcha return Loader pointer

func (*Loader) Instance

func (loader *Loader) Instance() *Captcha

Instance Get the verification code generation example, do not save this return value as a global variable

func (*Loader) OnChange

func (loader *Loader) OnChange(viper *viper.Viper)

OnChange Implemented the IConfig interface of the configurator package, finally register to configurator, will actively trigger this method when the configuration changes

type RedisStore

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

RedisStore Use redis to store the verification code content

func (*RedisStore) Get

func (s *RedisStore) Get(id string, clear bool) string

Get store driver method

func (*RedisStore) Set

func (s *RedisStore) Set(id string, value string)

Set store driver method

func (*RedisStore) SetLogger

func (s *RedisStore) SetLogger(logger ILogger)

SetLogger set logger

func (*RedisStore) Verify

func (s *RedisStore) Verify(id, answer string, clear bool) bool

Verify Verify that the verification code is correct

type StoreConfig

type StoreConfig struct {
	RedisType string `mapstructure:"redis_type"`

	Network  string `mapstructure:"network"`
	Addr     string `mapstructure:"addr"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`

	Addresses          []string `mapstructure:"addresses"`
	Username           string   `mapstructure:"username"`
	SentinelPassword   string   `mapstructure:"sentinel_password"`
	MaxRetries         int      `mapstructure:"max_retries"`
	MinRetryBackoff    string   `mapstructure:"min_retry_backoff"`
	MaxRetryBackoff    string   `mapstructure:"max_retry_backoff"`
	DialTimeout        string   `mapstructure:"dial_timeout"`
	ReadTimeout        string   `mapstructure:"read_timeout"`
	WriteTimeout       string   `mapstructure:"write_timeout"`
	PoolSize           int      `mapstructure:"pool_size"`
	MinIdleConns       int      `mapstructure:"min_idle_conns"`
	MaxConnAge         string   `mapstructure:"max_conn_age"`
	PoolTimeout        string   `mapstructure:"pool_timeout"`
	IdleTimeout        string   `mapstructure:"idle_timeout"`
	IdleCheckFrequency string   `mapstructure:"idle_check_frequency"`
	MaxRedirects       int      `mapstructure:"max_redirects"`
	ReadOnly           bool     `mapstructure:"read_only"`
	RouteByLatency     bool     `mapstructure:"route_by_latency"`
	RouteRandomly      bool     `mapstructure:"route_randomly"`
	SlaveOnly          bool     `mapstructure:"slave_only"`
	Randomly           bool     `mapstructure:"randomly"`
	MasterName         string   `mapstructure:"master_name"`

	NewClient    func(opt *redis.Options) *redis.Client
	TLSConfig    *tls.Config
	Dialer       func(ctx context.Context, network, addr string) (net.Conn, error)
	OnConnect    func(ctx context.Context, cn *redis.Conn) error
	Limiter      redis.Limiter
	ClusterSlots func(ctx context.Context) ([]redis.ClusterSlot, error)
}

StoreConfig redis config

func (StoreConfig) NewStore

func (config StoreConfig) NewStore() *RedisStore

NewStore get the specified redis store according to the configuration information

Jump to

Keyboard shortcuts

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