diff options
| author | David Lönnhager <david.l@mullvad.net> | 2021-11-19 14:40:00 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2021-11-22 17:15:33 +0100 |
| commit | f1f2e0c44d570f80502e3aaff5368d81fcb6f4f6 (patch) | |
| tree | 58ca253e7fff1666f77dbb7e1a01202107503523 | |
| parent | 7934fc4d20c9d220b626fd14229cc0469fcbbfc6 (diff) | |
| download | mullvadvpn-f1f2e0c44d570f80502e3aaff5368d81fcb6f4f6.tar.xz mullvadvpn-f1f2e0c44d570f80502e3aaff5368d81fcb6f4f6.zip | |
Compare interfaces using their LUIDs instead of aliases
| -rw-r--r-- | windows/windns/src/windns/windns.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/windows/windns/src/windns/windns.cpp b/windows/windns/src/windns/windns.cpp index b48ca6f163..26532f00e8 100644 --- a/windows/windns/src/windns/windns.cpp +++ b/windows/windns/src/windns/windns.cpp @@ -94,9 +94,17 @@ AdapterDnsAddresses GetAdapterDnsAddresses(const std::wstring &adapterAlias) GAA_FLAG_SKIP_UNICAST | GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST ); + NET_LUID luid; + if (NO_ERROR != ConvertInterfaceAliasToLuid(adapterAlias.c_str(), &luid)) + { + const auto err = std::wstring(L"Could not resolve LUID of interface: \"") + .append(adapterAlias).append(L"\""); + THROW_ERROR(common::string::ToAnsi(err).c_str()); + } + for (const auto adapter : adapters) { - if (0 != _wcsicmp(adapter.alias().c_str(), adapterAlias.c_str())) + if (luid.Value != adapter.raw().Luid.Value) { continue; } |
