nwesterhausen / domain-monitor

Self-hosted server to monitor WHOIS records for specified domains.
MIT License
84 stars 11 forks source link

Unregistered Domains Trigger Exception & Eventual Panic on Dashboard #86

Open xM8WVqaG opened 3 months ago

xM8WVqaG commented 3 months ago

Describe the bug If you monitor a domain that isn't currently registered, it raises a stack trace and crashes the server.

To Reproduce Steps to reproduce the behavior:

  1. Add example-unregistered-domain.com to Monitored Domains
  2. Navigate back to Dashboard in the Web GUI
  3. See errors below

Exception which doesn't kill the server:

dm_1  | 2024/07/21 12:05:43 🙅 WHOIS entry cache miss for example-unregistered-domain.com
dm_1  | 2024/07/21 12:05:43 Error parsing whois for example-unregistered-domain.com: whoisparser: domain is not found
dm_1  | 2024/07/21 12:05:43 💾 Flushed WHOIS data cache to whois-cache.yaml
dm_1  | echo: http: panic serving 172.18.0.1:40108: runtime error: invalid memory address or nil pointer dereference
dm_1  | goroutine 30 [running]:
dm_1  | net/http.(*conn).serve.func1()
dm_1  |     /usr/local/go/src/net/http/server.go:1898 +0xbe
dm_1  | panic({0x75e600?, 0xa77b50?})
dm_1  |     /usr/local/go/src/runtime/panic.go:770 +0x132
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard.WhoisDetail.func2({0x857710?, 0xc00020c690?}, {0x855460, 0xc000520d20?})
dm_1  |     /src/views/domains/domain-dashboard_templ.go:217 +0x17f
dm_1  | github.com/a-h/templ.ComponentFunc.Render(0xa79070?, {0x857710?, 0xc00020c690?}, {0x855460?, 0xc000520d20?})
dm_1  |     /go/pkg/mod/github.com/a-h/templ@v0.2.648/runtime.go:41 +0x37
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.View({0x85cd78, 0xc00017a0a0}, {0x854c60, 0xc000138400})
dm_1  |     /src/handlers/routes.go:87 +0x170
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard(0xc00004a0b0, {0x85cd78, 0xc00017a0a0})
dm_1  |     /src/handlers/whois.handler.go:38 +0x212
dm_1  | github.com/labstack/echo/v4.(*Echo).add.func1({0x85cd78, 0xc00017a0a0})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:582 +0x4b
dm_1  | github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x85cd78, 0xc00017a0a0})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/middleware/logger.go:126 +0xd8
dm_1  | github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc00013c248, {0x857048, 0xc000520d20}, 0xc000524a20)
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:669 +0x327
dm_1  | net/http.serverHandler.ServeHTTP({0x8561d0?}, {0x857048?, 0xc000520d20?}, 0x6?)
dm_1  |     /usr/local/go/src/net/http/server.go:3137 +0x8e
dm_1  | net/http.(*conn).serve(0xc00007a3f0, {0x8576d8, 0xc0002f5440})
dm_1  |     /usr/local/go/src/net/http/server.go:2039 +0x5e8
dm_1  | created by net/http.(*Server).Serve in goroutine 1
dm_1  |     /usr/local/go/src/net/http/server.go:3285 +0x4b4
dm_1  | echo: http: panic serving 172.18.0.1:35428: runtime error: invalid memory address or nil pointer dereference
dm_1  | goroutine 162 [running]:
dm_1  | net/http.(*conn).serve.func1()
dm_1  |     /usr/local/go/src/net/http/server.go:1898 +0xbe
dm_1  | panic({0x75e600?, 0xa77b50?})
dm_1  |     /usr/local/go/src/runtime/panic.go:770 +0x132
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard.WhoisDetail.func2({0x857710?, 0xc0000ca000?}, {0x855460, 0xc000520000?})
dm_1  |     /src/views/domains/domain-dashboard_templ.go:217 +0x17f
dm_1  | github.com/a-h/templ.ComponentFunc.Render(0xa79070?, {0x857710?, 0xc0000ca000?}, {0x855460?, 0xc000520000?})
dm_1  |     /go/pkg/mod/github.com/a-h/templ@v0.2.648/runtime.go:41 +0x37
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.View({0x85cd78, 0xc0001020a0}, {0x854c60, 0xc000096080})
dm_1  |     /src/handlers/routes.go:87 +0x170
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard(0xc00004a0b0, {0x85cd78, 0xc0001020a0})
dm_1  |     /src/handlers/whois.handler.go:38 +0x212
dm_1  | github.com/labstack/echo/v4.(*Echo).add.func1({0x85cd78, 0xc0001020a0})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:582 +0x4b
dm_1  | github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x85cd78, 0xc0001020a0})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/middleware/logger.go:126 +0xd8
dm_1  | github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc00013c248, {0x857048, 0xc000520000}, 0xc000524000)
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:669 +0x327
dm_1  | net/http.serverHandler.ServeHTTP({0x8561d0?}, {0x857048?, 0xc000520000?}, 0x6?)
dm_1  |     /usr/local/go/src/net/http/server.go:3137 +0x8e
dm_1  | net/http.(*conn).serve(0xc0001347e0, {0x8576d8, 0xc0002f5440})
dm_1  |     /usr/local/go/src/net/http/server.go:2039 +0x5e8
dm_1  | created by net/http.(*Server).Serve in goroutine 1
dm_1  |     /usr/local/go/src/net/http/server.go:3285 +0x4b4
dm_1  | echo: http: panic serving 172.18.0.1:35434: runtime error: invalid memory address or nil pointer dereference
dm_1  | goroutine 226 [running]:
dm_1  | net/http.(*conn).serve.func1()
dm_1  |     /usr/local/go/src/net/http/server.go:1898 +0xbe
dm_1  | panic({0x75e600?, 0xa77b50?})
dm_1  |     /usr/local/go/src/runtime/panic.go:770 +0x132
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard.WhoisDetail.func2({0x857710?, 0xc0000ca0f0?}, {0x855460, 0xc0005200e0?})
dm_1  |     /src/views/domains/domain-dashboard_templ.go:217 +0x17f
dm_1  | github.com/a-h/templ.ComponentFunc.Render(0xa79070?, {0x857710?, 0xc0000ca0f0?}, {0x855460?, 0xc0005200e0?})
dm_1  |     /go/pkg/mod/github.com/a-h/templ@v0.2.648/runtime.go:41 +0x37
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.View({0x85cd78, 0xc000102280}, {0x854c60, 0xc000096200})
dm_1  |     /src/handlers/routes.go:87 +0x170
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard(0xc00004a0b0, {0x85cd78, 0xc000102280})
dm_1  |     /src/handlers/whois.handler.go:38 +0x212
dm_1  | github.com/labstack/echo/v4.(*Echo).add.func1({0x85cd78, 0xc000102280})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:582 +0x4b
dm_1  | github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x85cd78, 0xc000102280})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/middleware/logger.go:126 +0xd8
dm_1  | github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc00013c248, {0x857048, 0xc0005200e0}, 0xc000524120)
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:669 +0x327
dm_1  | net/http.serverHandler.ServeHTTP({0x8561d0?}, {0x857048?, 0xc0005200e0?}, 0x6?)
dm_1  |     /usr/local/go/src/net/http/server.go:3137 +0x8e
dm_1  | net/http.(*conn).serve(0xc000206090, {0x8576d8, 0xc0002f5440})
dm_1  |     /usr/local/go/src/net/http/server.go:2039 +0x5e8
dm_1  | created by net/http.(*Server).Serve in goroutine 1
dm_1  |     /usr/local/go/src/net/http/server.go:3285 +0x4b4

