mirror of https://github.com/gin-gonic/gin.git
More changes!
This commit is contained in:
parent
c3ecb91dbf
commit
3db1479acc
|
@ -13,9 +13,11 @@ import (
|
||||||
func rateLimit(c *gin.Context) {
|
func rateLimit(c *gin.Context) {
|
||||||
ip := c.ClientIP()
|
ip := c.ClientIP()
|
||||||
value := ips.Add(ip, 1)
|
value := ips.Add(ip, 1)
|
||||||
fmt.Printf("ip: %s, count: %f\n", ip, value)
|
if int(value)%50 == 0 {
|
||||||
if value >= 300 {
|
fmt.Printf("ip: %s, count: %d\n", ip, int(value))
|
||||||
if int(value)%300 == 0 {
|
}
|
||||||
|
if value >= 200 {
|
||||||
|
if int(value)%200 == 0 {
|
||||||
fmt.Println("ip blocked")
|
fmt.Println("ip blocked")
|
||||||
}
|
}
|
||||||
c.AbortWithStatus(503)
|
c.AbortWithStatus(503)
|
||||||
|
|
Loading…
Reference in New Issue