(c *gin.Context)
| 190 | } |
| 191 | |
| 192 | func checkIPLimit(c *gin.Context) bool { |
| 193 | settingRepo := repo.NewISettingRepo() |
| 194 | status, _ := settingRepo.Get(repo.WithByKey("AllowIPs")) |
| 195 | if len(status.Value) == 0 { |
| 196 | return true |
| 197 | } |
| 198 | clientIP := common.GetRealClientIP(c) |
| 199 | if common.IsPrivateIP(clientIP) { |
| 200 | return true |
| 201 | } |
| 202 | |
| 203 | for _, ip := range strings.Split(status.Value, ",") { |
| 204 | if len(ip) == 0 { |
| 205 | continue |
| 206 | } |
| 207 | if ip == clientIP || (strings.Contains(ip, "/") && common.CheckIpInCidr(ip, clientIP)) { |
| 208 | return true |
| 209 | } |
| 210 | } |
| 211 | return false |
| 212 | } |
| 213 | |
| 214 | func checkSession(c *gin.Context) bool { |
| 215 | _, err := global.SESSION.Get(c) |
no test coverage detected