Initial commit

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-15 13:57:10 +08:00
co-authored by Claude Opus 5
commit 8679200f41
1897 changed files with 257900 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
package ip
import (
"net/http"
"91porn-server/common/constant"
"91porn-server/common/stderr"
"91porn-server/models/v/ipwhitemod"
"91porn-server/web/webg"
"github.com/gin-gonic/gin"
)
// RealIP 获取真实IP
func RealIP(c *gin.Context) {
ip := c.ClientIP()
c.Set(constant.CtxIP, ip)
}
var accessForbidMsg = gin.H{
"code": stderr.ErrAccessForbid,
"msg": stderr.ErrAccessForbid.Msg(),
}
// RealIP 获取真实IP
func CheckWhiteIP(ctx *gin.Context) {
//检查ip是否在白名单中
// ipFlag, err := webg.Redis.SISMember(constant.IPWhiteRedisKey, constant.CtxIP)
// if webg.Conf.EnableIPWhite.IsEnable && (err != nil || !ipFlag) {
if webg.Conf.EnableIPWhite.IsEnable {
iPWhite, err := ipwhitemod.FindOneByIp(ctx.ClientIP())
if err != nil || iPWhite.IP == "" {
ctx.AbortWithStatusJSON(http.StatusOK, accessForbidMsg)
return
}
}
}