googleforgames / quilkin

Quilkin is a non-transparent UDP proxy specifically designed for use with large scale multiplayer dedicated game server deployments, to ensure security, access control, telemetry data, metrics and more.
Apache License 2.0
1.29k stars 94 forks source link

Allow loading external Rust Filters dynamically #420

Open markmandel opened 3 years ago

markmandel commented 3 years ago

Context:

If the filter traits were moved to another crate, filters could be defined in separate crates and loaded by Quilkin at runtime. That would be much more reasonable for users.

Originally posted by @XAMPPRocky in https://github.com/googleforgames/quilkin/issues/401#issuecomment-934577495

This is an issue to track this idea, as I think it's definitely got value for sure. I'm sure @XAMPPRocky you know more about this than I do. I couldn't find a particularly clear guide.

Here are the resources I found:

XAMPPRocky commented 3 years ago

I hadn't looked at stable_abi closely before, it seems interesting and worth investigating. I think we should discuss what kind of behaviour we expect from the runtime loading. Here are a couple of open questions that come to mind.

markmandel commented 2 years ago

Where do we store the plugins?

My suggestion: make the folder to search (I'm assuming there may be more than one plugin loaded at once) configurable through the config yaml, but with a default of a separate relative directory from the main binary.

I'm inclined towards startup only for simplicity and security.

100% concur. Runtime replacement of code scares me. 😱

What context do we send across the FFI boundary?

I expect this will require experimenting with abi_stable_crates and seeing what is possible, and how close it might come to our existing context data.

Side thought: Assuming all goes to plan with #411 -- would that make things harder to load an external plugin, as we no longer have a context object (or would we need to fabricate one just to allow external loading of code?) Again, might just require some experimentation to see what is possible.

markmandel commented 1 year ago

https://robert.kra.hn/posts/hot-reloading-rust/

Was just reading this - based on work Bevy has been doing