aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tunnel/winipcfg
diff options
context:
space:
mode:
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
}