wgengine/netstack: check userspace ping success on Windows

Hacky temporary workaround until we do #13654 correctly.

Updates #13654

Change-Id: I764eaedbb112fb3a34dddb89572fec1b2543fd4a
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
Brad Fitzpatrick
2024-10-02 10:01:46 -07:00
committed by Brad Fitzpatrick
parent 1f8eea53a8
commit 5f88b65764
3 changed files with 118 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
package netstack
import (
"errors"
"net/netip"
"os"
"os/exec"
@@ -26,7 +27,13 @@ func (ns *Impl) sendOutboundUserPing(dstIP netip.Addr, timeout time.Duration) er
var err error
switch runtime.GOOS {
case "windows":
err = exec.Command("ping", "-n", "1", "-w", "3000", dstIP.String()).Run()
var out []byte
out, err = exec.Command("ping", "-n", "1", "-w", "3000", dstIP.String()).CombinedOutput()
if err == nil && !windowsPingOutputIsSuccess(dstIP, out) {
// TODO(bradfitz,nickkhyl): return the actual ICMP error we heard back to the caller?
// For now we just drop it.
err = errors.New("unsuccessful ICMP reply received")
}
case "freebsd":
// Note: 2000 ms is actually 1 second + 2,000
// milliseconds extra for 3 seconds total.