MCPcopy Index your code
hub / github.com/TruthHun/BookStack / NewRegLimit

Function NewRegLimit

models/reg_limit.go:21–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21func NewRegLimit() (rl *RegLimit) {
22 rl = &RegLimit{}
23 var options []Option
24 orm.NewOrm().QueryTable(NewOption()).Filter("option_name__in", "REAL_IP_FIELD", "HOUR_REG_NUM", "DAILY_REG_NUM").All(&options, "option_name", "option_value")
25 for _, item := range options {
26 switch item.OptionName {
27 case "REAL_IP_FIELD":
28 rl.RealIPField = item.OptionValue
29 case "HOUR_REG_NUM":
30 rl.HourRegNum, _ = strconv.Atoi(item.OptionValue)
31 case "DAILY_REG_NUM":
32 rl.DailyRegNum, _ = strconv.Atoi(item.OptionValue)
33 }
34 }
35 return rl
36}
37
38func (rl *RegLimit) CheckIPIsAllowed(ip string) (allowHour, allowDaily bool) {
39 now := time.Now()

Callers 1

RegisterMethod · 0.92

Calls 2

NewOptionFunction · 0.85
AllMethod · 0.45

Tested by

no test coverage detected