2021-03-26 00:40:52 +00:00
|
|
|
// Copyright (c) 2021 Tailscale Inc & AUTHORS All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package dns
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os/exec"
|
|
|
|
)
|
|
|
|
|
2021-09-19 03:33:21 +00:00
|
|
|
func flushCaches() error {
|
2021-03-26 00:40:52 +00:00
|
|
|
out, err := exec.Command("ipconfig", "/flushdns").CombinedOutput()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("%v (output: %s)", err, out)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2021-09-19 03:33:21 +00:00
|
|
|
|
|
|
|
// Flush clears the local resolver cache.
|
|
|
|
//
|
|
|
|
// Only Windows has a public dns.Flush, needed in router_windows.go. Other
|
|
|
|
// platforms like Linux need a different flush implementation depending on
|
|
|
|
// the DNS manager. There is a FlushCaches method on the manager which
|
|
|
|
// can be used on all platforms.
|
|
|
|
func Flush() error {
|
|
|
|
return flushCaches()
|
|
|
|
}
|