Rename BMCProbeResult to ScannedResult and remove from collect.go

This commit is contained in:
David J. Allen 2023-10-09 11:20:02 -06:00
parent 54dde2dda6
commit 4694353220
2 changed files with 5 additions and 11 deletions

View file

@ -33,12 +33,6 @@ const (
HTTPS_PORT = 443 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... // NOTE: ...params were getting too long...
type QueryParams struct { type QueryParams struct {
@ -112,7 +106,7 @@ func NewClient(l *log.Logger, q *QueryParams) (*bmclib.Client, error) {
return client, nil 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 // check for available probe states
if probeStates == nil { if probeStates == nil {
return fmt.Errorf("no probe states found") 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)) found := make([]string, 0, len(*probeStates))
done := make(chan struct{}, q.Threads+1) 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 // generate custom xnames for bmcs
node := xnames.Node{ node := xnames.Node{

View file

@ -8,7 +8,7 @@ import (
"github.com/jmoiron/sqlx" "github.com/jmoiron/sqlx"
) )
func InsertProbeResults(path string, states *[]magellan.BMCProbeResult) error { func InsertProbeResults(path string, states *[]magellan.ScannedResult) error {
if states == nil { if states == nil {
return fmt.Errorf("states == nil") return fmt.Errorf("states == nil")
} }
@ -46,13 +46,13 @@ func InsertProbeResults(path string, states *[]magellan.BMCProbeResult) error {
return nil return nil
} }
func GetProbeResults(path string) ([]magellan.BMCProbeResult, error) { func GetProbeResults(path string) ([]magellan.ScannedResult, error) {
db, err := sqlx.Open("sqlite3", path) db, err := sqlx.Open("sqlite3", path)
if err != nil { if err != nil {
return nil, fmt.Errorf("could not open database: %v", err) 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;") err = db.Select(&results, "SELECT * FROM magellan_scanned_ports ORDER BY host ASC, port ASC;")
if err != nil { if err != nil {
return nil, fmt.Errorf("could not retrieve probes: %v", err) return nil, fmt.Errorf("could not retrieve probes: %v", err)