mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-20 05:13:58 -07:00
Windows DNS
This commit is contained in:
parent
6868e98904
commit
d9c4e644de
5 changed files with 427 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue