19 lines
354 B
Go
19 lines
354 B
Go
package ipblacklist
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"videoweb/pub/common/ipaddr"
|
|
"videoweb/web/service/srv_ipblack"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func IpBlackListMiddleware(ctx *gin.Context) {
|
|
ip := ipaddr.ResolveClientIP(ctx)
|
|
if srv_ipblack.CheckIp(ip) {
|
|
ctx.AbortWithStatusJSON(http.StatusUnauthorized, errors.New("login limit"))
|
|
return
|
|
}
|
|
}
|