aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tunnel
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2020-11-27 13:36:25 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-11-27 13:36:25 +0100
commit2d4feb2c7bf951024cdb04a0daa8695f7202bee0 (patch)
treecb25ac8e663347b728b47f2152f3e9e27d3ca0a0 /tunnel
parentconf: separate out migration and print errors (diff)
downloadwireguard-windows-2d4feb2c7bf951024cdb04a0daa8695f7202bee0.tar.xz
wireguard-windows-2d4feb2c7bf951024cdb04a0daa8695f7202bee0.zip
winipcfg: cleanup netsh error reporting
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--tunnel/winipcfg/netsh.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/tunnel/winipcfg/netsh.go b/tunnel/winipcfg/netsh.go
index 3f273987..780c7fc1 100644
--- a/tunnel/winipcfg/netsh.go
+++ b/tunnel/winipcfg/netsh.go
@@ -37,16 +37,15 @@ func runNetsh(cmds []string) error {
io.WriteString(stdin, strings.Join(append(cmds, "exit\r\n"), "\r\n"))
}()
output, err := cmd.CombinedOutput()
- if err != nil {
- return fmt.Errorf("runNetsh run - %w", err)
- }
// Horrible kludges, sorry.
- cleaned := bytes.ReplaceAll(output, []byte("netsh>"), []byte{})
+ cleaned := bytes.ReplaceAll(output, []byte{'\r', '\n'}, []byte{'\n'})
+ cleaned = bytes.ReplaceAll(cleaned, []byte("netsh>"), []byte{})
cleaned = bytes.ReplaceAll(cleaned, []byte("There are no Domain Name Servers (DNS) configured on this computer."), []byte{})
cleaned = bytes.TrimSpace(cleaned)
- if len(cleaned) != 0 {
- return fmt.Errorf("runNetsh returned error strings.\ninput:\n%s\noutput\n:%s",
- strings.Join(cmds, "\n"), bytes.ReplaceAll(output, []byte{'\r', '\n'}, []byte{'\n'}))
+ if len(cleaned) != 0 && err == nil {
+ return fmt.Errorf("netsh: %#q", string(cleaned))
+ } else if err != nil {
+ return fmt.Errorf("netsh: %v: %#q", err, string(cleaned))
}
return nil
}