fix: 自助注册按 trusted_proxies 解析客户端 IP

This commit is contained in:
Nixevol
2026-09-30 10:44:43 +08:00
parent 479a08ee11
commit 73ee4e74c7
3 changed files with 91 additions and 1 deletions
+4 -1
View File
@@ -137,6 +137,7 @@ func runServe(ctx context.Context, cfg config.Config) error {
sess.SetPresence(presApp)
uplink.presence = presApp
trustedNets := httpx.ParseCIDRs(cfg.TrustedProxies)
idApp := identity.New(identity.Config{
DB: db,
Hash: hashPool,
@@ -145,6 +146,9 @@ func runServe(ctx context.Context, cfg config.Config) error {
MaxScheduleSeconds: int64(cfg.Limits.MaxScheduleSeconds),
Logger: slog.Default(),
ConnControl: brk,
ClientIP: func(r *http.Request) string {
return httpx.ClientIP(r, trustedNets)
},
})
uplink.identity = idApp
@@ -161,7 +165,6 @@ func runServe(ctx context.Context, cfg config.Config) error {
return fmt.Errorf("message recover: %w", recoverErr)
}
trustedNets := httpx.ParseCIDRs(cfg.TrustedProxies)
adminHandler := admin.New(admin.Deps{
DB: db,
Hash: hashPool,