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"
|
"html/template"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
@ -51,8 +52,7 @@ type HatsSite struct {
|
||||||
Registrant *whoisparser.Contact
|
Registrant *whoisparser.Contact
|
||||||
ScreenshotURL template.URL
|
ScreenshotURL template.URL
|
||||||
Title string
|
Title string
|
||||||
HTTPOpen bool
|
Notes template.HTML
|
||||||
HTTPSOpen bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSites(largest int, wd selenium.WebDriver) (sites []HatsSite, err error) {
|
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.Registrar = result.Registrar
|
||||||
hatsSite.Registrant = result.Registrant
|
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
|
// Get web page, take screenshot
|
||||||
err = wd.Get(fmt.Sprintf("http://%v/", hatsSite.DomainName))
|
err = wd.Get(fmt.Sprintf("http://%v/", hatsSite.DomainName))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -40,6 +40,10 @@
|
||||||
<dt>Title</dt>
|
<dt>Title</dt>
|
||||||
<dd>{{.}}</dd>
|
<dd>{{.}}</dd>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{with .Notes}}
|
||||||
|
<dt>Notes</dt>
|
||||||
|
<dd>{{.}}</dd>
|
||||||
|
{{end}}
|
||||||
</dl>
|
</dl>
|
||||||
{{if .ScreenshotURL}}
|
{{if .ScreenshotURL}}
|
||||||
<img src="{{.ScreenshotURL}}" alt="screenshot of {{.DomainName}} as of {{.FetchTime.Format "Mon Jan 2 15:04:05 -0700 MST 2006" }}">
|
<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