mirror of
https://github.com/lejianwen/rustdesk-api.git
synced 2025-11-29 08:33:21 +00:00
23 lines
492 B
Go
23 lines
492 B
Go
package middleware
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/lejianwen/rustdesk-api/v2/global"
|
|
"github.com/lejianwen/rustdesk-api/v2/http/response"
|
|
"net/http"
|
|
)
|
|
|
|
func Limiter() gin.HandlerFunc {
|
|
return func(c *gin.Context) {
|
|
loginLimiter := global.LoginLimiter
|
|
clientIp := c.ClientIP()
|
|
banned, _ := loginLimiter.CheckSecurityStatus(clientIp)
|
|
if banned {
|
|
response.Fail(c, http.StatusLocked, response.TranslateMsg(c, "Banned"))
|
|
c.Abort()
|
|
return
|
|
}
|
|
c.Next()
|
|
}
|
|
}
|