mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-30 05:25:35 +00:00
93c2882a2f
Windows has a public dns.Flush used in router_windows.go. However that won't work for platforms like Linux, where we need a different flush mechanism for resolved versus other implementations. We're instead adding a FlushCaches method to the dns Manager, which can be made to work on all platforms as needed. Fixes https://github.com/tailscale/tailscale/issues/2132 Signed-off-by: Denton Gentry <dgentry@tailscale.com>
29 lines
738 B
Go
29 lines
738 B
Go
// 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"
|
|
)
|
|
|
|
func flushCaches() error {
|
|
out, err := exec.Command("ipconfig", "/flushdns").CombinedOutput()
|
|
if err != nil {
|
|
return fmt.Errorf("%v (output: %s)", err, out)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// 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()
|
|
}
|