Merge dev to edge

This commit is contained in:
Adam Ierymenko 2019-08-06 14:13:07 -05:00
commit f9900cc6fb
No known key found for this signature in database
GPG key ID: 1657198823E52A61
50 changed files with 4563 additions and 624 deletions

View file

@ -124,9 +124,9 @@ int LinuxNetLink::_doRecv(int fd)
if(nlp->nlmsg_type == NLMSG_ERROR && (nlp->nlmsg_flags & NLM_F_ACK) != NLM_F_ACK) {
struct nlmsgerr *err = (struct nlmsgerr*)NLMSG_DATA(nlp);
if (err->error != 0) {
//#ifdef ZT_TRACE
fprintf(stderr, "rtnetlink error: %s\n", strerror(-(err->error)));
//#endif
#ifdef ZT_TRACE
//fprintf(stderr, "rtnetlink error: %s\n", strerror(-(err->error)));
#endif
}
p = buf;
nll = 0;

View file

@ -165,6 +165,7 @@ MacEthernetTap::MacEthernetTap(
break;
}
}
_dev = devstr;
if (::pipe(_shutdownSignalPipe))
throw std::runtime_error("pipe creation failed");
@ -285,7 +286,7 @@ std::vector<InetAddress> MacEthernetTap::ips() const
if (!getifaddrs(&ifa)) {
struct ifaddrs *p = ifa;
while (p) {
if ((!strcmp(p->ifa_name,_dev.c_str()))&&(p->ifa_addr)&&(p->ifa_netmask)&&(p->ifa_addr->sa_family == p->ifa_netmask->sa_family)) {
if ((p->ifa_name)&&(!strcmp(p->ifa_name,_dev.c_str()))&&(p->ifa_addr)) {
switch(p->ifa_addr->sa_family) {
case AF_INET: {
struct sockaddr_in *sin = (struct sockaddr_in *)p->ifa_addr;
@ -361,7 +362,7 @@ void MacEthernetTap::scanMulticastGroups(std::vector<MulticastGroup> &added,std:
newGroups.push_back(MulticastGroup::deriveMulticastGroupForAddressResolution(*ip));
std::sort(newGroups.begin(),newGroups.end());
std::unique(newGroups.begin(),newGroups.end());
newGroups.erase(std::unique(newGroups.begin(),newGroups.end()),newGroups.end());
for(std::vector<MulticastGroup>::iterator m(newGroups.begin());m!=newGroups.end();++m) {
if (!std::binary_search(_multicastGroups.begin(),_multicastGroups.end(),*m))

View file

@ -399,10 +399,6 @@ std::string OSUtils::platformDefaultHomePath()
return homeDir;
#endif
#ifdef __SYNOLOGY__
return std::string("/var/packages/zerotier/target/var");
#endif
// Check for user-defined environment variable before using defaults
#ifdef __WINDOWS__
DWORD bufferSize = 65535;

View file

@ -58,6 +58,8 @@
#include "..\windows\TapDriver6\tap-windows.h"
#include <netcon.h>
// Create a fake unused default route to force detection of network type on networks without gateways
#define ZT_WINDOWS_CREATE_FAKE_DEFAULT_ROUTE
@ -824,6 +826,61 @@ void WindowsEthernetTap::setFriendlyName(const char *dn)
RegSetKeyValueA(ifp,"Connection","Name",REG_SZ,(LPCVOID)dn,(DWORD)(strlen(dn)+1));
RegCloseKey(ifp);
}
HRESULT hr = CoInitialize(nullptr);
if (hr != S_OK) return;
CoInitializeSecurity(NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_PKT,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL, EOAC_NONE, NULL);
if (hr != S_OK) return;
INetSharingManager *nsm;
hr = CoCreateInstance(__uuidof(NetSharingManager), NULL, CLSCTX_ALL, __uuidof(INetSharingManager), (void**)&nsm);
if (hr != S_OK) return;
bool found = false;
INetSharingEveryConnectionCollection *nsecc = nullptr;
hr = nsm->get_EnumEveryConnection(&nsecc);
if (!nsecc) {
fprintf(stderr, "Failed to get NSM connections");
return;
}
IEnumVARIANT *ev = nullptr;
IUnknown *unk = nullptr;
hr = nsecc->get__NewEnum(&unk);
if (unk) {
hr = unk->QueryInterface(__uuidof(IEnumVARIANT), (void**)&ev);
unk->Release();
}
if (ev) {
VARIANT v;
VariantInit(&v);
while ((S_OK == ev->Next(1, &v, NULL)) && found == FALSE) {
if (V_VT(&v) == VT_UNKNOWN) {
INetConnection *nc = nullptr;
V_UNKNOWN(&v)->QueryInterface(__uuidof(INetConnection), (void**)&nc);
if (nc) {
NETCON_PROPERTIES *ncp = nullptr;
nc->GetProperties(&ncp);
GUID curId = ncp->guidId;
if (curId == _deviceGuid) {
wchar_t wtext[255];
mbstowcs(wtext, dn, strlen(dn)+1);
nc->Rename(wtext);
found = true;
}
nc->Release();
}
}
VariantClear(&v);
}
ev->Release();
}
nsecc->Release();
}
void WindowsEthernetTap::scanMulticastGroups(std::vector<MulticastGroup> &added,std::vector<MulticastGroup> &removed)