mirror of
https://github.com/davidallendj/magellan.git
synced 2025-12-20 03:27:03 -07:00
Added more output for debugging
This commit is contained in:
parent
a75530e96b
commit
e93f49eb82
3 changed files with 21 additions and 8 deletions
|
|
@ -57,7 +57,7 @@ var scanCmd = &cobra.Command{
|
||||||
if threads <= 0 {
|
if threads <= 0 {
|
||||||
threads = mathutil.Clamp(len(hostsToScan), 1, 255)
|
threads = mathutil.Clamp(len(hostsToScan), 1, 255)
|
||||||
}
|
}
|
||||||
probeStates := magellan.ScanForAssets(hostsToScan, portsToScan, threads, timeout, disableProbing)
|
probeStates := magellan.ScanForAssets(hostsToScan, portsToScan, threads, timeout, disableProbing, verbose)
|
||||||
if verbose {
|
if verbose {
|
||||||
for _, r := range probeStates {
|
for _, r := range probeStates {
|
||||||
fmt.Printf("%s:%d (%s)\n", r.Host, r.Port, r.Protocol)
|
fmt.Printf("%s:%d (%s)\n", r.Host, r.Port, r.Protocol)
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,10 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
l.Log.Errorf("failed to query chassis: %v", err)
|
l.Log.Errorf("failed to query chassis: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
json.Unmarshal(chassis, &rm)
|
err = json.Unmarshal(chassis, &rm)
|
||||||
|
if err != nil {
|
||||||
|
l.Log.Errorf("failed to unmarshal chassis JSON: %v", err)
|
||||||
|
}
|
||||||
data["Chassis"] = rm["Chassis"]
|
data["Chassis"] = rm["Chassis"]
|
||||||
|
|
||||||
// systems
|
// systems
|
||||||
|
|
@ -133,7 +136,10 @@ func CollectAll(probeStates *[]ScannedResult, l *log.Logger, q *QueryParams) err
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Log.Errorf("failed to query systems: %v", err)
|
l.Log.Errorf("failed to query systems: %v", err)
|
||||||
}
|
}
|
||||||
json.Unmarshal(systems, &rm)
|
err = json.Unmarshal(systems, &rm)
|
||||||
|
if err != nil {
|
||||||
|
l.Log.Errorf("failed to unmarshal system JSON: %v", err)
|
||||||
|
}
|
||||||
data["Systems"] = rm["Systems"]
|
data["Systems"] = rm["Systems"]
|
||||||
|
|
||||||
// add other fields from systems
|
// add other fields from systems
|
||||||
|
|
|
||||||
|
|
@ -95,11 +95,12 @@ func generateHosts(ip *net.IP, mask *net.IPMask) []string {
|
||||||
return hosts
|
return hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
func ScanForAssets(hosts []string, ports []int, threads int, timeout int, disableProbing bool) []ScannedResult {
|
func ScanForAssets(hosts []string, ports []int, threads int, timeout int, disableProbing bool, verbose bool) []ScannedResult {
|
||||||
results := make([]ScannedResult, 0, len(hosts))
|
var (
|
||||||
done := make(chan struct{}, threads+1)
|
results = make([]ScannedResult, 0, len(hosts))
|
||||||
chanHost := make(chan string, threads+1)
|
done = make(chan struct{}, threads+1)
|
||||||
// chanPort := make(chan int, threads+1)
|
chanHost = make(chan string, threads+1)
|
||||||
|
)
|
||||||
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(threads)
|
wg.Add(threads)
|
||||||
|
|
@ -118,8 +119,14 @@ func ScanForAssets(hosts []string, ports []int, threads int, timeout int, disabl
|
||||||
url := fmt.Sprintf("https://%s:%d/redfish/v1/", result.Host, result.Port)
|
url := fmt.Sprintf("https://%s:%d/redfish/v1/", result.Host, result.Port)
|
||||||
res, _, err := util.MakeRequest(nil, url, "GET", nil, nil)
|
res, _, err := util.MakeRequest(nil, url, "GET", nil, nil)
|
||||||
if err != nil || res == nil {
|
if err != nil || res == nil {
|
||||||
|
if verbose {
|
||||||
|
fmt.Printf("failed to make request: %v\n", err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
} else if res.StatusCode != http.StatusOK {
|
} else if res.StatusCode != http.StatusOK {
|
||||||
|
if verbose {
|
||||||
|
fmt.Printf("request returned code: %v\n", res.StatusCode)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
probeResults = append(probeResults, result)
|
probeResults = append(probeResults, result)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue