MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / checkIPLimit

Function checkIPLimit

core/utils/security/security.go:192–212  ·  view source on GitHub ↗
(c *gin.Context)

Source from the content-addressed store, hash-verified

190}
191
192func 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
214func checkSession(c *gin.Context) bool {
215 _, err := global.SESSION.Get(c)

Callers 2

HandleNotRouteFunction · 0.85
CheckSecurityFunction · 0.85

Calls 2

GetMethod · 0.95
WithByKeyMethod · 0.65

Tested by

no test coverage detected