verify ip
This commit is contained in:
parent
016036905b
commit
d235aa4edb
|
@ -8,7 +8,6 @@ import (
|
||||||
|
|
||||||
func VerifyIp() gin.HandlerFunc {
|
func VerifyIp() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
return
|
|
||||||
// 读取请求体
|
// 读取请求体
|
||||||
reqIp := c.ClientIP()
|
reqIp := c.ClientIP()
|
||||||
//验证商户是否存在
|
//验证商户是否存在
|
||||||
|
@ -25,3 +24,16 @@ func VerifyIp() gin.HandlerFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func VerifyHtmlIp() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
// 读取请求体
|
||||||
|
reqIp := c.ClientIP()
|
||||||
|
//验证商户是否存在
|
||||||
|
if reqIp != "172.22.0.1" && reqIp != "117.176.133.38" {
|
||||||
|
common.Error(c, 400, "ip无权限访问")
|
||||||
|
c.Abort()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ func RegisterRoute(router *gin.Engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
orders := router.Group("/orders")
|
orders := router.Group("/orders")
|
||||||
|
orders.Use(middlewares.VerifyHtmlIp())
|
||||||
{
|
{
|
||||||
orders.POST("/get_by_id", ordersCon.GetById)
|
orders.POST("/get_by_id", ordersCon.GetById)
|
||||||
orders.POST("/search", ordersCon.Search)
|
orders.POST("/search", ordersCon.Search)
|
||||||
|
@ -78,6 +79,7 @@ func RegisterRoute(router *gin.Engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
product := router.Group("/product")
|
product := router.Group("/product")
|
||||||
|
product.Use(middlewares.VerifyHtmlIp())
|
||||||
{
|
{
|
||||||
product.POST("/get_by_id", proCon.GetById)
|
product.POST("/get_by_id", proCon.GetById)
|
||||||
product.POST("/search", proCon.Search)
|
product.POST("/search", proCon.Search)
|
||||||
|
@ -87,6 +89,7 @@ func RegisterRoute(router *gin.Engine) {
|
||||||
}
|
}
|
||||||
|
|
||||||
whitelist := router.Group("/whitelist")
|
whitelist := router.Group("/whitelist")
|
||||||
|
whitelist.Use(middlewares.VerifyHtmlIp())
|
||||||
{
|
{
|
||||||
whitelist.POST("/get_by_id", wlCon.GetById)
|
whitelist.POST("/get_by_id", wlCon.GetById)
|
||||||
whitelist.POST("/search", wlCon.Search)
|
whitelist.POST("/search", wlCon.Search)
|
||||||
|
|
Loading…
Reference in New Issue