Unhandled panic which does::

dm_1  | echo: http: panic serving 172.18.0.1:45044: runtime error: invalid memory address or nil pointer dereference
dm_1  | goroutine 54 [running]:
dm_1  | net/http.(*conn).serve.func1()
dm_1  |     /usr/local/go/src/net/http/server.go:1898 +0xbe
dm_1  | panic({0x75e600?, 0xa77b50?})
dm_1  |     /usr/local/go/src/runtime/panic.go:770 +0x132
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard.WhoisDetail.func2({0x857710?, 0xc000078500?}, {0x855460, 0xc000208700?})
dm_1  |     /src/views/domains/domain-dashboard_templ.go:217 +0x17f
dm_1  | github.com/a-h/templ.ComponentFunc.Render(0xa79070?, {0x857710?, 0xc000078500?}, {0x855460?, 0xc000208700?})
dm_1  |     /go/pkg/mod/github.com/a-h/templ@v0.2.648/runtime.go:41 +0x37
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.View({0x85cd78, 0xc000218000}, {0x854c60, 0xc0000ca380})
dm_1  |     /src/handlers/routes.go:87 +0x170
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard(0xc00004a0b0, {0x85cd78, 0xc000218000})
dm_1  |     /src/handlers/whois.handler.go:38 +0x212
dm_1  | github.com/labstack/echo/v4.(*Echo).add.func1({0x85cd78, 0xc000218000})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:582 +0x4b
dm_1  | github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x85cd78, 0xc000218000})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/middleware/logger.go:126 +0xd8
dm_1  | github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0000bc248, {0x857048, 0xc000208700}, 0xc00019e6c0)
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:669 +0x327
dm_1  | net/http.serverHandler.ServeHTTP({0x8561d0?}, {0x857048?, 0xc000208700?}, 0x6?)
dm_1  |     /usr/local/go/src/net/http/server.go:3137 +0x8e
dm_1  | net/http.(*conn).serve(0xc0000b42d0, {0x8576d8, 0xc000101c80})
dm_1  |     /usr/local/go/src/net/http/server.go:2039 +0x5e8
dm_1  | created by net/http.(*Server).Serve in goroutine 1
dm_1  |     /usr/local/go/src/net/http/server.go:3285 +0x4b4
dm_1  | echo: http: panic serving 172.18.0.1:45048: runtime error: invalid memory address or nil pointer dereference
dm_1  | goroutine 28 [running]:
dm_1  | net/http.(*conn).serve.func1()
dm_1  |     /usr/local/go/src/net/http/server.go:1898 +0xbe
dm_1  | panic({0x75e600?, 0xa77b50?})
dm_1  |     /usr/local/go/src/runtime/panic.go:770 +0x132
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard.WhoisDetail.func2({0x857710?, 0xc0000785a0?}, {0x855460, 0xc0002087e0?})
dm_1  |     /src/views/domains/domain-dashboard_templ.go:217 +0x17f
dm_1  | github.com/a-h/templ.ComponentFunc.Render(0xa79070?, {0x857710?, 0xc0000785a0?}, {0x855460?, 0xc0002087e0?})
dm_1  |     /go/pkg/mod/github.com/a-h/templ@v0.2.648/runtime.go:41 +0x37
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.View({0x85cd78, 0xc0002180a0}, {0x854c60, 0xc0000ca400})
dm_1  |     /src/handlers/routes.go:87 +0x170
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard(0xc00004a0b0, {0x85cd78, 0xc0002180a0})
dm_1  |     /src/handlers/whois.handler.go:38 +0x212
dm_1  | github.com/labstack/echo/v4.(*Echo).add.func1({0x85cd78, 0xc0002180a0})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:582 +0x4b
dm_1  | github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x85cd78, 0xc0002180a0})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/middleware/logger.go:126 +0xd8
dm_1  | github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0000bc248, {0x857048, 0xc0002087e0}, 0xc00019e7e0)
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:669 +0x327
dm_1  | net/http.serverHandler.ServeHTTP({0x8561d0?}, {0x857048?, 0xc0002087e0?}, 0x6?)
dm_1  |     /usr/local/go/src/net/http/server.go:3137 +0x8e
dm_1  | net/http.(*conn).serve(0xc0000cc000, {0x8576d8, 0xc000101c80})
dm_1  |     /usr/local/go/src/net/http/server.go:2039 +0x5e8
dm_1  | created by net/http.(*Server).Serve in goroutine 1
dm_1  |     /usr/local/go/src/net/http/server.go:3285 +0x4b4
dm_1  | echo: http: panic serving 172.18.0.1:45058: runtime error: invalid memory address or nil pointer dereference
dm_1  | goroutine 85 [running]:
dm_1  | net/http.(*conn).serve.func1()
dm_1  |     /usr/local/go/src/net/http/server.go:1898 +0xbe
dm_1  | panic({0x75e600?, 0xa77b50?})
dm_1  |     /usr/local/go/src/runtime/panic.go:770 +0x132
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard.WhoisDetail.func2({0x857710?, 0xc000078690?}, {0x855460, 0xc0002088c0?})
dm_1  |     /src/views/domains/domain-dashboard_templ.go:217 +0x17f
dm_1  | github.com/a-h/templ.ComponentFunc.Render(0xa79070?, {0x857710?, 0xc000078690?}, {0x855460?, 0xc0002088c0?})
dm_1  |     /go/pkg/mod/github.com/a-h/templ@v0.2.648/runtime.go:41 +0x37
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.View({0x85cd78, 0xc000218140}, {0x854c60, 0xc0000ca600})
dm_1  |     /src/handlers/routes.go:87 +0x170
dm_1  | github.com/nwesterhausen/domain-monitor/handlers.(*WhoisHandler).GetCard(0xc00004a0b0, {0x85cd78, 0xc000218140})
dm_1  |     /src/handlers/whois.handler.go:38 +0x212
dm_1  | github.com/labstack/echo/v4.(*Echo).add.func1({0x85cd78, 0xc000218140})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:582 +0x4b
dm_1  | github.com/labstack/echo/v4/middleware.LoggerWithConfig.func2.1({0x85cd78, 0xc000218140})
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/middleware/logger.go:126 +0xd8
dm_1  | github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0000bc248, {0x857048, 0xc0002088c0}, 0xc00019e900)
dm_1  |     /go/pkg/mod/github.com/labstack/echo/v4@v4.11.4/echo.go:669 +0x327
dm_1  | net/http.serverHandler.ServeHTTP({0x8561d0?}, {0x857048?, 0xc0002088c0?}, 0x6?)
dm_1  |     /usr/local/go/src/net/http/server.go:3137 +0x8e
dm_1  | net/http.(*conn).serve(0xc0000cc510, {0x8576d8, 0xc000101c80})
dm_1  |     /usr/local/go/src/net/http/server.go:2039 +0x5e8
dm_1  | created by net/http.(*Server).Serve in goroutine 1
dm_1  |     /usr/local/go/src/net/http/server.go:3285 +0x4b4
dm_1  | {"time":"2024-07-21T12:07:48.977041762Z","id":"","remote_ip":"172.18.0.1","host":"localhost:3124","method":"GET","uri":"/configuration","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0","status":200,"error":"","latency":33073,"latency_human":"33.073µs","bytes_in":0,"bytes_out":0}
dm_1  | {"time":"2024-07-21T12:07:49.026747548Z","id":"","remote_ip":"172.18.0.1","host":"localhost:3124","method":"GET","uri":"/config/app","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0","status":200,"error":"","latency":15721,"latency_human":"15.721µs","bytes_in":0,"bytes_out":0}
dm_1  | {"time":"2024-07-21T12:07:50.15582585Z","id":"","remote_ip":"172.18.0.1","host":"localhost:3124","method":"GET","uri":"/config/domain","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0","status":200,"error":"","latency":16510,"latency_human":"16.51µs","bytes_in":0,"bytes_out":0}
dm_1  | {"time":"2024-07-21T12:07:50.188613656Z","id":"","remote_ip":"172.18.0.1","host":"localhost:3124","method":"GET","uri":"/domain/tbody","user_agent":"Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0","status":200,"error":"","latency":259258,"latency_human":"259.258µs","bytes_in":0,"bytes_out":0}
dm_1  | panic: runtime error: invalid memory address or nil pointer dereference
dm_1  | [signal SIGSEGV: segmentation violation code=0x1 addr=0xd8 pc=0x71fd26]
dm_1  | 
dm_1  | goroutine 45 [running]:
dm_1  | main.domainExpirationCheckOnSchedule({{{0xc0000c0d88, 0x1c, 0x1c}}, {0xc000120a20, 0x1a}}, {{{0xc0000b6d88, 0x1b, 0x1b}}, {0xc000018528, 0x15}}, ...)
dm_1  |     /src/cmd/main.go:127 +0x446
dm_1  | main.main.func2()
dm_1  |     /src/cmd/main.go:102 +0x88
dm_1  | created by time.goFunc
dm_1  |     /usr/local/go/src/time/sleep.go:177 +0x2d

Expected behavior

The domain has no WHOIS records which is a valid situation. For example, when a domain expires!

Version

$ docker image list --digests ghcr.io/nwesterhausen/domain-monitor
REPOSITORY                             TAG       DIGEST                                                                    IMAGE ID       CREATED        SIZE
ghcr.io/nwesterhausen/domain-monitor   1         sha256:0f9de73ee4ff87d23bbaadfcf577fb03751ee98ae2d4d5e8e46652d2edc0d923   20297239a7b5   3 months ago   17.7MB