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

Implement makeSafeForNet more thoroughly for avatar-related messages #191

Merged
merged 2 commits into from
Feb 20, 2024

Conversation

dgelessus
Copy link
Contributor

@dgelessus dgelessus commented Jan 3, 2024

AvBrainGeneric can contain arbitrary messages, and so can (indirectly) many avatar-related messages that contain a brain and/or task. This change ensures that such nested messages are checked for net-safety.

H-uru/Plasma#1550 implements similar checks on the receiving end in the client.

AvBrainGeneric can contain arbitrary messages, and so can (indirectly)
many avatar-related messages that contain a brain and/or task. This
change ensures that such nested messages are checked for net-safety.
Comment on lines +95 to +102
// These fields can contain arbitrary messages,
// so we must check them before sending the brain to other clients.
// The client never uses these fields for brains sent over the network though,
// so for simplicity, don't allow them over the network at all.
// If this causes issues, we could specifically allow NotifyMsg
// (the only message type that the client puts in these fields)
// or recursively call makeSafeForNet() on the messages.
return m_startMessage == nullptr && m_endMessage == nullptr;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This check is more restrictive than strictly necessary (see comment). It hasn't caused any issues in my (limited) testing, but this can be loosened if necessary.

Comment on lines 74 to 75
// This can only be LinkToAgeMsg.
&& (m_acceptMsg == nullptr || (m_acceptMsg->type() == ID_LinkToAgeMsg && m_acceptMsg->makeSafeForNet()));
Copy link
Member

Choose a reason for hiding this comment

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

I think I would prefer to see us only run makeSafeForNet() on the m_acceptMsg and not constrain on its type. That way, we're free to add more coop coordinators in the future. IIRC, TOC has something bespoke that uses coop coordinator. While they don't use DS, I think that's a good indicator that this is a useful avenue for future features.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, can do. I wanted to be safe here and keep DIRTSAND's existing behavior - before my changes here, a similar check was done in MOUL::AvCoopMsg::makeSafeForNet().

Only LinkToAgeMsg is currently used here, but we might want to use other
types in the future.
@zrax zrax merged commit 4d77e32 into H-uru:master Feb 20, 2024
4 checks passed
@dgelessus dgelessus deleted the net_safe_avatar_messages branch February 20, 2024 17:49
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