Skip to content

Commit

Permalink
Message for attackers
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 14, 2015
1 parent 3db1479 commit e33ea85
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions examples/realtime-advanced/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,18 @@ import (
)

func rateLimit(c *gin.Context) {

ip := c.ClientIP()
value := ips.Add(ip, 1)
if int(value)%50 == 0 {
fmt.Printf("ip: %s, count: %d\n", ip, int(value))
value := int(ips.Add(ip, 1))
if value%10 == 0 {
fmt.Printf("ip: %s, count: %d\n", ip, value)
}
if value >= 200 {
if int(value)%200 == 0 {
if value >= 100 {
if value%100 == 0 {
fmt.Println("ip blocked")
}
c.AbortWithStatus(503)
c.Abort()
c.String(503, "you were automatically banned :)")
}
}

Expand Down

0 comments on commit e33ea85

Please sign in to comment.