From b5712f40773685afacd94afdac2a6dc76141ff23 Mon Sep 17 00:00:00 2001 From: phenpessoa Date: Tue, 26 Sep 2023 12:17:35 -0300 Subject: [PATCH] webserver: return on error and check if location is not nil --- src/webserver.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/webserver.go b/src/webserver.go index bb84c5a1..6fa6e59e 100644 --- a/src/webserver.go +++ b/src/webserver.go @@ -1230,7 +1230,7 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string case http.StatusFound: // Check if page is in maintenance mode location, _ := res.RawResponse.Location() - if location.Host == "maintenance.tibia.com" { + if location != nil && location.Host == "maintenance.tibia.com" { LogMessage := "maintenance mode detected on tibia.com" log.Printf("[info] TibiaDataHTMLDataCollector: %s!", LogMessage) return "", validation.ErrorMaintenanceMode @@ -1258,6 +1258,7 @@ func TibiaDataHTMLDataCollector(TibiaDataRequest TibiaDataRequestStruct) (string doc, err := goquery.NewDocumentFromReader(resIo2) if err != nil { log.Printf("[error] TibiaDataHTMLDataCollector (URL: %s) error: %s", res.Request.URL, err) + return "", err } data, err := doc.Find(".Border_2 .Border_3").Html()