mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 04:53:44 +02:00
Builds on Windows now.
This commit is contained in:
parent
4d1cca1150
commit
a5896264fa
3 changed files with 36 additions and 15 deletions
|
@ -182,7 +182,6 @@ void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const s
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __UNIX_LIKE__
|
|
||||||
size_t lastSlash = url.rfind('/');
|
size_t lastSlash = url.rfind('/');
|
||||||
if (lastSlash == std::string::npos) { // sanity check, shouldn't happen
|
if (lastSlash == std::string::npos) { // sanity check, shouldn't happen
|
||||||
LOG("software update aborted: invalid URL");
|
LOG("software update aborted: invalid URL");
|
||||||
|
@ -191,30 +190,36 @@ void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const s
|
||||||
}
|
}
|
||||||
std::string updatesDir(_r->homePath + ZT_PATH_SEPARATOR_S + "updates.d");
|
std::string updatesDir(_r->homePath + ZT_PATH_SEPARATOR_S + "updates.d");
|
||||||
std::string updatePath(updatesDir + ZT_PATH_SEPARATOR_S + url.substr(lastSlash + 1));
|
std::string updatePath(updatesDir + ZT_PATH_SEPARATOR_S + url.substr(lastSlash + 1));
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
CreateDirectoryA(updatesDir.c_str(),NULL);
|
||||||
|
#else
|
||||||
mkdir(updatesDir.c_str(),0755);
|
mkdir(updatesDir.c_str(),0755);
|
||||||
|
#endif
|
||||||
|
|
||||||
int fd = ::open(updatePath.c_str(),O_WRONLY|O_CREAT|O_TRUNC,0755);
|
FILE *upf = fopen(updatePath.c_str(),"wb");
|
||||||
if (fd <= 0) {
|
if (!upf) {
|
||||||
LOG("software update aborted: unable to open %s for writing",updatePath.c_str());
|
LOG("software update aborted: unable to open %s for writing",updatePath.c_str());
|
||||||
upd->_status = UPDATE_STATUS_IDLE;
|
upd->_status = UPDATE_STATUS_IDLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((long)::write(fd,body.data(),body.length()) != (long)body.length()) {
|
if (fwrite(body.data(),body.length(),1,upf) != 1) {
|
||||||
LOG("software update aborted: unable to write to %s",updatePath.c_str());
|
LOG("software update aborted: unable to write to %s",updatePath.c_str());
|
||||||
upd->_status = UPDATE_STATUS_IDLE;
|
upd->_status = UPDATE_STATUS_IDLE;
|
||||||
|
fclose(upf);
|
||||||
|
Utils::rm(updatePath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
::close(fd);
|
fclose(upf);
|
||||||
|
|
||||||
|
#ifdef __UNIX_LIKE__
|
||||||
::chmod(updatePath.c_str(),0755);
|
::chmod(updatePath.c_str(),0755);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// We exit with this reason code and the path as the text. It is the
|
||||||
|
// caller's responsibility (main.c) to pick this up and do the right
|
||||||
|
// thing.
|
||||||
upd->_status = UPDATE_STATUS_IDLE;
|
upd->_status = UPDATE_STATUS_IDLE;
|
||||||
|
|
||||||
_r->node->terminate(Node::NODE_RESTART_FOR_UPGRADE,updatePath.c_str());
|
_r->node->terminate(Node::NODE_RESTART_FOR_UPGRADE,updatePath.c_str());
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
|
||||||
todo;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
</ProjectConfiguration>
|
</ProjectConfiguration>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="..\..\ext\lz4\lz4.h" />
|
||||||
|
<ClInclude Include="..\..\ext\lz4\lz4hc.h" />
|
||||||
<ClInclude Include="..\..\node\Address.hpp" />
|
<ClInclude Include="..\..\node\Address.hpp" />
|
||||||
<ClInclude Include="..\..\node\Array.hpp" />
|
<ClInclude Include="..\..\node\Array.hpp" />
|
||||||
<ClInclude Include="..\..\node\AtomicCounter.hpp" />
|
<ClInclude Include="..\..\node\AtomicCounter.hpp" />
|
||||||
|
@ -64,6 +66,8 @@
|
||||||
<ClInclude Include="..\..\node\Utils.hpp" />
|
<ClInclude Include="..\..\node\Utils.hpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="..\..\ext\lz4\lz4.c" />
|
||||||
|
<ClCompile Include="..\..\ext\lz4\lz4hc.c" />
|
||||||
<ClCompile Include="..\..\node\C25519.cpp" />
|
<ClCompile Include="..\..\node\C25519.cpp" />
|
||||||
<ClCompile Include="..\..\node\CertificateOfMembership.cpp" />
|
<ClCompile Include="..\..\node\CertificateOfMembership.cpp" />
|
||||||
<ClCompile Include="..\..\node\Defaults.cpp" />
|
<ClCompile Include="..\..\node\Defaults.cpp" />
|
||||||
|
@ -168,7 +172,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>$(SolutionDir)\ext\bin\libcrypto\win32-vs2012\libeay32.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>wsock32.lib;ws2_32.lib;winhttp.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
|
@ -183,7 +187,7 @@
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Console</SubSystem>
|
<SubSystem>Console</SubSystem>
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<AdditionalDependencies>$(SolutionDir)\ext\bin\libcrypto\win32-vs2012\libeay32.lib;wsock32.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>wsock32.lib;ws2_32.lib;winhttp.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
|
@ -202,7 +206,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>wsock32.lib;ws2_32.lib;iphlpapi.lib;$(SolutionDir)\ext\bin\libcrypto\win32-vs2012\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>wsock32.lib;ws2_32.lib;winhttp.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
@ -222,7 +226,7 @@
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
<OptimizeReferences>true</OptimizeReferences>
|
||||||
<AdditionalDependencies>wsock32.lib;ws2_32.lib;iphlpapi.lib;$(SolutionDir)\ext\bin\libcrypto\win64-vs2012\libeay32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
<AdditionalDependencies>wsock32.lib;ws2_32.lib;winhttp.lib;Iphlpapi.lib;Rpcrt4.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
|
|
|
@ -140,6 +140,12 @@
|
||||||
<ClInclude Include="..\..\node\Utils.hpp">
|
<ClInclude Include="..\..\node\Utils.hpp">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\ext\lz4\lz4.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\ext\lz4\lz4hc.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\node\C25519.cpp">
|
<ClCompile Include="..\..\node\C25519.cpp">
|
||||||
|
@ -226,5 +232,11 @@
|
||||||
<ClCompile Include="..\..\selftest.cpp">
|
<ClCompile Include="..\..\selftest.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\ext\lz4\lz4.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\ext\lz4\lz4hc.c">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
Loading…
Add table
Reference in a new issue