Windows DNS
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
#include "OSUtils.hpp"
|
||||
|
||||
#include "..\windows\TapDriver6\tap-windows.h"
|
||||
#include "WinDNSHelper.hpp"
|
||||
|
||||
#include <netcon.h>
|
||||
|
||||
@@ -473,6 +474,29 @@ WindowsEthernetTap::WindowsEthernetTap(
|
||||
char data[1024];
|
||||
char tag[24];
|
||||
|
||||
// Initialize COM
|
||||
HRESULT hres = CoInitializeEx(0, COINIT_MULTITHREADED);
|
||||
if (FAILED(hres)) {
|
||||
throw std::runtime_error("WinEthernetTap: COM initialization failed");
|
||||
}
|
||||
|
||||
hres = CoInitializeSecurity(
|
||||
NULL,
|
||||
-1,
|
||||
NULL,
|
||||
NULL,
|
||||
RPC_C_AUTHN_LEVEL_DEFAULT,
|
||||
RPC_C_IMP_LEVEL_IMPERSONATE,
|
||||
NULL,
|
||||
EOAC_NONE,
|
||||
NULL
|
||||
);
|
||||
if (FAILED(hres)) {
|
||||
CoUninitialize();
|
||||
throw std::runtime_error("WinEthernetTap: Failed to initialize security");
|
||||
}
|
||||
|
||||
|
||||
// We "tag" registry entries with the network ID to identify persistent devices
|
||||
OSUtils::ztsnprintf(tag,sizeof(tag),"%.16llx",(unsigned long long)nwid);
|
||||
|
||||
@@ -646,6 +670,8 @@ WindowsEthernetTap::WindowsEthernetTap(
|
||||
|
||||
WindowsEthernetTap::~WindowsEthernetTap()
|
||||
{
|
||||
WinDNSHelper::removeDNS(_nwid);
|
||||
CoUninitialize();
|
||||
_run = false;
|
||||
ReleaseSemaphore(_injectSemaphore,1,NULL);
|
||||
Thread::join(_thread);
|
||||
@@ -1292,7 +1318,7 @@ void WindowsEthernetTap::_syncIps()
|
||||
|
||||
void WindowsEthernetTap::setDns(const char* domain, const std::vector<InetAddress>& servers)
|
||||
{
|
||||
|
||||
WinDNSHelper::setDNS(_nwid, domain, servers);
|
||||
}
|
||||
|
||||
} // namespace ZeroTier
|
||||
|
||||
Reference in New Issue
Block a user