Bump version to 1.0.23
This commit is contained in:
@@ -18,6 +18,7 @@ type Machine struct {
|
||||
WakeTimeoutSeconds int `db:"wake_timeout_seconds" json:"wake_timeout_seconds"`
|
||||
WakeCheckIntervalSeconds int `db:"wake_check_interval_seconds" json:"wake_check_interval_seconds"`
|
||||
FingerprintConfirmed bool `db:"fingerprint_confirmed" json:"fingerprint_confirmed"`
|
||||
HostKeyFingerprint *string `db:"host_key_fingerprint" json:"host_key_fingerprint"`
|
||||
Status string `db:"status" json:"status"`
|
||||
LastSeenAt *time.Time `db:"last_seen_at" json:"last_seen_at"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
@@ -35,11 +36,11 @@ func (r *MachineRepository) Create(m *Machine) (int64, error) {
|
||||
res, err := r.db.Exec(`
|
||||
INSERT INTO machines (name, host, port, ssh_user, ssh_key_id, mac_address,
|
||||
wol_enabled, broadcast_addr, wake_timeout_seconds, wake_check_interval_seconds,
|
||||
fingerprint_confirmed, status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
fingerprint_confirmed, host_key_fingerprint, status)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
m.Name, m.Host, m.Port, m.SSHUser, m.SSHKeyID, m.MACAddress,
|
||||
boolToInt(m.WoLEnabled), m.BroadcastAddr, m.WakeTimeoutSeconds,
|
||||
m.WakeCheckIntervalSeconds, boolToInt(m.FingerprintConfirmed), m.Status,
|
||||
m.WakeCheckIntervalSeconds, boolToInt(m.FingerprintConfirmed), m.HostKeyFingerprint, m.Status,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -51,7 +52,7 @@ func (r *MachineRepository) GetAll() ([]Machine, error) {
|
||||
rows, err := r.db.Query(`
|
||||
SELECT id, name, host, port, ssh_user, ssh_key_id, mac_address,
|
||||
wol_enabled, broadcast_addr, wake_timeout_seconds, wake_check_interval_seconds,
|
||||
fingerprint_confirmed, status, last_seen_at, created_at
|
||||
fingerprint_confirmed, host_key_fingerprint, status, last_seen_at, created_at
|
||||
FROM machines ORDER BY name`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -64,10 +65,11 @@ func (r *MachineRepository) GetAll() ([]Machine, error) {
|
||||
var mac, bcast sql.NullString
|
||||
var keyID sql.NullInt64
|
||||
var lastSeen sql.NullTime
|
||||
var hostKeyFP sql.NullString
|
||||
err := rows.Scan(&m.ID, &m.Name, &m.Host, &m.Port, &m.SSHUser, &keyID,
|
||||
&mac, &m.WoLEnabled, &bcast, &m.WakeTimeoutSeconds,
|
||||
&m.WakeCheckIntervalSeconds, &m.FingerprintConfirmed,
|
||||
&m.Status, &lastSeen, &m.CreatedAt)
|
||||
&hostKeyFP, &m.Status, &lastSeen, &m.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -81,6 +83,9 @@ func (r *MachineRepository) GetAll() ([]Machine, error) {
|
||||
if bcast.Valid {
|
||||
m.BroadcastAddr = &bcast.String
|
||||
}
|
||||
if hostKeyFP.Valid {
|
||||
m.HostKeyFingerprint = &hostKeyFP.String
|
||||
}
|
||||
if lastSeen.Valid {
|
||||
m.LastSeenAt = &lastSeen.Time
|
||||
}
|
||||
@@ -94,15 +99,16 @@ func (r *MachineRepository) GetByID(id int64) (*Machine, error) {
|
||||
var mac, bcast sql.NullString
|
||||
var keyID sql.NullInt64
|
||||
var lastSeen sql.NullTime
|
||||
var hostKeyFP sql.NullString
|
||||
err := r.db.QueryRow(`
|
||||
SELECT id, name, host, port, ssh_user, ssh_key_id, mac_address,
|
||||
wol_enabled, broadcast_addr, wake_timeout_seconds, wake_check_interval_seconds,
|
||||
fingerprint_confirmed, status, last_seen_at, created_at
|
||||
fingerprint_confirmed, host_key_fingerprint, status, last_seen_at, created_at
|
||||
FROM machines WHERE id = ?`, id).Scan(
|
||||
&m.ID, &m.Name, &m.Host, &m.Port, &m.SSHUser, &keyID,
|
||||
&mac, &m.WoLEnabled, &bcast, &m.WakeTimeoutSeconds,
|
||||
&m.WakeCheckIntervalSeconds, &m.FingerprintConfirmed,
|
||||
&m.Status, &lastSeen, &m.CreatedAt)
|
||||
&hostKeyFP, &m.Status, &lastSeen, &m.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -116,6 +122,9 @@ func (r *MachineRepository) GetByID(id int64) (*Machine, error) {
|
||||
if bcast.Valid {
|
||||
m.BroadcastAddr = &bcast.String
|
||||
}
|
||||
if hostKeyFP.Valid {
|
||||
m.HostKeyFingerprint = &hostKeyFP.String
|
||||
}
|
||||
if lastSeen.Valid {
|
||||
m.LastSeenAt = &lastSeen.Time
|
||||
}
|
||||
@@ -126,11 +135,11 @@ func (r *MachineRepository) Update(m *Machine) error {
|
||||
_, err := r.db.Exec(`
|
||||
UPDATE machines SET name=?, host=?, port=?, ssh_user=?, ssh_key_id=?,
|
||||
mac_address=?, wol_enabled=?, broadcast_addr=?, wake_timeout_seconds=?,
|
||||
wake_check_interval_seconds=?, fingerprint_confirmed=?, status=?, last_seen_at=?
|
||||
wake_check_interval_seconds=?, fingerprint_confirmed=?, host_key_fingerprint=?, status=?, last_seen_at=?
|
||||
WHERE id=?`,
|
||||
m.Name, m.Host, m.Port, m.SSHUser, m.SSHKeyID, m.MACAddress,
|
||||
boolToInt(m.WoLEnabled), m.BroadcastAddr, m.WakeTimeoutSeconds,
|
||||
m.WakeCheckIntervalSeconds, boolToInt(m.FingerprintConfirmed),
|
||||
m.WakeCheckIntervalSeconds, boolToInt(m.FingerprintConfirmed), m.HostKeyFingerprint,
|
||||
m.Status, m.LastSeenAt, m.ID,
|
||||
)
|
||||
return err
|
||||
@@ -141,6 +150,14 @@ func (r *MachineRepository) Delete(id int64) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *MachineRepository) UpdateFingerprint(id int64, confirmed bool, fingerprint string) error {
|
||||
_, err := r.db.Exec(
|
||||
"UPDATE machines SET fingerprint_confirmed = ?, host_key_fingerprint = ? WHERE id = ?",
|
||||
boolToInt(confirmed), fingerprint, id,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *MachineRepository) UpdateStatus(id int64, status string) error {
|
||||
_, err := r.db.Exec(
|
||||
"UPDATE machines SET status = ?, last_seen_at = CURRENT_TIMESTAMP WHERE id = ?",
|
||||
|
||||
Reference in New Issue
Block a user