refactor code

This commit is contained in:
naiba
2024-11-23 00:02:57 +08:00
parent 58cc8aa5df
commit 68f6da436d
2 changed files with 4 additions and 4 deletions

View File

@@ -36,12 +36,12 @@ func RealIp(c *gin.Context) {
c.AbortWithStatusJSON(http.StatusOK, model.CommonResponse[any]{Success: false, Error: "real ip header not found"})
return
}
ip, err := netip.ParseAddr(vals)
ip, err := netip.ParseAddrPort(vals)
if err != nil {
c.AbortWithStatusJSON(http.StatusOK, model.CommonResponse[any]{Success: false, Error: err.Error()})
return
}
c.Set(model.CtxKeyRealIPStr, ip.String())
c.Set(model.CtxKeyRealIPStr, ip.Addr().String())
c.Next()
}