Add IP logging to ban, kick, unban

This commit is contained in:
ppeb
2024-08-24 20:42:00 -05:00
parent 788bf7ff0b
commit cfec099bdd
4 changed files with 55 additions and 35 deletions

View File

@@ -16,6 +16,7 @@ const (
UpdateUserProfileID = `UPDATE users SET profile_id = $3 WHERE user_id = $1 AND gsbrcd = $2`
UpdateUserNGDeviceID = `UPDATE users SET ng_device_id = $2 WHERE profile_id = $1`
GetUser = `SELECT user_id, gsbrcd, email, unique_nick, firstname, lastname, open_host FROM users WHERE profile_id = $1`
GetUserLastIPAddress = `SELECT last_ip_address FROM users WHERE profile_id = $1`
DoesUserExist = `SELECT EXISTS(SELECT 1 FROM users WHERE user_id = $1 AND gsbrcd = $2)`
IsProfileIDInUse = `SELECT EXISTS(SELECT 1 FROM users WHERE profile_id = $1)`
DeleteUserSession = `DELETE FROM sessions WHERE profile_id = $1`
@@ -147,6 +148,16 @@ func UnbanUser(pool *pgxpool.Pool, ctx context.Context, profileId uint32) bool {
return err == nil
}
func GetUserIP(pool *pgxpool.Pool, ctx context.Context, profileId uint32) string {
var ip string
err := pool.QueryRow(ctx, GetUserLastIPAddress, profileId).Scan(&ip)
if err != nil {
return "Unknown"
}
return ip
}
func GetMKWFriendInfo(pool *pgxpool.Pool, ctx context.Context, profileId uint32) string {
var info string
err := pool.QueryRow(ctx, GetMKWFriendInfoQuery, profileId).Scan(&info)