GmodNET/GmodDotNet

[ENH] Allow modules to be loaded from any folder

GlebChili opened this issue · 3 comments

Description

We should add an option to load GmodDotNet modules from any folder on disk, not only lua/bin/Modules. This can enhance development inner loop performance since users can load modules directly from MSBuild project's output folder (like bin/Debug/net5.0) without need to copy build artifacts for each update.

Implementation details

We should check if an argument of dotnet.load function is a full path to a .NET assembly and try to load it in this case.

Security considerations

Since dotnet.load is a part of GmodDotNet Lua API, server owners can potentially make clients load modules, which were not properly installed. This is problematic. Thus loading modules from arbitrary location should be an opt-in feature. I suggest to use environment variable, something like GMODNET_ALLOW_ANY_FOLDER, as a turn on switch.

I would suggest making it a Debug only option. I can't think of a case where regular server admins would need that feature.

@Stat1cV01D I think that environment variable switch should work for both servers and clients.

After some research I have decided that environment variable should be called DOTNET_ENVIRONMENT and must be activated by a value Development. This is how ASP.NET Core checks environment (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments?view=aspnetcore-5.0) and we should follow established practices. This is what was implemented in #107.