Documentation ¶
Index ¶
Constants ¶
View Source
const ( ActionTimeCachePrefix = "action-time:" ActionCountCachePrefix = "action-count:" AlwaysModeVerifiedCachePrefix = "captcha-am-verified:" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
操作次数限制器(根据 IP)
关键函数:
IsPass(ip) 请求启用了 Limiter 的页面时, 判断操作次数是否过限,若超过限制则响应 need_captcha
MarkVerifyPassed 若验证码正确,则放行操作一次(最大操作数 -1)
MarkVerifyFailed 若验证码错误,则操作次数 +1,记录最后操作时间
Log(ip) 当用户发表评论后,调用 Log 操作次数 +1,记录最后操作时间
func NewLimiter ¶
func NewLimiter(conf *LimiterConf) *Limiter
type LimiterConf ¶
Click to show internal directories.
Click to hide internal directories.