diff --git a/honeypot/store/postgres.go b/honeypot/store/postgres.go index 756aea8..83bc571 100644 --- a/honeypot/store/postgres.go +++ b/honeypot/store/postgres.go @@ -3,6 +3,7 @@ package store import ( "database/sql" "fmt" + "net" _ "github.com/jackc/pgx/v4/stdlib" "github.uio.no/torjus/apiary/models" @@ -188,9 +189,11 @@ func (s *PostgresStore) Query(query AttemptQuery) ([]models.LoginAttempt, error) var results []models.LoginAttempt for rows.Next() { var la models.LoginAttempt - if err := rows.Scan(&la.ID, &la.Date, &la.RemoteIP, &la.Username, &la.Password, &la.SSHClientVersion, &la.ConnectionUUID, &la.Country); err != nil { + var ipString string + if err := rows.Scan(&la.ID, &la.Date, &ipString, &la.Username, &la.Password, &la.SSHClientVersion, &la.ConnectionUUID, &la.Country); err != nil { return nil, fmt.Errorf("Unable to unmarshal data from database: %w", err) } + la.RemoteIP = net.ParseIP(ipString) results = append(results, la) }