summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2018-05-29 17:51:05 +0200
committerOdd Stranne <odd@mullvad.net>2018-06-18 08:45:13 +0200
commit361827acbed9d30f5a4a957962b15bec83e066a9 (patch)
tree790e5c6b81c7d687f39f17fa1ec353bbd5979b5d
parentba3a6f71e6288884cc4a17aabc8aa139a7a43a87 (diff)
downloadmullvadvpn-361827acbed9d30f5a4a957962b15bec83e066a9.tar.xz
mullvadvpn-361827acbed9d30f5a4a957962b15bec83e066a9.zip
Add proper error check inside SetDnsServers
-rw-r--r--windows/windns/src/windns/netconfighelpers.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/windows/windns/src/windns/netconfighelpers.cpp b/windows/windns/src/windns/netconfighelpers.cpp
index f95dd39ee4..701cfcce6f 100644
--- a/windows/windns/src/windns/netconfighelpers.cpp
+++ b/windows/windns/src/windns/netconfighelpers.cpp
@@ -2,6 +2,9 @@
#include "netconfighelpers.h"
#include "comhelpers.h"
#include "wmi/methodcall.h"
+#include <cstdint>
+#include <sstream>
+#include <stdexcept>
namespace nchelpers
{
@@ -45,11 +48,33 @@ void SetDnsServers(wmi::IConnection &connection, CComPtr<IWbemClassObject> insta
auto status = methodCall.invoke(connection, instance, L"SetDNSServerSearchOrder");
- //
- // TODO check status, (type? expected value?)
- //
+ const uint32_t STATUS_SUCCESS_NO_REBOOT_REQUIRED = 0;
- return;
+ if (STATUS_SUCCESS_NO_REBOOT_REQUIRED == V_UI4(&status))
+ {
+ return;
+ }
+
+ std::string msg("Unable to update adapter configuration with new DNS servers");
+
+ try
+ {
+ auto configIndex = ComGetPropertyAlways(instance, L"Index");
+ auto interfaceIndex = ComGetPropertyAlways(instance, L"InterfaceIndex");
+
+ std::stringstream ss;
+
+ ss << "Unable to update adapter with interfaceIndex = " << V_UI4(&interfaceIndex) \
+ << ", configuration index = " << V_UI4(&configIndex) \
+ << " with new DNS servers. Error: " << V_UI4(&status);
+
+ msg = ss.str();
+ }
+ catch (...)
+ {
+ }
+
+ throw std::runtime_error(msg);
}
}