1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00
cowyo/ratelimiter.go

26 lines
332 B
Go
Raw Normal View History

package main
2016-03-29 03:21:06 +03:00
import "time"
var bannedIPs []string
func init() {
go clearBannedIPs()
}
func clearBannedIPs() {
for {
bannedIPs = []string{}
time.Sleep(3 * time.Minute)
}
}
func isIPBanned(ip string) bool {
if stringInSlice(ip, bannedIPs) {
return true
} else {
2016-03-29 03:21:06 +03:00
bannedIPs = append(bannedIPs, ip)
return false
}
}