diff options
-rwxr-xr-x | .gitignore | 2 | ||||
-rw-r--r-- | node/BandwidthAccount.hpp | 4 | ||||
-rw-r--r-- | node/C25519.cpp | 4 | ||||
-rw-r--r-- | node/Constants.hpp | 2 | ||||
-rw-r--r-- | node/EthernetTap.cpp | 2 | ||||
-rw-r--r-- | node/HttpClient.cpp | 36 | ||||
-rw-r--r-- | node/NetworkConfig.hpp | 4 | ||||
-rw-r--r-- | node/NodeConfig.cpp | 6 | ||||
-rw-r--r-- | node/Packet.cpp | 2 | ||||
-rw-r--r-- | node/Packet.hpp | 2 | ||||
-rw-r--r-- | node/PacketDecoder.cpp | 2 | ||||
-rw-r--r-- | node/Poly1305.cpp | 5 | ||||
-rw-r--r-- | node/Utils.cpp | 4 | ||||
-rw-r--r-- | windows/SelfTest/SelfTest.vcxproj | 1 | ||||
-rw-r--r-- | windows/SelfTest/SelfTest.vcxproj.filters | 3 |
15 files changed, 53 insertions, 26 deletions
@@ -34,3 +34,5 @@ *.autosave /ZeroTier One.zip /ZeroTier One.dmg +/windows/ZeroTierOne.sdf +/windows/ZeroTierOne.v11.suo diff --git a/node/BandwidthAccount.hpp b/node/BandwidthAccount.hpp index 98c7dd20..0eb527d6 100644 --- a/node/BandwidthAccount.hpp +++ b/node/BandwidthAccount.hpp @@ -34,6 +34,10 @@ #include "Constants.hpp" #include "Utils.hpp" +#ifdef __WINDOWS__ +#define round(x) ((x-floor(x))>0.5 ? ceil(x) : floor(x)) +#endif + namespace ZeroTier { /** diff --git a/node/C25519.cpp b/node/C25519.cpp index 3a3b3704..8c7b89c8 100644 --- a/node/C25519.cpp +++ b/node/C25519.cpp @@ -18,6 +18,10 @@ Derived from public domain code by D. J. Bernstein. #include "SHA512.hpp" #include "Buffer.hpp" +#ifdef __WINDOWS__ +#pragma warning(disable: 4146) +#endif + namespace ZeroTier { ////////////////////////////////////////////////////////////////////////////// diff --git a/node/Constants.hpp b/node/Constants.hpp index 20983db9..66ce7edf 100644 --- a/node/Constants.hpp +++ b/node/Constants.hpp @@ -77,6 +77,8 @@ #define ZT_PATH_SEPARATOR '\\' #define ZT_PATH_SEPARATOR_S "\\" #define ZT_EOL_S "\r\n" +#include <WinSock2.h> +#include <Windows.h> #endif // Assume these are little-endian. PPC is not supported for OSX, and ARM diff --git a/node/EthernetTap.cpp b/node/EthernetTap.cpp index e9ab74b8..458f1eed 100644 --- a/node/EthernetTap.cpp +++ b/node/EthernetTap.cpp @@ -938,7 +938,7 @@ void EthernetTap::threadMain() #include <nldef.h> #include <netioapi.h> -#include "..\vsprojects\TapDriver\tap-windows.h" +#include "..\windows\TapDriver\tap-windows.h" namespace ZeroTier { diff --git a/node/HttpClient.cpp b/node/HttpClient.cpp index ad7bba27..0e0c8ccf 100644 --- a/node/HttpClient.cpp +++ b/node/HttpClient.cpp @@ -25,21 +25,20 @@ * LLC. Start here: http://www.zerotier.com/ */ +#include "Constants.hpp" + +#ifdef __WINDOWS__ +#include <WinSock2.h> +#include <Windows.h> +#include <winhttp.h> +#include <locale> +#include <codecvt> +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <vector> -#include <utility> -#include <algorithm> - -#include "Constants.hpp" -#include "HttpClient.hpp" -#include "Thread.hpp" -#include "Utils.hpp" -#include "NonCopyable.hpp" -#include "Defaults.hpp" - #ifdef __UNIX_LIKE__ #include <unistd.h> #include <signal.h> @@ -51,12 +50,15 @@ #include <sys/wait.h> #endif -#ifdef __WINDOWS__ -#include <locale> -#include <codecvt> -#include <Windows.h> -#include <winhttp.h> -#endif +#include <vector> +#include <utility> +#include <algorithm> + +#include "HttpClient.hpp" +#include "Thread.hpp" +#include "Utils.hpp" +#include "NonCopyable.hpp" +#include "Defaults.hpp" namespace ZeroTier { diff --git a/node/NetworkConfig.hpp b/node/NetworkConfig.hpp index 06a7a337..57f22da2 100644 --- a/node/NetworkConfig.hpp +++ b/node/NetworkConfig.hpp @@ -112,8 +112,8 @@ public: if ((!etherType)||(etherType > 0xffff)) // sanity checks return false; else if ((_etWhitelist[0] & 1)) // prsence of 0 in set inverts sense: whitelist becomes blacklist - return (!(_etWhitelist[etherType >> 3] & (1 << (etherType & 7)))); - else return ((_etWhitelist[etherType >> 3] & (1 << (etherType & 7)))); + return ((_etWhitelist[etherType >> 3] & (1 << (etherType & 7))) == 0); + else return ((_etWhitelist[etherType >> 3] & (1 << (etherType & 7))) != 0); } std::set<unsigned int> allowedEtherTypes() const; diff --git a/node/NodeConfig.cpp b/node/NodeConfig.cpp index 770f1f6f..374e9916 100644 --- a/node/NodeConfig.cpp +++ b/node/NodeConfig.cpp @@ -77,7 +77,7 @@ NodeConfig::NodeConfig(const RuntimeEnvironment *renv,const char *authToken,unsi if (!d->second) { std::string::size_type dot = d->first.rfind(".conf"); if (dot != std::string::npos) { - uint64_t nwid = strtoull(d->first.substr(0,dot).c_str(),(char **)0,16); + uint64_t nwid = Utils::hexStrToU64(d->first.substr(0,dot).c_str()); // TODO: remove legacy code once out of beta if (nwid == 0x6c92786fee000001ULL) { @@ -230,7 +230,7 @@ std::vector<std::string> NodeConfig::execute(const char *command) } } else if (cmd[0] == "join") { if (cmd.size() > 1) { - uint64_t nwid = strtoull(cmd[1].c_str(),(char **)0,16); + uint64_t nwid = Utils::hexStrToU64(cmd[1].c_str()); if (nwid > 0) { Mutex::Lock _l(_networks_m); if (_networks.count(nwid)) { @@ -255,7 +255,7 @@ std::vector<std::string> NodeConfig::execute(const char *command) } else if (cmd[0] == "leave") { if (cmd.size() > 1) { Mutex::Lock _l(_networks_m); - uint64_t nwid = strtoull(cmd[1].c_str(),(char **)0,16); + uint64_t nwid = Utils::hexStrToU64(cmd[1].c_str()); std::map< uint64_t,SharedPtr<Network> >::iterator nw(_networks.find(nwid)); if (nw == _networks.end()) { _P("404 leave %.16llx ERROR: not a member of that network",(unsigned long long)nwid); diff --git a/node/Packet.cpp b/node/Packet.cpp index 20547d79..41fbe1b7 100644 --- a/node/Packet.cpp +++ b/node/Packet.cpp @@ -64,7 +64,7 @@ const char *Packet::errorString(ErrorCode e) case ERROR_IDENTITY_COLLISION: return "IDENTITY_COLLISION"; case ERROR_UNSUPPORTED_OPERATION: return "UNSUPPORTED_OPERATION"; case ERROR_NEED_MEMBERSHIP_CERTIFICATE: return "NEED_MEMBERSHIP_CERTIFICATE"; - case ERROR_NETWORK_ACCESS_DENIED: return "NETWORK_ACCESS_DENIED"; + case ERROR_NETWORK_ACCESS_DENIED_: return "NETWORK_ACCESS_DENIED"; } return "(unknown)"; } diff --git a/node/Packet.hpp b/node/Packet.hpp index c9269a82..be5ffb54 100644 --- a/node/Packet.hpp +++ b/node/Packet.hpp @@ -672,7 +672,7 @@ public: ERROR_NEED_MEMBERSHIP_CERTIFICATE = 6, /* Tried to join network, but you're not a member */ - ERROR_NETWORK_ACCESS_DENIED = 7 + ERROR_NETWORK_ACCESS_DENIED_ = 7 /* extra _ to avoid Windows name conflict */ }; /** diff --git a/node/PacketDecoder.cpp b/node/PacketDecoder.cpp index b8bdc8de..4869bca5 100644 --- a/node/PacketDecoder.cpp +++ b/node/PacketDecoder.cpp @@ -151,7 +151,7 @@ bool PacketDecoder::_doERROR(const RuntimeEnvironment *_r,const SharedPtr<Peer> if (network) network->pushMembershipCertificate(source(),true,Utils::now()); } break; - case Packet::ERROR_NETWORK_ACCESS_DENIED: { + case Packet::ERROR_NETWORK_ACCESS_DENIED_: { SharedPtr<Network> network(_r->nc->network(at<uint64_t>(ZT_PROTO_VERB_ERROR_IDX_PAYLOAD))); if ((network)&&(network->controller() == source())) network->forceStatusTo(Network::NETWORK_ACCESS_DENIED); diff --git a/node/Poly1305.cpp b/node/Poly1305.cpp index dff9b452..e9ac8ce7 100644 --- a/node/Poly1305.cpp +++ b/node/Poly1305.cpp @@ -4,8 +4,13 @@ D. J. Bernstein Public domain. */ +#include "Constants.hpp" #include "Poly1305.hpp" +#ifdef __WINDOWS__ +#pragma warning(disable: 4146) +#endif + namespace ZeroTier { ////////////////////////////////////////////////////////////////////////////// diff --git a/node/Utils.cpp b/node/Utils.cpp index 45d1aee8..53a67179 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -280,8 +280,12 @@ int64_t Utils::getFileSize(const char *path) struct stat s; if (stat(path,&s)) return -1; +#ifdef __WINDOWS__ + return s.st_size; +#else if (S_ISREG(s.st_mode)) return s.st_size; +#endif return -1; } diff --git a/windows/SelfTest/SelfTest.vcxproj b/windows/SelfTest/SelfTest.vcxproj index 03b9ae05..fa7885b0 100644 --- a/windows/SelfTest/SelfTest.vcxproj +++ b/windows/SelfTest/SelfTest.vcxproj @@ -91,6 +91,7 @@ <ClCompile Include="..\..\node\Topology.cpp" /> <ClCompile Include="..\..\node\UdpSocket.cpp" /> <ClCompile Include="..\..\node\Utils.cpp" /> + <ClCompile Include="..\..\selftest.cpp" /> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{DCD73B97-0F44-4044-8BA4-95B59CCAB4BD}</ProjectGuid> diff --git a/windows/SelfTest/SelfTest.vcxproj.filters b/windows/SelfTest/SelfTest.vcxproj.filters index 65453383..572568ed 100644 --- a/windows/SelfTest/SelfTest.vcxproj.filters +++ b/windows/SelfTest/SelfTest.vcxproj.filters @@ -223,5 +223,8 @@ <ClCompile Include="..\..\node\Utils.cpp"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="..\..\selftest.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> </Project>
\ No newline at end of file |