From 1346e31a8ee962c40b1f18cb8ff1d5fe866744e3 Mon Sep 17 00:00:00 2001
From: Adam Ierymenko <adam.ierymenko@zerotier.com>
Date: Fri, 13 Jan 2017 14:22:36 -0800
Subject: [PATCH] Windows build fixes, Software update fix, warning removal.

---
 node/Multicaster.hpp                            | 2 +-
 one.cpp                                         | 4 ++--
 service/SoftwareUpdater.cpp                     | 8 ++++----
 windows/ZeroTierOne/ZeroTierOne.vcxproj         | 8 ++++----
 windows/ZeroTierOne/ZeroTierOne.vcxproj.filters | 9 ++++++---
 5 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/node/Multicaster.hpp b/node/Multicaster.hpp
index 5c94cd3a6..32dec9cf7 100644
--- a/node/Multicaster.hpp
+++ b/node/Multicaster.hpp
@@ -220,7 +220,7 @@ private:
 	{
 		_GatherAuthKey() : member(0),networkId(0) {}
 		_GatherAuthKey(const uint64_t nwid,const Address &a) : member(a.toInt()),networkId(nwid) {}
-		inline unsigned long hashCode() const { return (member ^ networkId); }
+		inline unsigned long hashCode() const { return (unsigned long)(member ^ networkId); }
 		inline bool operator==(const _GatherAuthKey &k) const { return ((member == k.member)&&(networkId == k.networkId)); }
 		uint64_t member;
 		uint64_t networkId;
diff --git a/one.cpp b/one.cpp
index 1cda3fb11..3ebaa8faa 100644
--- a/one.cpp
+++ b/one.cpp
@@ -495,7 +495,7 @@ static int cli(int argc,char **argv)
 					(std::string("/network/") + arg1).c_str(),
 					requestHeaders,
 					jsons,
-					strlen(jsons),
+					(unsigned long)strlen(jsons),
 					responseHeaders,
 					responseBody);
 				if (scode == 200) {
@@ -572,7 +572,7 @@ static int idtool(int argc,char **argv)
 		int vanityBits = 0;
 		if (argc >= 5) {
 			vanity = Utils::hexStrToU64(argv[4]) & 0xffffffffffULL;
-			vanityBits = 4 * strlen(argv[4]);
+			vanityBits = 4 * (int)strlen(argv[4]);
 			if (vanityBits > 40)
 				vanityBits = 40;
 		}
diff --git a/service/SoftwareUpdater.cpp b/service/SoftwareUpdater.cpp
index 299c0d97b..f6572cfcb 100644
--- a/service/SoftwareUpdater.cpp
+++ b/service/SoftwareUpdater.cpp
@@ -21,6 +21,9 @@
 #include <string.h>
 #include <stdint.h>
 
+#include "../node/Constants.hpp"
+#include "../version.h"
+
 #ifdef __WINDOWS__
 #include <WinSock2.h>
 #include <Windows.h>
@@ -37,9 +40,6 @@
 
 #include "SoftwareUpdater.hpp"
 
-#include "../version.h"
-
-#include "../node/Constants.hpp"
 #include "../node/Utils.hpp"
 #include "../node/SHA512.hpp"
 #include "../node/Buffer.hpp"
@@ -369,7 +369,7 @@ void SoftwareUpdater::apply()
 		PROCESS_INFORMATION pi;
 		memset(&si,0,sizeof(si));
 		memset(&pi,0,sizeof(pi));
-		CreateProcessA(NULL,updatePath.c_str(),NULL,NULL,FALSE,CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP,NULL,NULL,&si,&pi);
+		CreateProcessA(NULL,const_cast<LPSTR>(updatePath.c_str()),NULL,NULL,FALSE,CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP,NULL,NULL,&si,&pi);
 #else
 		char *argv[256];
 		unsigned long ac = 0;
diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj
index fc259ebfa..2a6545eb2 100644
--- a/windows/ZeroTierOne/ZeroTierOne.vcxproj
+++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj
@@ -255,7 +255,7 @@
       <SDLCheck>true</SDLCheck>
       <AdditionalIncludeDirectories>
       </AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <DisableSpecificWarnings>4996</DisableSpecificWarnings>
     </ClCompile>
     <Link>
@@ -271,7 +271,7 @@
       <SDLCheck>true</SDLCheck>
       <AdditionalIncludeDirectories>
       </AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MultiProcessorCompilation>false</MultiProcessorCompilation>
       <DisableSpecificWarnings>4996</DisableSpecificWarnings>
     </ClCompile>
@@ -291,7 +291,7 @@
       <SDLCheck>true</SDLCheck>
       <AdditionalIncludeDirectories>
       </AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>STATICLIB;ZT_OFFICIAL_RELEASE;ZT_AUTO_UPDATE;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>STATICLIB;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;ZT_SOFTWARE_UPDATE_DEFAULT="apply";%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
       <StringPooling>true</StringPooling>
@@ -317,7 +317,7 @@
       <SDLCheck>true</SDLCheck>
       <AdditionalIncludeDirectories>
       </AdditionalIncludeDirectories>
-      <PreprocessorDefinitions>STATICLIB;ZT_OFFICIAL_RELEASE;ZT_AUTO_UPDATE;ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <PreprocessorDefinitions>STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="apply";ZT_SALSA20_SSE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;WIN32;NOMINMAX;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
       <EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
       <StringPooling>true</StringPooling>
diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters
index 1fa39abda..8a426d4bb 100644
--- a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters
+++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters
@@ -264,6 +264,9 @@
     <ClCompile Include="..\..\controller\JSONDB.cpp">
       <Filter>Source Files\controller</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\service\SoftwareUpdater.cpp">
+      <Filter>Source Files\service</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="resource.h">
@@ -293,9 +296,6 @@
     <ClInclude Include="..\..\service\ControlPlane.hpp">
       <Filter>Header Files\service</Filter>
     </ClInclude>
-    <ClInclude Include="..\..\service\ControlPlaneSubsystem.hpp">
-      <Filter>Header Files\service</Filter>
-    </ClInclude>
     <ClInclude Include="..\..\service\OneService.hpp">
       <Filter>Header Files\service</Filter>
     </ClInclude>
@@ -554,6 +554,9 @@
     <ClInclude Include="..\..\osdep\ManagedRoute.hpp">
       <Filter>Header Files\osdep</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\service\SoftwareUpdater.hpp">
+      <Filter>Header Files\service</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="ZeroTierOne.rc">