fix: 自助注册按 trusted_proxies 解析客户端 IP
This commit is contained in:
+4
-1
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user