summaryrefslogtreecommitdiffhomepage
path: root/windows/windns/src/extras/loader
diff options
context:
space:
mode:
authorOdd Stranne <odd@mullvad.net>2019-09-03 22:55:20 +0200
committerOdd Stranne <odd@mullvad.net>2019-09-05 10:19:07 +0200
commite2ef1227283c252ec5a7190ed9b4bd278405fa9b (patch)
treecbfaaf2b21f06b36c09d659d924b05b2bd89ba0a /windows/windns/src/extras/loader
parenteb6802418f9c82a2093d0c7027159ef85ab40654 (diff)
downloadmullvadvpn-e2ef1227283c252ec5a7190ed9b4bd278405fa9b.tar.xz
mullvadvpn-e2ef1227283c252ec5a7190ed9b4bd278405fa9b.zip
Remove monitoring logic in DNS code
Diffstat (limited to 'windows/windns/src/extras/loader')
-rw-r--r--windows/windns/src/extras/loader/loader.cpp94
1 files changed, 1 insertions, 93 deletions
diff --git a/windows/windns/src/extras/loader/loader.cpp b/windows/windns/src/extras/loader/loader.cpp
index 5c6603c3dd..b20b4336b0 100644
--- a/windows/windns/src/extras/loader/loader.cpp
+++ b/windows/windns/src/extras/loader/loader.cpp
@@ -27,86 +27,12 @@ void WINDNS_API LogSink(WinDnsLogCategory category, const char *message, const c
}
}
-void WINDNS_API RecoverySink(const void *recoveryData, uint32_t dataLength, void *context)
-{
- std::wcout << L"Updated recovery data was delivered to WINDNS client code" << std::endl;
-
- auto f = CreateFileW(L"windns_recovery", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, 0, nullptr);
-
- if (INVALID_HANDLE_VALUE == f)
- {
- std::wcout << L"Failed to create recovery file" << std::endl;
- return;
- }
-
- if (FALSE == WriteFile(f, recoveryData, dataLength, nullptr, nullptr))
- {
- std::wcout << L"Failed to update recovery file" << std::endl;
- }
-
- CloseHandle(f);
-}
-
-void Recover()
-{
- auto f = CreateFileW(L"windns_recovery", GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
-
- if (INVALID_HANDLE_VALUE == f)
- {
- std::wcout << L"Failed to open recovery file" << std::endl;
- return;
- }
-
- std::vector<uint8_t> data;
-
- data.resize(GetFileSize(f, nullptr));
-
- if (FALSE == ReadFile(f, &data[0], static_cast<DWORD>(data.size()), nullptr, nullptr))
- {
- std::wcout << L"Failed to read in recovery data" << std::endl;
- CloseHandle(f);
-
- return;
- }
-
- std::wcout << L"WinDns_Recover: " << std::boolalpha <<
- WinDns_Recover(&data[0], static_cast<uint32_t>(data.size())) << std::endl;
-}
-
-bool Ask(const std::wstring &question)
-{
- std::wcout << question.c_str() << L" Y/N: ";
-
- auto answer = _getwch();
-
- std::wcout << std::endl;
-
- if ('y' == answer || 'Y' == answer)
- {
- return true;
- }
-
- return false;
-}
-
-void WaitInput(const std::wstring &message)
-{
- std::wcout << message.c_str() << std::endl;
- _getwch();
-}
-
int main()
{
common::trace::Trace::RegisterSink(new common::trace::ConsoleTraceSink);
std::wcout << L"WinDns_Initialize: " << std::boolalpha << WinDns_Initialize(LogSink, nullptr) << std::endl;
- if (Ask(L"Perform recovery?"))
- {
- Recover();
- return 0;
- }
-
const wchar_t *servers[] =
{
L"8.8.8.8",
@@ -119,28 +45,10 @@ int main()
L"2001:4860:4860::8844"
};
- auto status = WinDns_Set(servers, _countof(servers), v6Servers, _countof(v6Servers), RecoverySink, nullptr);
-
- std::wcout << L"WinDns_Set: " << std::boolalpha << status << std::endl;
-
- WaitInput(L"Press a key to abort DNS monitoring + enforcing...");
-
- if (Ask(L"Perform WinDns_Reset() before next WinDns_Set()?"))
- {
- std::wcout << L"WinDns_Reset: " << std::boolalpha << WinDns_Reset() << std::endl;
- }
-
- status = WinDns_Set(servers, _countof(servers), v6Servers, _countof(v6Servers), RecoverySink, nullptr);
+ auto status = WinDns_Set(L"Wi-Fi", servers, _countof(servers), v6Servers, _countof(v6Servers));
std::wcout << L"WinDns_Set: " << std::boolalpha << status << std::endl;
- WaitInput(L"Press a key to abort DNS monitoring + enforcing...");
-
- if (Ask(L"Perform WinDns_Reset() before WinDns_Deinitialize()?"))
- {
- std::wcout << L"WinDns_Reset: " << std::boolalpha << WinDns_Reset() << std::endl;
- }
-
std::wcout << L"WinDns_Deinitialize: " << std::boolalpha << WinDns_Deinitialize() << std::endl;
return 0;