aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2021-08-10 00:15:44 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2021-08-10 02:30:33 +0200
commit688876ff6361126b042b027e7f283f22f02e1a7e (patch)
tree8f3b7bdbe2812d2ad6da65570554d51260802787
parentembeddable-dll-service: csharp: update for wgnt (diff)
downloadwireguard-windows-688876ff6361126b042b027e7f283f22f02e1a7e.tar.xz
wireguard-windows-688876ff6361126b042b027e7f283f22f02e1a7e.zip
tunnel: provide better logging for when iphlpapi fails
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
-rw-r--r--services/errors.go2
-rw-r--r--tunnel/addressconfig.go12
-rw-r--r--tunnel/interfacewatcher.go3
3 files changed, 12 insertions, 5 deletions
diff --git a/services/errors.go b/services/errors.go
index 8986ebcb..e4fcc77d 100644
--- a/services/errors.go
+++ b/services/errors.go
@@ -61,7 +61,7 @@ func (e Error) Error() string {
case ErrorMonitorMTUChanges:
return "Unable to monitor default route MTU for changes"
case ErrorSetNetConfig:
- return "Unable to set interface addresses, routes, dns, and/or interface settings"
+ return "Unable to configure adapter network settings"
case ErrorTrackTunnels:
return "Unable to track existing tunnels"
case ErrorEnumerateSessions:
diff --git a/tunnel/addressconfig.go b/tunnel/addressconfig.go
index fba7d770..74ad75b3 100644
--- a/tunnel/addressconfig.go
+++ b/tunnel/addressconfig.go
@@ -7,6 +7,7 @@ package tunnel
import (
"bytes"
+ "fmt"
"log"
"net"
"sort"
@@ -105,7 +106,7 @@ func configureInterface(family winipcfg.AddressFamily, conf *conf.Config, luid w
err = luid.SetIPAddressesForFamily(family, addresses)
}
if err != nil {
- return err
+ return fmt.Errorf("unable to set ips %v: %w", addresses, err)
}
deduplicatedRoutes := make([]*winipcfg.RouteData, 0, len(routes))
@@ -137,6 +138,7 @@ func configureInterface(family winipcfg.AddressFamily, conf *conf.Config, luid w
if !conf.Interface.TableOff {
err = luid.SetRoutesForFamily(family, deduplicatedRoutes)
if err != nil {
+ return fmt.Errorf("unable to set routes %v: %w", deduplicatedRoutes, err)
return err
}
}
@@ -166,10 +168,14 @@ func configureInterface(family winipcfg.AddressFamily, conf *conf.Config, luid w
}
err = ipif.Set()
if err != nil {
- return err
+ return fmt.Errorf("unable to set metric and MTU: %w", err)
}
- return luid.SetDNS(family, conf.Interface.DNS, conf.Interface.DNSSearch)
+ err = luid.SetDNS(family, conf.Interface.DNS, conf.Interface.DNSSearch)
+ if err != nil {
+ return fmt.Errorf("unable to set DNS %v %v: %w", conf.Interface.DNS, conf.Interface.DNSSearch, err)
+ }
+ return nil
}
func enableFirewall(conf *conf.Config, luid winipcfg.LUID) error {
diff --git a/tunnel/interfacewatcher.go b/tunnel/interfacewatcher.go
index 32132e93..1abc021d 100644
--- a/tunnel/interfacewatcher.go
+++ b/tunnel/interfacewatcher.go
@@ -6,6 +6,7 @@
package tunnel
import (
+ "fmt"
"log"
"sync"
@@ -145,7 +146,7 @@ func watchInterface() (*interfaceWatcher, error) {
iw.setup(iface.Family)
})
if err != nil {
- return nil, err
+ return nil, fmt.Errorf("unable to register interface change callback: %w", err)
}
return iw, nil
}