切换util工具函数
This commit is contained in:
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/gin/define"
|
||||
|
||||
networkUtil "git.zhangdeman.cn/zhangdeman/network/util"
|
||||
"git.zhangdeman.cn/zhangdeman/util"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
@ -43,8 +44,8 @@ func getTraceID(ctx *gin.Context) string {
|
||||
return fmt.Sprintf(
|
||||
"%v-%v-%v-%v",
|
||||
time.Now().UnixNano()/1e6,
|
||||
strings.ReplaceAll(util.IP.GetHostIP(), ".", ""),
|
||||
strings.ReplaceAll(util.IP.GetRemoteIP(ctx.Request), ".", ""),
|
||||
strings.ReplaceAll(networkUtil.IP.GetHostIP(), ".", ""),
|
||||
strings.ReplaceAll(networkUtil.IP.GetRemoteIP(ctx.Request), ".", ""),
|
||||
util.String.Md5(util.String.GenRandom("", 32)),
|
||||
)
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ package middleware
|
||||
import (
|
||||
"git.zhangdeman.cn/zhangdeman/gin/define"
|
||||
"git.zhangdeman.cn/zhangdeman/gin/response"
|
||||
"git.zhangdeman.cn/zhangdeman/util"
|
||||
networkUtil "git.zhangdeman.cn/zhangdeman/network/util"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@ -26,7 +26,7 @@ func ValidateBlackIPMiddleware(code interface{}, httpCode int, validateFunc defi
|
||||
ctx.Next()
|
||||
return
|
||||
}
|
||||
if validateFunc(ctx, util.IP.GetRemoteIP(ctx.Request)) {
|
||||
if validateFunc(ctx, networkUtil.IP.GetRemoteIP(ctx.Request)) {
|
||||
// 命中黑名单
|
||||
response.Send(ctx, code, httpCode, nil)
|
||||
ctx.Abort()
|
||||
@ -48,7 +48,7 @@ func ValidateWhiteIPMiddleware(code interface{}, httpCode int, validateFunc defi
|
||||
ctx.Next()
|
||||
return
|
||||
}
|
||||
if !validateFunc(ctx, util.IP.GetRemoteIP(ctx.Request)) {
|
||||
if !validateFunc(ctx, networkUtil.IP.GetRemoteIP(ctx.Request)) {
|
||||
// 非名单
|
||||
response.Send(ctx, code, httpCode, nil)
|
||||
ctx.Abort()
|
||||
|
Reference in New Issue
Block a user