From cea9ab0932d363d5251b8862d84a4696a1592db4 Mon Sep 17 00:00:00 2001 From: Owen Date: Sun, 30 Nov 2025 14:28:25 -0500 Subject: [PATCH] Add some logging Former-commit-id: 5d129b4fce865fb9b303d250a3e1cc16da73e1d8 --- dns/platform/darwin.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dns/platform/darwin.go b/dns/platform/darwin.go index bbcedcf..0b853f5 100644 --- a/dns/platform/darwin.go +++ b/dns/platform/darwin.go @@ -9,6 +9,8 @@ import ( "net/netip" "os/exec" "strings" + + "github.com/fosrl/newt/logger" ) const ( @@ -209,11 +211,14 @@ func (d *DarwinDNSConfigurator) parseServerAddresses(output []byte) []netip.Addr // flushDNSCache flushes the system DNS cache func (d *DarwinDNSConfigurator) flushDNSCache() error { + logger.Debug("Flushing dscacheutil cache") cmd := exec.Command(dscacheutilPath, "-flushcache") if err := cmd.Run(); err != nil { return fmt.Errorf("flush cache: %w", err) } + logger.Debug("Flushing mDNSResponder cache") + cmd = exec.Command("killall", "-HUP", "mDNSResponder") if err := cmd.Run(); err != nil { // Non-fatal, mDNSResponder might not be running @@ -228,6 +233,8 @@ func (d *DarwinDNSConfigurator) runScutil(commands string) ([]byte, error) { // Wrap commands with open/quit wrapped := fmt.Sprintf("open\n%squit\n", commands) + logger.Debug("Running scutil with commands:\n%s\n", wrapped) + cmd := exec.Command(scutilPath) cmd.Stdin = strings.NewReader(wrapped) @@ -236,5 +243,7 @@ func (d *DarwinDNSConfigurator) runScutil(commands string) ([]byte, error) { return nil, fmt.Errorf("scutil command failed: %w, output: %s", err, output) } + logger.Debug("scutil output:\n%s\n", output) + return output, nil }