Trying fmt
This commit is contained in:
parent
b0aa2e407c
commit
c3ecb91dbf
@ -1,9 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -13,10 +13,10 @@ 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)
|
||||||
log.Printf("ip: %s, count: %f\n", ip, value)
|
fmt.Printf("ip: %s, count: %f\n", ip, value)
|
||||||
if value > 300 {
|
if value >= 300 {
|
||||||
if int(value)%200 == 0 {
|
if int(value)%300 == 0 {
|
||||||
log.Println("ip blocked")
|
fmt.Println("ip blocked")
|
||||||
}
|
}
|
||||||
c.AbortWithStatus(503)
|
c.AbortWithStatus(503)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user