From 46943532209a4a7faa8d6625b590d8b1f795bc00 Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Mon, 9 Oct 2023 11:20:02 -0600 Subject: [PATCH] Rename `BMCProbeResult` to `ScannedResult` and remove from `collect.go` --- internal/collect.go | 10 ++-------- internal/db/sqlite/sqlite.go | 6 +++--- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/internal/collect.go b/internal/collect.go index 9ca35b9..0f43d75 100644 --- a/internal/collect.go +++ b/internal/collect.go @@ -33,12 +33,6 @@ const ( HTTPS_PORT = 443 ) -type BMCProbeResult struct { - Host string `json:"host"` - Port int `json:"port"` - Protocol string `json:"protocol"` - State bool `json:"state"` -} // NOTE: ...params were getting too long... type QueryParams struct { @@ -112,7 +106,7 @@ func NewClient(l *log.Logger, q *QueryParams) (*bmclib.Client, error) { return client, nil } -func CollectInfo(probeStates *[]BMCProbeResult, l *log.Logger, q *QueryParams) error { +func CollectInfo(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) error { // check for available probe states if probeStates == nil { return fmt.Errorf("no probe states found") @@ -130,7 +124,7 @@ func CollectInfo(probeStates *[]BMCProbeResult, l *log.Logger, q *QueryParams) e found := make([]string, 0, len(*probeStates)) done := make(chan struct{}, q.Threads+1) - chanProbeState := make(chan BMCProbeResult, q.Threads+1) + chanProbeState := make(chan ScannedResult, q.Threads+1) // generate custom xnames for bmcs node := xnames.Node{ diff --git a/internal/db/sqlite/sqlite.go b/internal/db/sqlite/sqlite.go index 39ff33b..2dbc67c 100644 --- a/internal/db/sqlite/sqlite.go +++ b/internal/db/sqlite/sqlite.go @@ -8,7 +8,7 @@ import ( "github.com/jmoiron/sqlx" ) -func InsertProbeResults(path string, states *[]magellan.BMCProbeResult) error { +func InsertProbeResults(path string, states *[]magellan.ScannedResult) error { if states == nil { return fmt.Errorf("states == nil") } @@ -46,13 +46,13 @@ func InsertProbeResults(path string, states *[]magellan.BMCProbeResult) error { return nil } -func GetProbeResults(path string) ([]magellan.BMCProbeResult, error) { +func GetProbeResults(path string) ([]magellan.ScannedResult, error) { db, err := sqlx.Open("sqlite3", path) if err != nil { return nil, fmt.Errorf("could not open database: %v", err) } - results := []magellan.BMCProbeResult{} + results := []magellan.ScannedResult{} err = db.Select(&results, "SELECT * FROM magellan_scanned_ports ORDER BY host ASC, port ASC;") if err != nil { return nil, fmt.Errorf("could not retrieve probes: %v", err)