Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Verified mods auto-downloading #362

Closed
wants to merge 100 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
0862895
feat: porting code from old branch
Alystrasz Nov 29, 2022
1030b8b
refactor: remove old code
Alystrasz Nov 29, 2022
dfdee00
feat: download method fetches ZIP archive from Thunderstore API
Alystrasz Nov 29, 2022
10cd16f
feat: expose DownloadMod method to Squirrel VM
Alystrasz Nov 29, 2022
92595eb
feat: use a list to tell which mods are being downloaded
Alystrasz Nov 30, 2022
018755d
docs: add documentation to all methods
Alystrasz Nov 30, 2022
97058fb
docs: add big-ass section titles in ASCII-art because why not
Alystrasz Nov 30, 2022
93a5b0d
Merge branch 'R2Northstar:main' into feat/new-verified-mods
Alystrasz Dec 1, 2022
86c3ba2
build: add libzip library
Alystrasz Dec 2, 2022
c252c02
Merge branch 'feat/new-verified-mods' of github.com:Alystrasz/Northst…
Alystrasz Dec 2, 2022
25e278f
Revert "build: add libzip library"
Alystrasz Dec 2, 2022
5e2cfcf
refactor: remove GetVerifiedModsList method
Alystrasz Dec 2, 2022
1d3bc0e
refactor: remove cURL code from FetchVerifiedModsList
Alystrasz Dec 2, 2022
ea30429
feat: add "NS" prefix to Squirrel-exposed methods
Alystrasz Dec 2, 2022
ddab989
Merge branch 'master' into feat/new-verified-mods
Alystrasz Dec 2, 2022
949529e
build: add libzip library dependency
Alystrasz Dec 3, 2022
d0d2df7
feat: read mods files from zip archive
Alystrasz Dec 4, 2022
448e706
refactor: remove mod status check from DownloadMod method
Alystrasz Dec 4, 2022
0aa88b4
feat: extract folders from archive
Alystrasz Dec 4, 2022
3565741
feat: extract files from archive
Alystrasz Dec 4, 2022
16af759
feat: extract archive content directly into mods/ folder
Alystrasz Dec 4, 2022
ae6dfc0
refactor: remove unused code
Alystrasz Dec 6, 2022
1e6b991
refactor: use Fifty.mp_frostbite as test mod only
Alystrasz Dec 6, 2022
126e97a
refactor: add gotos REQUEST_END_CLEANUP in case something goes wrong
Alystrasz Dec 6, 2022
8a3ed78
docs: add TODO notes
Alystrasz Dec 6, 2022
6c366c2
docs: add documentation to DownloadMod method
Alystrasz Dec 8, 2022
4cba187
refactor: encapsulate versions in objects
Alystrasz Dec 9, 2022
d7ad2e2
Merge branch 'R2Northstar:main' into feat/new-verified-mods
Alystrasz Dec 9, 2022
bda2a03
Merge branch 'main' into feat/new-verified-mods
Alystrasz Dec 11, 2022
7b370c2
build: update lib import in zip.h
Alystrasz Dec 11, 2022
60f1d61
style: format file
Alystrasz Dec 11, 2022
9d548a9
Merge branch 'feat/new-verified-mods' of github.com:Alystrasz/Northst…
Alystrasz Dec 12, 2022
8fc2159
style: format
Alystrasz Dec 13, 2022
c1fd577
Merge branch 'main' into feat/new-verified-mods
Alystrasz Dec 13, 2022
1523f51
Merge branch 'master' into feat/new-verified-mods
Alystrasz Dec 20, 2022
9a437c0
Merge branch 'master' into feat/new-verified-mods
Alystrasz Dec 26, 2022
b3cecba
feat: save current download progress in a local float
Alystrasz Dec 26, 2022
7c6ac26
feat: format download progress (keeping two decimals)
Alystrasz Dec 26, 2022
6b4ed4e
feat: expose download progression to Squirrel VM
Alystrasz Dec 26, 2022
6f16e63
fix: reset download progress before starting mod download
Alystrasz Dec 26, 2022
e5ba792
style: format code
Alystrasz Dec 26, 2022
c392219
refactor: send download stats to VM
Alystrasz Dec 27, 2022
6dbc5e7
test: add Zircon Spitfire to verified mods list
Alystrasz Dec 27, 2022
aa8c117
feat: send zip extraction stats to VM
Alystrasz Dec 27, 2022
c8195bb
feat: send big files extraction progress to VM
Alystrasz Dec 27, 2022
2384077
docs: add documentation to currentDownloadStats variable
Alystrasz Dec 27, 2022
b6ebce7
style: only assign changing vector elements + send vector to VM using…
Alystrasz Dec 27, 2022
174285a
refactor: remove file download progress log (because too many entries)
Alystrasz Dec 28, 2022
c27e316
feat: add a log entry to mark mod's successful extraction
Alystrasz Dec 28, 2022
4ee0cc0
feat: extraction progress is updated with extracted content
Alystrasz Dec 29, 2022
3b3c4fe
refactor: export total size computation outside of thread
Alystrasz Dec 29, 2022
41b81d8
feat: add code skeleton to check downloaded archive checksum
Alystrasz Dec 30, 2022
1c4c3e9
build: add openssl libraries to linker inputs
Alystrasz Jan 3, 2023
9d3422d
fix: abort mod install if hashes do NOT match
Alystrasz Jan 3, 2023
258e157
Merge pull request #1 from Alystrasz/feat/checksum
Alystrasz Jan 3, 2023
9f0f2a8
docs: add some documentation
Alystrasz Jan 3, 2023
56883fe
feat: abort mod download on create_directory failure
Alystrasz Jan 3, 2023
118dc53
feat: abort mod extraction if input stream is not open
Alystrasz Jan 3, 2023
38f38ac
feat: add link to error_code values
Alystrasz Jan 3, 2023
1aaafad
Merge branch 'main' into feat/new-verified-mods
Alystrasz Jan 8, 2023
6966f79
build: move verified stuff into mods/verified/ filter
Alystrasz Jan 8, 2023
5d05785
feat: add VerificationResult enum
Alystrasz Jan 8, 2023
e24a51e
feat: add FAILED_READING_ARCHIVE value to result enum
Alystrasz Jan 8, 2023
d969edd
feat: add a modDownloadAndExtractionResult variable to track process …
Alystrasz Jan 8, 2023
95e712f
fix: add missing header
Alystrasz Jan 8, 2023
74b8722
build: include enum file in compilation process
Alystrasz Jan 8, 2023
43006e6
fix: add header file for verification results
Alystrasz Jan 8, 2023
5a3bab1
feat: add NSGetModExtractionResult Squirrel-exposed method
Alystrasz Jan 8, 2023
4e6d420
feat: check errors on directory creation
Alystrasz Jan 9, 2023
71378e3
feat: remove downloaded archive on thread death
Alystrasz Jan 9, 2023
b4bcbc5
fix: close zip files after extraction
Alystrasz Jan 9, 2023
9b6dda1
style: format
Alystrasz Jan 9, 2023
f68036d
feat: put Thunderstore manifest.json file into mods directories
Alystrasz Jan 10, 2023
4f4bcb8
Merge branch 'main' into feat/new-verified-mods
Alystrasz Jan 11, 2023
678222c
Merge branch 'main' into feat/new-verified-mods
Alystrasz Jan 17, 2023
a3d3049
feat: add key to mod.json files
Alystrasz Jan 17, 2023
53b4fef
fix: pretty format mod.json files
Alystrasz Jan 18, 2023
363d323
feat: fetch verified mods list on DLL load
Alystrasz Jan 24, 2023
50c2f29
refactor: remove NSFetchVerifiedModsList Squirrel method
Alystrasz Jan 24, 2023
2041b94
refactor: put all verification-related code in a dedicated package
Alystrasz Jan 25, 2023
d51260a
refactor: remove unused verifiedmods.h file
Alystrasz Jan 25, 2023
1249fd2
refactor: move util methods to dedicated files
Alystrasz Jan 25, 2023
93fed07
feat: create thunderstore_author.txt files
Alystrasz Jan 26, 2023
4933551
style: format
Alystrasz Jan 26, 2023
3bb4765
Merge branch 'main' into feat/new-verified-mods
Alystrasz Jan 26, 2023
ffea820
Merge branch 'R2Northstar:main' into feat/new-verified-mods
Alystrasz Jan 26, 2023
80eb805
Merge branch 'R2Northstar:main' into feat/new-verified-mods
Alystrasz Jan 30, 2023
27350a9
refactor: unzip mods in remote mods directory
Alystrasz Jan 30, 2023
0e322ea
feat: use thunderstore dependency string as mod directory name
Alystrasz Jan 31, 2023
421b6ce
style: typo in variable name
Alystrasz Jan 31, 2023
5e98846
Merge branch 'main' into feat/new-verified-mods
Alystrasz Feb 1, 2023
bf9ab56
feat: add Dinorush.Brute4 mod to verified mods
Alystrasz Feb 4, 2023
277646e
Merge branch 'main' into feat/new-verified-mods
Alystrasz Mar 8, 2023
397daa7
Merge branch 'main' into feat/new-verified-mods
Alystrasz Apr 10, 2023
c71cd82
Merge branch 'main' into feat/new-verified-mods
Alystrasz May 23, 2023
3a216b2
Merge branch 'main' into feat/new-verified-mods
Alystrasz May 23, 2023
2eeae52
Merge branch 'feat/new-verified-mods' of github.com:Alystrasz/Northst…
Alystrasz May 23, 2023
9981922
refactor: add s2s map as verified mod
Alystrasz May 26, 2023
d6e4900
fix: create files parent directory if needed
Alystrasz May 26, 2023
883ea0b
style: reformat verifiedmods.cpp
Alystrasz May 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions NorthstarDLL/NorthstarDLL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,15 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)include\libzip\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>pch.h</ForcedIncludeFiles>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>$(SolutionDir)include\MinHook.x64.lib;$(SolutionDir)include\libcurl\lib\libcurl_a.lib;Ws2_32.lib;Crypt32.lib;Cryptui.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;Bcrypt.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(SolutionDir)include\MinHook.x64.lib;$(SolutionDir)include\libcrypto_static.lib;$(SolutionDir)include\libssl_static.lib;$(SolutionDir)include\libcurl\lib\libcurl_a.lib;$(SolutionDir)include\libzip\lib\zip.lib;$(SolutionDir)include\libzip\lib\zlib.lib;$(SolutionDir)include\libzip\lib\bz2.lib;Ws2_32.lib;Crypt32.lib;Cryptui.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;Bcrypt.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ForceSymbolReferences>
</ForceSymbolReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand All @@ -93,6 +94,7 @@
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp20</LanguageStandard>
<AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)include\libzip\lib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<Optimization>Disabled</Optimization>
Expand All @@ -104,7 +106,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>$(SolutionDir)include\MinHook.x64.lib;$(SolutionDir)include\libcurl\lib\libcurl_a.lib;Ws2_32.lib;Crypt32.lib;Cryptui.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;Bcrypt.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(SolutionDir)include\MinHook.x64.lib;$(SolutionDir)include\libcrypto_static.lib;$(SolutionDir)include\libssl_static.lib;$(SolutionDir)include\libcurl\lib\libcurl_a.lib;Ws2_32.lib;Crypt32.lib;Cryptui.lib;$(SolutionDir)include\libzip\lib\zip.lib;$(SolutionDir)include\libzip\lib\zlib.lib;$(SolutionDir)include\libzip\lib\bz2.lib;dbghelp.lib;Wldap32.lib;Normaliz.lib;Bcrypt.lib;version.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ForceSymbolReferences>
</ForceSymbolReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand All @@ -128,6 +130,11 @@
<ClInclude Include="..\include\libcurl\include\curl\system.h" />
<ClInclude Include="..\include\libcurl\include\curl\typecheck-gcc.h" />
<ClInclude Include="..\include\libcurl\include\curl\urlapi.h" />
<ClInclude Include="..\include\libzip\include\bzlib.h" />
<ClInclude Include="..\include\libzip\include\zconf.h" />
<ClInclude Include="..\include\libzip\include\zip.h" />
<ClInclude Include="..\include\libzip\include\zipconf.h" />
<ClInclude Include="..\include\libzip\include\zlib.h" />
<ClInclude Include="..\include\MinHook.h" />
<ClInclude Include="..\include\openssl\aes.h" />
<ClInclude Include="..\include\openssl\asn1.h" />
Expand Down Expand Up @@ -429,6 +436,8 @@
<ClInclude Include="logging\sourceconsole.h" />
<ClInclude Include="masterserver\masterserver.h" />
<ClInclude Include="mods\modmanager.h" />
<ClInclude Include="mods\verified\verification_results.h" />
<ClInclude Include="mods\verified\verifiedmodsutils.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="plugins\pluginbackend.h" />
<ClInclude Include="plugins\plugins.h" />
Expand Down Expand Up @@ -503,6 +512,9 @@
<ClCompile Include="mods\compiled\modpdef.cpp" />
<ClCompile Include="mods\compiled\modscriptsrson.cpp" />
<ClCompile Include="mods\modmanager.cpp" />
<ClCompile Include="mods\verified\verification_results.cpp" />
<ClCompile Include="mods\verified\verifiedmods.cpp" />
<ClCompile Include="mods\verified\verifiedmodsutils.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
Expand Down
39 changes: 39 additions & 0 deletions NorthstarDLL/NorthstarDLL.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@
<Filter Include="Header Files\shared\exploit_fixes">
<UniqueIdentifier>{1a377c09-bd3d-4757-b3bc-9cd0a1e6ac0d}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\mods\verified">
<UniqueIdentifier>{d14c40a3-f54b-41f6-acca-3ecc4b83cc38}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\mods\verified">
<UniqueIdentifier>{8b2cefce-037f-4c76-af2d-bbbd85588e3b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\MinHook.h">
Expand Down Expand Up @@ -1032,6 +1038,9 @@
<ClInclude Include="plugins\plugins.h">
<Filter>Header Files\plugins</Filter>
</ClInclude>
<ClInclude Include="plugins\plugin_abi.h">
<Filter>Header Files\plugins</Filter>
</ClInclude>
<ClInclude Include="server\serverpresence.h">
<Filter>Header Files\server</Filter>
</ClInclude>
Expand Down Expand Up @@ -1059,6 +1068,21 @@
<ClInclude Include="dllmain.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\libzip\include\bzlib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\libzip\include\zconf.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\libzip\include\zip.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\libzip\include\zipconf.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\libzip\include\zlib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -1182,6 +1206,12 @@
<ClInclude Include="util\utils.h">
<Filter>Header Files\util</Filter>
</ClInclude>
<ClInclude Include="mods\verified\verification_results.h">
<Filter>Header Files\mods\verified</Filter>
</ClInclude>
<ClInclude Include="mods\verified\verifiedmodsutils.h">
<Filter>Header Files\mods\verified</Filter>
</ClInclude>
<ClInclude Include="dedicated\dedicatedlogtoclient.h">
<Filter>Header Files\dedicated</Filter>
</ClInclude>
Expand Down Expand Up @@ -1444,6 +1474,15 @@
<ClCompile Include="util\utils.cpp">
<Filter>Source Files\util</Filter>
</ClCompile>
<ClCompile Include="mods\verified\verification_results.cpp">
<Filter>Source Files\mods\verified</Filter>
</ClCompile>
<ClCompile Include="mods\verified\verifiedmods.cpp">
<Filter>Source Files\mods\verified</Filter>
</ClCompile>
<ClCompile Include="mods\verified\verifiedmodsutils.cpp">
<Filter>Source Files\mods\verified</Filter>
</ClCompile>
<ClCompile Include="dedicated\dedicatedlogtoclient.cpp">
<Filter>Source Files\dedicated</Filter>
</ClCompile>
Expand Down
11 changes: 11 additions & 0 deletions NorthstarDLL/mods/verified/verification_results.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "pch.h"
#include <string>
#include "verification_results.h"

std::array<std::string, 7> _resultValues {
"OK", "FAILED", "FAILED_READING_ARCHIVE", "FAILED_WRITING_TO_DISK", "MOD_FETCHING_FAILED", "MOD_CORRUPTED", "NO_DISK_SPACE_AVAILABLE"};

const char* GetVerifiedModErrorString(VerificationResult error)
{
return _resultValues[error].c_str();
}
17 changes: 17 additions & 0 deletions NorthstarDLL/mods/verified/verification_results.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* This enumeration allows to characterize result of verified mod downloading and extraction.
* Its values match localization entries client-side, which will be displayed by Squirrel VM
* to users if operation result is different than OK.
**/
enum VerificationResult
{
OK,
FAILED, // Generic error message, should be avoided as much as possible
FAILED_READING_ARCHIVE,
FAILED_WRITING_TO_DISK,
MOD_FETCHING_FAILED,
MOD_CORRUPTED, // Downloaded archive checksum does not match verified hash
NO_DISK_SPACE_AVAILABLE,
};

const char* GetVerifiedModErrorString(VerificationResult error);
Loading