mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
@@ -9,6 +9,8 @@ import (
|
|||||||
"net/netip"
|
"net/netip"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/fosrl/newt/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -209,11 +211,14 @@ func (d *DarwinDNSConfigurator) parseServerAddresses(output []byte) []netip.Addr
|
|||||||
|
|
||||||
// flushDNSCache flushes the system DNS cache
|
// flushDNSCache flushes the system DNS cache
|
||||||
func (d *DarwinDNSConfigurator) flushDNSCache() error {
|
func (d *DarwinDNSConfigurator) flushDNSCache() error {
|
||||||
|
logger.Debug("Flushing dscacheutil cache")
|
||||||
cmd := exec.Command(dscacheutilPath, "-flushcache")
|
cmd := exec.Command(dscacheutilPath, "-flushcache")
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
return fmt.Errorf("flush cache: %w", err)
|
return fmt.Errorf("flush cache: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Debug("Flushing mDNSResponder cache")
|
||||||
|
|
||||||
cmd = exec.Command("killall", "-HUP", "mDNSResponder")
|
cmd = exec.Command("killall", "-HUP", "mDNSResponder")
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
// Non-fatal, mDNSResponder might not be running
|
// Non-fatal, mDNSResponder might not be running
|
||||||
@@ -228,6 +233,8 @@ func (d *DarwinDNSConfigurator) runScutil(commands string) ([]byte, error) {
|
|||||||
// Wrap commands with open/quit
|
// Wrap commands with open/quit
|
||||||
wrapped := fmt.Sprintf("open\n%squit\n", commands)
|
wrapped := fmt.Sprintf("open\n%squit\n", commands)
|
||||||
|
|
||||||
|
logger.Debug("Running scutil with commands:\n%s\n", wrapped)
|
||||||
|
|
||||||
cmd := exec.Command(scutilPath)
|
cmd := exec.Command(scutilPath)
|
||||||
cmd.Stdin = strings.NewReader(wrapped)
|
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)
|
return nil, fmt.Errorf("scutil command failed: %w, output: %s", err, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Debug("scutil output:\n%s\n", output)
|
||||||
|
|
||||||
return output, nil
|
return output, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user