From b7359e1d45f505171356bcae3c7d5e2341ecc859 Mon Sep 17 00:00:00 2001 From: radhitya Date: Sun, 21 Jun 2026 09:48:42 +0700 Subject: forward mode, cache opt, ACL, rate limit, admin/health, systemd, fix UDP reply --- main.go | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index ecba31d..9a341fb 100644 --- a/main.go +++ b/main.go @@ -2,18 +2,18 @@ package main import ( "context" - "log/slog" - "time" - "os" - "os/signal" - "path/filepath" - "syscall" "fmt" "linum/internal/blocklist" "linum/internal/cache" "linum/internal/config" "linum/internal/resolver" "linum/internal/server" + "log/slog" + "os" + "os/signal" + "path/filepath" + "syscall" + "time" ) func main() { @@ -41,7 +41,7 @@ func main() { slog.SetDefault(logger) fmt.Println("linum - simple dns recursive") - fmt.Printf("github.com/radhityax/linum\n\n") + fmt.Printf("codeberg.org/radhitya/linum\n\n") logger.Info("config loaded", "file", flags.Config) @@ -101,22 +101,26 @@ func main() { ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer stop() - srv, err := server.New(cfg.Server.ListenUDP, cfg.Server.ListenTCP, cfg.Server.ListenDOH, logger, r, c, bl) + srv, err := server.New(cfg.Server.ListenUDP, cfg.Server.ListenTCP, cfg.Server.ListenDOH, logger, r, c, bl, cfg) if err != nil { logger.Error("create server failed", "err", err) os.Exit(1) } defer srv.Close() + if cfg.Admin.Listen != "" { + logger.Info("admin server configured", "addr", cfg.Admin.Listen) + } + logger.Info("linum starting", - "udp", cfg.Server.ListenUDP, - "tcp", cfg.Server.ListenTCP, - "doh", cfg.Server.ListenDOH, -) + "udp", cfg.Server.ListenUDP, + "tcp", cfg.Server.ListenTCP, + "doh", cfg.Server.ListenDOH, + ) -if err := srv.Run(ctx); err != nil && err != context.Canceled { - logger.Error("server stopped with error", "err", err) - os.Exit(1) -} -logger.Info("linum stopped cleanly") + if err := srv.Run(ctx); err != nil && err != context.Canceled { + logger.Error("server stopped with error", "err", err) + os.Exit(1) + } + logger.Info("linum stopped cleanly") } -- cgit v1.2.3