feat: 连接列表显示客户端真实 IP,支持反代和 CDN 场景
新增可配置的 real_ip_headers(默认 CF-Connecting-IP > X-Real-IP > X-Forwarded-For 降级取值),trusted_proxies 用于 gin 代理信任链。 WebSocket 连接建立时捕获真实 IP 并在 /profile 和 /admin 连接列表展示, 登录会话 IP 同步改用真实 IP。
This commit is contained in:
@@ -80,7 +80,7 @@ func Login(c *gin.Context) {
|
||||
session := model.Session{
|
||||
SessionID: sessionID,
|
||||
UserID: user.ID,
|
||||
IP: c.ClientIP(),
|
||||
IP: middleware.GetRealIP(c),
|
||||
UserAgent: c.GetHeader("User-Agent"),
|
||||
ExpiresAt: time.Now().Add(24 * time.Hour),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user