srv_limit

package
v0.0.0-...-bae3b6f Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SecLimitMgrVars = &SecLimitMgr{
	UserLimitMap: make(map[int]*Limit),
	IpLimitMap:   make(map[string]*Limit),
}

Functions

func AntiSpam

func AntiSpam(req *model.SecRequest) (err error)

防作弊

Types

type Limit

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

type MinLimit

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

分钟限制

func (*MinLimit) Check

func (p *MinLimit) Check(nowTime int64) int

检查用户访问的次数

func (*MinLimit) Count

func (p *MinLimit) Count(nowTime int64) (curCount int)

在1分钟之内访问的次数

type SecLimit

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

秒限制

func (*SecLimit) Check

func (p *SecLimit) Check(nowTime int64) int

检查用户访问的次数

func (*SecLimit) Count

func (p *SecLimit) Count(nowTime int64) (curCount int)

一秒内访问的次数

type SecLimitMgr

type SecLimitMgr struct {
	UserLimitMap map[int]*Limit
	IpLimitMap   map[string]*Limit
	// contains filtered or unexported fields
}

限制管理

type TimeLimit

type TimeLimit interface {
	Count(nowTIme int64) (curCount int)
	Check(nowTIme int64) int
}

Jump to

Keyboard shortcuts

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