From 5820cce4879a5eae8addfdfbf2ed59cbb259c92b Mon Sep 17 00:00:00 2001 From: ppeb Date: Thu, 20 Mar 2025 19:26:21 -0500 Subject: [PATCH] Ban by device id for nand players and csnum for all --- database/login.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/database/login.go b/database/login.go index a92b104..875a982 100644 --- a/database/login.go +++ b/database/login.go @@ -18,7 +18,7 @@ const ( WITH RECURSIVE device_tree AS ( SELECT unnest(ng_device_id) AS device_id FROM users - WHERE ng_device_id && $1 + WHERE ng_device_id && $2 UNION SELECT unnest(ng_device_id) FROM users @@ -29,10 +29,13 @@ const ( SELECT has_ban, ban_tos, ng_device_id, ban_reason FROM users WHERE has_ban = true - AND (profile_id = $2 - OR last_ip_address = $3 - OR ($4 != '' AND last_ip_address = $4)) - AND (ban_expires IS NULL OR ban_expires > $5) + AND (profile_id = $3 + OR (ng_device_id && (SELECT * FROM known_ng_device_ids) + AND $1 != 67349608) + OR last_ip_address = $4 + OR ($4 != '' AND last_ip_address = $5) + OR $7 && csnum) + AND (ban_expires IS NULL OR ban_expires > $6) ORDER BY ban_tos DESC LIMIT 1` ) @@ -226,7 +229,7 @@ func LoginUserToGPCM(pool *pgxpool.Pool, ctx context.Context, userId uint64, gsb var banReason string timeNow := time.Now() - err = pool.QueryRow(ctx, SearchUserBan, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason) + err = pool.QueryRow(ctx, SearchUserBan, ngDeviceId, user.NgDeviceId, user.ProfileId, ipAddress, *lastIPAddress, timeNow, user.Csnum).Scan(&banExists, &banTOS, &bannedDeviceIdList, &banReason) if err != nil { if err != pgx.ErrNoRows {