0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 02:10:45 -05:00
Merijn Hendriks 9c89c31c68 Modernize HTTP v2 (!104)
This PR won't affect modders who have already updated their mods to 3.8.0. They just need to re-compile.

This is a resubmission of my previous PR (SPT-AKI/Modules#99) with additional code cleanup and fixes.
Instead of outright removing the functionality, this time I deprecate it instead (marked for removal in next release).

Requires SPT-AKI/Server#274 to function.

## Overview

- HTTP modernization
  - Adds `Aki.Common.Http.Client`, a replacement for `Aki.Common.Http.Request` and builds on top of `System.Net.Http.HttpClient`
  - Implements failsafe retries when requesting during busy connections
  - Improved debugging
  - Improved performance
  - Deprecades old request code
- Bundle system
  - Fixes remote downloaded bundles using external IP
  - Implements functional bundle caching from remote sources
  - Implements multi-threaded bundle downloads
  - Implements Unity-compatible bundle format support
  - Extensive cleanup
  - Deprecated unneccecary models

## Why?

In it's current state, the bundle system is ducktaped together in 2021, fundumentally broken and in desperate need of a cleanup and fixes.
The HTTP code hasn't been updated since 2021, and `HttpWebRequest` has been deprecated by Microsoft for a while now.
There was also a lot of opportunity left for simple performance gains that even reduces the complexity of the code.

As for why not two separate PRs (HTTP modernization, bundle rework): both were deeply interconnected. A change in one requires modification in the other. Hence the current approach.

## Testing

The code has been validated and tested by @TheSparta and me.
A large section of the code has been implemented and tested extensively by modders.

### Local

1. Start the game from 127.0.0.1
2. The game starts loading bundles from the mods path

### Remote, full re-aquire

1. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
2. Start the game from LAN IP
3. A folder named `user/cache/bundles` is created

### Remote, partial-aquire (deleted)

1. Ensure all bundles are cached
2. Delete one of the aquired bundles from cache
3. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
4. Start the game from LAN IP
5. The bundle is redownloaded

### Remote, partial-aquire (invalid crc)

1. Ensure all bundles are cached
2. Update a bundle mod with a new bundle on the same path
3. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
4. Start the game from LAN IP
5. The bundle is redownloaded

### Remote, use cache

1. Ensure all bundles are cached
2. Start the server from LAN IP (http.json, set host to `cmd > ipconfig` address, example: `192.168.178.32`)
3. Start the game from LAN IP
4. The game starts loading bundles from the cache path

## Risk assessment

In order to reduce friction between releases, this PR introduces a deprecation system.
Obsolete classes and methods have been marked deprecated.
These will remain available for the current release and continue to function as normal for this release.
A warning will be displayed during build when a modder relies on the deprecated functionality.
The marked classes and methods are to be removed in the next release.

The server-side changes have no impact on modders.

## Deprecation

The following classes are affected:

- `Aki.Common.Http.Request`: Replaced by `Aki.Common.Http.Request`
- `Aki.Common.Http.WebConstants`: Replaced by functionality from `System.Net.Http`
- `Aki.Custom.Models.BundleInfo`: Replaced by `Aki.Custom.Models.BundleItem`

The following methods are affected:

- `Aki.Common.Http.RequestHandler.GetData(path, hasHost)`: `hasHost` enables connection outside intended host.
- `Aki.Common.Http.RequestHandler.GetJson(path, hasHost)`: `hasHost` enables connection outside intended host.
- `Aki.Common.Http.RequestHandler.PostJson(path, json, hasHost)`: `hasHost` enables connection outside intended host.
- `Aki.Common.Http.RequestHandler.PutJson(path, json, hasHost)`: `hasHost` enables connection outside intended host.

The deprecated methods and `Aki.Custom.Models.BundleInfo` are self-contained and can be removed independently.
The deprecated classes require removal of all deprecated code at once.

Reviewed-on: SPT-AKI/Modules#104
Reviewed-by: TheSparta <thesparta@noreply.dev.sp-tarkov.com>
Co-authored-by: Merijn Hendriks <merijn.d.hendriks@gmail.com>
Co-committed-by: Merijn Hendriks <merijn.d.hendriks@gmail.com>
2024-03-29 18:43:46 +00:00
2023-03-03 18:52:31 +00:00
2024-03-29 18:43:46 +00:00
2023-03-03 18:52:31 +00:00
2023-10-10 10:58:33 +00:00
2023-03-03 18:52:31 +00:00
2024-03-18 16:37:54 +00:00

Modules

BepInEx plugins to alter Escape From Tarkov's behaviour

Project Function
Aki.Build Build script
Aki.Bundles External bundle loader
Aki.Common Common utilities used across projects
Aki.Core Required patches to start the game
Aki.Custom SPT-AKI enhancements to EFT
Aki.Debugging Debug utilities (disabled in release builds)
Aki.Reflection Reflection utilities used across the project
Aki.SinglePlayer Simulating online game while offline

Privacy

SPT is an open source project. Your commit credentials as author of a commit will be visible by anyone. Please make sure you understand this before submitting a PR. Feel free to use a "fake" username and email on your commits by using the following commands:

git config --local user.name "USERNAME"
git config --local user.email "USERNAME@SOMETHING.com"

Requirements

  • Escape From Tarkov 29197
  • Visual Studio Code -OR- Visual Studio 2022
  • .NET 6 SDK
  • PowerShell v7
    • Can also be installed via: dotnet tool update --global PowerShell

Project Setup

Copy-paste Live EFT's EscapeFromTarkov_Data/Managed/ folder to into this project's Project/Shared/Managed/ folder

Build (VS Code)

  1. File > Open Workspace > Modules.code-workspace
  2. Terminal > Run Build Task...
  3. Copy contents of /Build into SPT game folder and overwrite

Build (VS 2022)

  1. Open solution
  2. Restore nuget packages
  3. Build solution
  4. Copy contents of /Build into SPT game folder and overwrite

Game Setup

  1. Copy Live EFT files into a separate directory (from now on this will be referred to as the "SPT directory")
  2. Download BepInEx 5.4.22 x64 (BepInEx Releases - GitHub)
  3. Extract contents of the BepInEx zip into the root SPT directory
  4. Build Modules, Server and Launcher
  5. Copy the contents of each project's Build folder into the root SPT directory
  6. (Optional, but recommended) Download the BepInEx5 version of ConfigurationManager (ConfigurationManager Releases - GitHub) and extract the contents of the zip into the root SPT directory. The default keybind for opening the menu will be F1
  7. (Optional) Edit the BepInEx config (\BepInEx\config\BepInEx.cfg) and append Debug to the LogLevels setting. Example: LogLevels = Fatal, Error, Warning, Message, Info, Debug
Description
No description provided
Readme 151 MiB
Languages
C# 99.5%
PowerShell 0.5%