Skip to content

Commit

Permalink
complete missing debug statements
Browse files Browse the repository at this point in the history
  • Loading branch information
nitram509 committed Apr 1, 2024
1 parent 5dcd99f commit f0a169e
Showing 1 changed file with 30 additions and 51 deletions.
81 changes: 30 additions & 51 deletions debug_report.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ func (drc *DebugReportCommand) Run(args *GlobalOptions) error {
model, _, err := readTokenAndModel2GlobalOptions(args, drc.Address)
if err != nil {
printDebugNotLoggedIn(args, drc.Address, err)
} else {
println("Error: " + err.Error())
}
if isModel30x(model) {
printDebugReportGs30xEPx(drc.Address)
}
if isModel316(model) {
printDebugReportGs316EPx(drc.Address)
}
printDebugLoggedIn(args, model, drc.Address)
return nil
}

Expand Down Expand Up @@ -47,58 +44,40 @@ func printDebugNotLoggedIn(args *GlobalOptions, host string, err error) {
}

func printDebugLoggedIn(args *GlobalOptions, model NetgearModel, host string) {
println("---[DEBUG: model " + model + "]---")

var reqUrls []string
if isModel30x(model) {
reqUrls = []string{
fmt.Sprintf("http://%s/getPoePortStatus.cgi", host),
fmt.Sprintf("http://%s/PoEPortConfig.cgi", host),
fmt.Sprintf("http://%s/port_status.cgi", host),
fmt.Sprintf("http://%s/dashboard.cgi", host),
}
}
if isModel316(model) {
reqUrls = []string{
if !isModel30x(model) {
reqUrls = append(reqUrls,
// GS316xx
fmt.Sprintf("http://%s/iss/specific/poe.html", host),
fmt.Sprintf("http://%s/iss/specific/poePortConf.html", host),
fmt.Sprintf("http://%s/iss/specific/poePortStatus.html", host),
fmt.Sprintf("http://%s/iss/specific/dashboard.html", host),
fmt.Sprintf("http://%s/iss/specific/homepage.html", host),
}
)
}

for _, reqUrl := range reqUrls {
body, err := doHttpRequestAndReadResponse(args, "GET", host, reqUrl, "")
println(fmt.Sprintf("---[RESPONSE: %s]---", reqUrl))
if err != nil {
println("ERROR: " + err.Error())
} else if checkIsLoginRequired(body) {
println("WARN: it seems the session token expired, please re-login")
} else {
println(body)
if !isModel316(model) {
reqUrls = append(reqUrls,
// GS30xxx
fmt.Sprintf("http://%s/getPoePortStatus.cgi", host),
fmt.Sprintf("http://%s/PoEPortConfig.cgi", host),
fmt.Sprintf("http://%s/port_status.cgi", host),
fmt.Sprintf("http://%s/dashboard.cgi", host),
)
}
if len(reqUrls) > 0 {
println(fmt.Sprintf("---[DEBUG: model '%s']---", model))
for _, reqUrl := range reqUrls {
body, err := doHttpRequestAndReadResponse(args, "GET", host, reqUrl, "")
println(fmt.Sprintf("---[RESPONSE: %s]---", reqUrl))
if err != nil {
println("ERROR: " + err.Error())
} else if checkIsLoginRequired(body) {
println("WARN: it seems the session token expired, please re-login")
} else {
println(body)
}
println("---[/RESPONSE]---")
}
println("---[/RESPONSE]---")
println("---[/DEBUG]---")
}
println("---[/DEBUG]---")
}

func printDebugReportGs30xEPx(string) {
//var reqUrl string
//reqUrl = fmt.Sprintf("http://%s/getPoePortStatus.cgi", drc.Address)
//requestPage(args, drc.Address, reqUrl)

//if checkIsLoginRequired(statusPage) {
// return errors.New("no content. please, (re-)login first")
//}
//println("---[DEBUG]---")
//println(statusPage)
//println("---[DEBUG]---")

}

func printDebugReportGs316EPx(string) {
//var reqUrl string
//reqUrl = fmt.Sprintf("http://%s/iss/specific/poe.html", drc.Address)
//requestPage(args, drc.Address, reqUrl)
}

0 comments on commit f0a169e

Please sign in to comment.