Fix unmarshalling of ip from postgres
This commit is contained in:
parent
82d07eaaf4
commit
c1a1bf0b03
@ -3,6 +3,7 @@ package store
|
|||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
|
||||||
_ "github.com/jackc/pgx/v4/stdlib"
|
_ "github.com/jackc/pgx/v4/stdlib"
|
||||||
"github.uio.no/torjus/apiary/models"
|
"github.uio.no/torjus/apiary/models"
|
||||||
@ -188,9 +189,11 @@ func (s *PostgresStore) Query(query AttemptQuery) ([]models.LoginAttempt, error)
|
|||||||
var results []models.LoginAttempt
|
var results []models.LoginAttempt
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var la models.LoginAttempt
|
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)
|
return nil, fmt.Errorf("Unable to unmarshal data from database: %w", err)
|
||||||
}
|
}
|
||||||
|
la.RemoteIP = net.ParseIP(ipString)
|
||||||
results = append(results, la)
|
results = append(results, la)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user