mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-13 22:12:56 +00:00
Add new .h file to VS build, and Windows side of local interface address enumeration.
This commit is contained in:
parent
84ba365c77
commit
f881cdd767
@ -899,13 +899,17 @@ bool IncomingPacket::_doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const Sha
|
||||
switch(addrType) {
|
||||
case 4: {
|
||||
InetAddress a(field(ptr,4),4,at<uint16_t>(ptr + 4));
|
||||
if ((flags & (0x01 | 0x02)) == 0)
|
||||
if ((flags & (0x01 | 0x02)) == 0) {
|
||||
printf("contacting %s at %s\r\n",peer->address().toString().c_str(),a.toString().c_str());
|
||||
peer->attemptToContactAt(RR,a,RR->node->now());
|
||||
}
|
||||
} break;
|
||||
case 6: {
|
||||
InetAddress a(field(ptr,16),16,at<uint16_t>(ptr + 16));
|
||||
if ((flags & (0x01 | 0x02)) == 0)
|
||||
if ((flags & (0x01 | 0x02)) == 0) {
|
||||
printf("contacting %s at %s\r\n",peer->address().toString().c_str(),a.toString().c_str());
|
||||
peer->attemptToContactAt(RR,a,RR->node->now());
|
||||
}
|
||||
} break;
|
||||
}
|
||||
ptr += addrLen;
|
||||
|
@ -75,7 +75,11 @@ class SqliteNetworkController;
|
||||
#endif // ZT_ENABLE_NETWORK_CONTROLLER
|
||||
|
||||
#ifdef __WINDOWS__
|
||||
#include <WinSock2.h>
|
||||
#include <Windows.h>
|
||||
#include <ShlObj.h>
|
||||
#include <netioapi.h>
|
||||
#include <iphlpapi.h>
|
||||
#else
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
@ -614,10 +618,45 @@ public:
|
||||
{
|
||||
Mutex::Lock _l(_taps_m);
|
||||
for(std::map< uint64_t,EthernetTap *>::const_iterator t(_taps.begin());t!=_taps.end();++t)
|
||||
ztDevices.push_back(t->second->deviceName());
|
||||
ztDevices.push_back(t->second->luid());
|
||||
}
|
||||
|
||||
// TODO
|
||||
char aabuf[16384];
|
||||
ULONG aalen = sizeof(aabuf);
|
||||
if (GetAdaptersAddresses(AF_UNSPEC,GAA_FLAG_SKIP_ANYCAST|GAA_FLAG_SKIP_MULTICAST|GAA_FLAG_SKIP_DNS_SERVER,(void *)0,reinterpret_cast<PIP_ADAPTER_ADDRESSES>(aabuf),&aalen) == NO_ERROR) {
|
||||
PIP_ADAPTER_ADDRESSES a = reinterpret_cast<PIP_ADAPTER_ADDRESSES>(aabuf);
|
||||
while (a) {
|
||||
bool isZT = false;
|
||||
for(std::vector<NET_LUID>::const_iterator d(ztDevices.begin());d!=ztDevices.end();++d) {
|
||||
if (a->Luid.Value == d->Value) {
|
||||
isZT = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isZT) {
|
||||
PIP_ADAPTER_UNICAST_ADDRESS ua = a->FirstUnicastAddress;
|
||||
while (ua) {
|
||||
InetAddress ip(ua->Address.lpSockaddr);
|
||||
if ((ip.ss_family == AF_INET)||(ip.ss_family == AF_INET6)) {
|
||||
switch(ip.ipScope()) {
|
||||
case InetAddress::IP_SCOPE_LINK_LOCAL:
|
||||
case InetAddress::IP_SCOPE_PRIVATE:
|
||||
case InetAddress::IP_SCOPE_PSEUDOPRIVATE:
|
||||
case InetAddress::IP_SCOPE_SHARED:
|
||||
case InetAddress::IP_SCOPE_GLOBAL:
|
||||
ip.setPort(_port);
|
||||
_node->addLocalInterfaceAddress(reinterpret_cast<const struct sockaddr_storage *>(&ip),0,ZT1_LOCAL_INTERFACE_ADDRESS_TRUST_NORMAL,0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
ua = ua->Next;
|
||||
}
|
||||
}
|
||||
a = a->Next;
|
||||
}
|
||||
}
|
||||
#endif // __WINDOWS__
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,7 @@
|
||||
<ClInclude Include="..\..\node\Path.hpp" />
|
||||
<ClInclude Include="..\..\node\Peer.hpp" />
|
||||
<ClInclude Include="..\..\node\Poly1305.hpp" />
|
||||
<ClInclude Include="..\..\node\RemotePath.hpp" />
|
||||
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp" />
|
||||
<ClInclude Include="..\..\node\Salsa20.hpp" />
|
||||
<ClInclude Include="..\..\node\SelfAwareness.hpp" />
|
||||
|
@ -344,6 +344,9 @@
|
||||
<ClInclude Include="..\..\osdep\BackgroundResolver.hpp">
|
||||
<Filter>Header Files\osdep</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\RemotePath.hpp">
|
||||
<Filter>Header Files\node</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ZeroTierOne.rc">
|
||||
|
Loading…
x
Reference in New Issue
Block a user