Move DNS flush logic to net/dns.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson
2021-03-25 17:40:52 -07:00
parent 9f7f2af008
commit 6521f02ff6
2 changed files with 22 additions and 6 deletions

19
net/dns/flush_windows.go Normal file
View File

@@ -0,0 +1,19 @@
// 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"
)
// Flush clears the local resolver cache.
func Flush() error {
out, err := exec.Command("ipconfig", "/flushdns").CombinedOutput()
if err != nil {
return fmt.Errorf("%v (output: %s)", err, out)
}
return nil
}