db defender: fix getHost query and add more test cases

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino
2022-03-16 18:22:08 +01:00
parent 7b86e2ac59
commit 883a3dceaf
5 changed files with 32 additions and 8 deletions

View File

@@ -52,7 +52,7 @@ func getDefenderHostsQuery() string {
}
func getDefenderHostQuery() string {
return fmt.Sprintf(`SELECT id,ip,ban_time FROM %v WHERE ip = %v AND updated_at >= %v`,
return fmt.Sprintf(`SELECT id,ip,ban_time FROM %v WHERE ip = %v AND (updated_at >= %v OR ban_time > 0)`,
sqlTableDefenderHosts, sqlPlaceholders[0], sqlPlaceholders[1])
}