Include DNS check and graceful error if no DNS record exists
This commit is contained in:
parent
123bd7d62a
commit
0d2575bc0a
11
main.go
11
main.go
|
@ -33,6 +33,7 @@ import (
|
|||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
@ -51,8 +52,7 @@ type HatsSite struct {
|
|||
Registrant *whoisparser.Contact
|
||||
ScreenshotURL template.URL
|
||||
Title string
|
||||
HTTPOpen bool
|
||||
HTTPSOpen bool
|
||||
Notes template.HTML
|
||||
}
|
||||
|
||||
func getSites(largest int, wd selenium.WebDriver) (sites []HatsSite, err error) {
|
||||
|
@ -82,6 +82,13 @@ func getSites(largest int, wd selenium.WebDriver) (sites []HatsSite, err error)
|
|||
hatsSite.Registrar = result.Registrar
|
||||
hatsSite.Registrant = result.Registrant
|
||||
|
||||
_, err = net.LookupHost(hatsSite.DomainName)
|
||||
if err != nil {
|
||||
hatsSite.Notes = template.HTML(fmt.Sprintf("DNS Error: <code>%v</code>", err.Error()))
|
||||
sites = append(sites, hatsSite)
|
||||
continue
|
||||
}
|
||||
|
||||
// Get web page, take screenshot
|
||||
err = wd.Get(fmt.Sprintf("http://%v/", hatsSite.DomainName))
|
||||
if err != nil {
|
||||
|
|
|
@ -40,6 +40,10 @@
|
|||
<dt>Title</dt>
|
||||
<dd>{{.}}</dd>
|
||||
{{end}}
|
||||
{{with .Notes}}
|
||||
<dt>Notes</dt>
|
||||
<dd>{{.}}</dd>
|
||||
{{end}}
|
||||
</dl>
|
||||
{{if .ScreenshotURL}}
|
||||
<img src="{{.ScreenshotURL}}" alt="screenshot of {{.DomainName}} as of {{.FetchTime.Format "Mon Jan 2 15:04:05 -0700 MST 2006" }}">
|
||||
|
|
Loading…
Reference in a new issue