From c1a1bf0b0386f1019d19fb732a64a79dd4ad05d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Wed, 14 Apr 2021 18:01:11 +0200 Subject: [PATCH] Fix unmarshalling of ip from postgres --- honeypot/store/postgres.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) }