ipfilter

package
v0.0.0-...-65008d1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: AGPL-3.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LocalIPs = []string{`127.0.0.1`, `::1`}

Functions

func RedisAddr

func RedisAddr(addr string) func(*redis.Options)

func RedisDB

func RedisDB(db int) func(*redis.Options)

func RedisDialTimeout

func RedisDialTimeout(timeout time.Duration) func(*redis.Options)

func RedisIdleCheckFrequency

func RedisIdleCheckFrequency(timeout time.Duration) func(*redis.Options)

func RedisIdleTimeout

func RedisIdleTimeout(timeout time.Duration) func(*redis.Options)

func RedisMaxRetries

func RedisMaxRetries(maxRetries int) func(*redis.Options)

func RedisNetwork

func RedisNetwork(network string) func(*redis.Options)

func RedisPassword

func RedisPassword(password string) func(*redis.Options)

func RedisPoolSize

func RedisPoolSize(poolSize int) func(*redis.Options)

func RedisPoolTimeout

func RedisPoolTimeout(timeout time.Duration) func(*redis.Options)

func RedisReadOnly

func RedisReadOnly(readOnly bool) func(*redis.Options)

func RedisReadTimeout

func RedisReadTimeout(timeout time.Duration) func(*redis.Options)

func RedisTLSConfig

func RedisTLSConfig(config *tls.Config) func(*redis.Options)

func RedisWriteTimeout

func RedisWriteTimeout(timeout time.Duration) func(*redis.Options)

Types

type Options

type Options struct {
	On               bool     //是否启用
	PassToken        string   //通行口令
	BlockByDefault   bool     //默认封锁
	AllowedIPs       []string //白名单IP
	BlockedIPs       []string //黑名单IP
	AllowedCountries []string //白名单国家
	BlockedCountries []string //黑名单国家
	TrustProxy       bool     // 是否检查代理IP
}

func NewOptions

func NewOptions() *Options

func (*Options) Apply

func (o *Options) Apply(opts *ipfilter.Options) *Options

func (*Options) FromStore

func (o *Options) FromStore(r echo.H) *Options

type RateLimiterConfig

type RateLimiterConfig struct {
	On bool
	// The max count in duration for no policy, default is 100.
	Max int

	// Count duration for no policy, default is 1 Minute (60s).
	Duration int64 //seconds
	//key prefix, default is "LIMIT:".
	Prefix string

	//If request gets a  internal limiter error, just skip the limiter and let it go to next middleware
	SkipInternalError bool

	RedisAddr     string
	RedisPassword string
	RedisDB       int
	DBAccountID   uint
}

func NewRateLimiterConfig

func NewRateLimiterConfig() *RateLimiterConfig

func (*RateLimiterConfig) Apply

func (*RateLimiterConfig) FromStore

func (o *RateLimiterConfig) FromStore(r echo.H) *RateLimiterConfig

type RedisClient

type RedisClient struct {
	*redis.Client
}

RedisClient Implements RedisClient for redis.Client

func NewRedisClient

func NewRedisClient(settings ...func(*redis.Options)) *RedisClient

func (*RedisClient) DeleteKey

func (c *RedisClient) DeleteKey(key string) error

func (*RedisClient) EvalulateSha

func (c *RedisClient) EvalulateSha(sha1 string, keys []string, args ...interface{}) (interface{}, error)

func (*RedisClient) LuaScriptLoad

func (c *RedisClient) LuaScriptLoad(script string) (string, error)

Jump to

Keyboard shortcuts

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