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

Send DS's SDL to clients from the AuthSrv #184

Merged
merged 6 commits into from
Feb 20, 2024
Merged

Conversation

Hoikas
Copy link
Member

@Hoikas Hoikas commented Aug 27, 2023

H-uru/Plasma#1450 changed the meaning of /LocalData to "use the local PRPs and Python files" but still rely on the server's SDL. This means that clients either need to use the new /LocalSDL flag to use their own SDL, which is known to be dangerous, or we need to make it easier to get the known correct SDL to clients connecting to DirtSand.

Therefore, this adds the ability for DirtSand to automatically send down the SDL it is using internally to clients. It uses the very old auth secure preloader functionality, so it is compatible with all known clients. Most SDL files are quite small, which results in fairly poor download performance. Further, AuthSrv downloads are not compressed. So, I elected to give DirtSand the ability to write out its own SDL file containing all known state descriptors and omitting irrelevant comments and whitespace to give an optimal experience for users.

The last two commits could be deferred to another pull request, but I suspected some of the excess copying and memory management might be remarked upon, so I included those ideas for completeness' sake.

streams.cpp Outdated Show resolved Hide resolved
streams.cpp Outdated Show resolved Hide resolved
streams.h Outdated Show resolved Hide resolved
SDL/DescriptorDb.cpp Outdated Show resolved Hide resolved
AuthServ/AuthServer_Private.h Outdated Show resolved Hide resolved
Hoikas and others added 5 commits November 25, 2023 14:01
The encrypted stream class in *intended* for writing out minified copies
of the SDL files for the client, but adding the ability to read
encrypted SDL is just such low-hanging fruit that we might as well add
support for it.
Co-authored-by: dgelessus <dgelessus@users.noreply.github.com>
The client now prefers to download SDL files from the server, even when
`/LocalData` is supplied. Therefore, it is important that DS is always
able to serve SDL files without intervention. So, when SDLs are
requested from the AuthServ, send down an encrypted copy of the SDLs
that DS loaded.
@Hoikas
Copy link
Member Author

Hoikas commented Nov 25, 2023

I've removed the round-trip minifying step from this PR. Encrypted SDL files are not required for ease of use - DS can encrypt files before sending them down.

@Hoikas Hoikas requested a review from zrax February 19, 2024 23:30
SDL/DescriptorDb.h Outdated Show resolved Hide resolved
AuthServ/AuthServer.cpp Outdated Show resolved Hide resolved
SDL/DescriptorDb.cpp Outdated Show resolved Hide resolved
filename = DS::Settings::AuthRoot() + filename;
}

std::unique_ptr<DS::Stream> stream = std::make_unique<DS::FileStream>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::unique_ptr<DS::Stream> stream = std::make_unique<DS::FileStream>();
auto stream = std::make_unique<DS::FileStream>();

A unique_ptr<U> can be converted to a unique_ptr<T> if U derives from T, so there's no need for the extra casting complexity...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is true, later in the function, a DS::BufferStream can be moved to this std::unique_ptr. I'll do some work to remove the fiddly casting to make that more clear.

try {
stream->open(filename.c_str(), "rb");
static_cast<DS::FileStream*>(stream.get())->open(filename.c_str(), "rb");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static_cast<DS::FileStream*>(stream.get())->open(filename.c_str(), "rb");
stream->open(filename.c_str(), "rb");

SDL/SdlParser.cpp Show resolved Hide resolved
streams.h Show resolved Hide resolved
streams.cpp Outdated Show resolved Hide resolved
streams.cpp Show resolved Hide resolved
streams.cpp Outdated Show resolved Hide resolved
Co-authored-by: Michael Hansen <zrax0111@gmail.com>
@zrax zrax merged commit b9f06e7 into H-uru:master Feb 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants