mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-18 02:48:40 +00:00
Move DNS flush logic to net/dns.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
parent
9f7f2af008
commit
6521f02ff6
19
net/dns/flush_windows.go
Normal file
19
net/dns/flush_windows.go
Normal 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
|
||||
}
|
@ -22,8 +22,8 @@ import (
|
||||
"golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
|
||||
"inet.af/netaddr"
|
||||
"tailscale.com/logtail/backoff"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/net/dns"
|
||||
"tailscale.com/types/logger"
|
||||
)
|
||||
|
||||
type winRouter struct {
|
||||
@ -112,11 +112,8 @@ func (r *winRouter) Set(cfg *Config) error {
|
||||
}
|
||||
|
||||
// Flush DNS on router config change to clear cached DNS entries (solves #1430)
|
||||
out, err := exec.Command("ipconfig", "/flushdns").CombinedOutput()
|
||||
if err != nil {
|
||||
r.logf("flushdns error: %v; output: %s", err, out)
|
||||
} else {
|
||||
r.logf("flushdns successful")
|
||||
if err := dns.Flush(); err != nil {
|
||||
r.logf("flushdns error: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
Loading…
x
Reference in New Issue
Block a user