mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-21 13:54:15 -07:00
Merge branch 'master' into cmake
This commit is contained in:
commit
c2f9aab068
86 changed files with 4809 additions and 5863 deletions
|
@ -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;
|
||||
|
@ -850,6 +850,10 @@ void LinuxNetLink::addAddress(const InetAddress &addr, const char *iface)
|
|||
#endif
|
||||
|
||||
int interface_index = _indexForInterface(iface);
|
||||
for (int reps = 0; interface_index == -1 && reps < 10; ++reps) {
|
||||
Thread::sleep(100);
|
||||
interface_index = _indexForInterface(iface);
|
||||
}
|
||||
|
||||
if (interface_index == -1) {
|
||||
fprintf(stderr, "Unable to find index for interface %s\n", iface);
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -39,10 +39,6 @@
|
|||
#include "../node/MAC.hpp"
|
||||
#include "Thread.hpp"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
namespace ZeroTier {
|
||||
|
||||
class NetBSDEthernetTap
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue