Implements the full monitoring loop: - Immediate checks on startup, then periodic DNS+port and TLS cycles - Domain NS change detection with notifications - Per-nameserver hostname record tracking with change/failure/recovery and inconsistency detection - TCP port 80/443 monitoring with state change notifications - TLS certificate monitoring with change, expiry, and failure detection - State persistence after each cycle - First run establishes baseline without notifications - Graceful shutdown via context cancellation Defines DNSResolver, PortChecker, TLSChecker, and Notifier interfaces for dependency injection. Updates main.go fx wiring and resolver stub signature to match per-NS record format. Closes #2
71 lines
1.6 KiB
Go
71 lines
1.6 KiB
Go
// Package main is the entry point for dnswatcher.
|
|
package main
|
|
|
|
import (
|
|
"go.uber.org/fx"
|
|
|
|
"sneak.berlin/go/dnswatcher/internal/config"
|
|
"sneak.berlin/go/dnswatcher/internal/globals"
|
|
"sneak.berlin/go/dnswatcher/internal/handlers"
|
|
"sneak.berlin/go/dnswatcher/internal/healthcheck"
|
|
"sneak.berlin/go/dnswatcher/internal/logger"
|
|
"sneak.berlin/go/dnswatcher/internal/middleware"
|
|
"sneak.berlin/go/dnswatcher/internal/notify"
|
|
"sneak.berlin/go/dnswatcher/internal/portcheck"
|
|
"sneak.berlin/go/dnswatcher/internal/resolver"
|
|
"sneak.berlin/go/dnswatcher/internal/server"
|
|
"sneak.berlin/go/dnswatcher/internal/state"
|
|
"sneak.berlin/go/dnswatcher/internal/tlscheck"
|
|
"sneak.berlin/go/dnswatcher/internal/watcher"
|
|
|
|
_ "github.com/joho/godotenv/autoload"
|
|
)
|
|
|
|
// Build-time variables injected by linker flags (-ldflags).
|
|
//
|
|
//nolint:gochecknoglobals // build-time variables
|
|
var (
|
|
Appname = "dnswatcher"
|
|
Version string
|
|
Buildarch string
|
|
)
|
|
|
|
func main() {
|
|
globals.SetAppname(Appname)
|
|
globals.SetVersion(Version)
|
|
globals.SetBuildarch(Buildarch)
|
|
|
|
fx.New(
|
|
fx.Provide(
|
|
globals.New,
|
|
logger.New,
|
|
config.New,
|
|
state.New,
|
|
healthcheck.New,
|
|
resolver.New,
|
|
portcheck.New,
|
|
tlscheck.New,
|
|
notify.New,
|
|
watcher.New,
|
|
middleware.New,
|
|
handlers.New,
|
|
server.New,
|
|
),
|
|
fx.Provide(
|
|
func(r *resolver.Resolver) watcher.DNSResolver {
|
|
return r
|
|
},
|
|
func(p *portcheck.Checker) watcher.PortChecker {
|
|
return p
|
|
},
|
|
func(t *tlscheck.Checker) watcher.TLSChecker {
|
|
return t
|
|
},
|
|
func(n *notify.Service) watcher.Notifier {
|
|
return n
|
|
},
|
|
),
|
|
fx.Invoke(func(*server.Server, *watcher.Watcher) {}),
|
|
).Run()
|
|
}
|