Skip to content

Add flag to serve files from a directory#138

Merged
Bash-09 merged 5 commits intoMegaAntiCheat:mainfrom
Seercat3160:Seercat/WebFilesOverride
Apr 28, 2024
Merged

Add flag to serve files from a directory#138
Bash-09 merged 5 commits intoMegaAntiCheat:mainfrom
Seercat3160:Seercat/WebFilesOverride

Conversation

@Seercat3160
Copy link
Copy Markdown
Contributor

@Seercat3160 Seercat3160 commented Apr 27, 2024

I've added the launch option --web-dir which takes a path as an argument. Using it, the client-backend will serve files for the Web UI from there, rather than using the files bundled into the executable at build time.

This, as well as providing better support for custom UIs chosen by users, lays the groundwork for having some external program manage the client-backend and webui versions separately, downloading the binary packages of each from GitHub releases, without having to recompile the client-backend each time the webui is updated. This is probably the best way to ship the client to non-technical users, as they would simply install the launcher and it would take care of all the components needed. (I'm already working on this in a private repo btw - dev team, we can talk more about this later if you want)

As always, feel free to talk to me here or on the Discord regarding this PR.

Copy link
Copy Markdown
Contributor

@Bash-09 Bash-09 left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution, this definitely has potential to be quite useful.

The initial plan for distributing the program was that there is just a single binary made available that the user just had to run, which was why it was important to bundle the UI statically with it. At times of update, the user can just download the new version and replace the binary.

Having a launcher that automatically retrieves the latest version of the binary and the UI, and dynamically serving them is certainly a possibility. Although from a security perspective I personally do not like the idea of allowing the binary to automatically fetch a new version of the program and run it without needing the user's confirmation, which would probably be the main benefit of having such a launcher. That is at least on the binary executable side, I would be less opposed to this on the UI side, although I still want to avoid having the backend coupled with the frontend specifically, which is why we don't have a build.rs script to automatically build and include it, for example.

At this point my plan is still to compile in the UI for official builds, give the user a notification if there's a new version available, and direct them to download the new file, although it's possible that will change.

That said, having this option available certainly is a great benefit still, and so I would love to merge your contribution eventually :)

@Seercat3160
Copy link
Copy Markdown
Contributor Author

Seercat3160 commented Apr 28, 2024

How does this look?

I've added conditional compilation (the include-ui Cargo feature) for whether we bundle UI files, but I've done it in a way that means no changes are needed to anyone's workflow. If ./ui/index.html exists, ./ui/ is automatically bundled. If not, it isn't. I feel this is a sensible way of doing it, so if there's no UI present at build time the client actually gives useful info about that. It also means that no changes are needed to get the best outcome in #139.

Copy link
Copy Markdown
Contributor

@Bash-09 Bash-09 left a comment

Choose a reason for hiding this comment

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

Just some very minor comments, otherwise it's looking good :)

Copy link
Copy Markdown
Contributor

@Bash-09 Bash-09 left a comment

Choose a reason for hiding this comment

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

Functionality seems to work well. I'm happy to merge with just those minor changes mentioned earlier.

@Bash-09 Bash-09 merged commit f57f225 into MegaAntiCheat:main Apr 28, 2024
@Bash-09 Bash-09 mentioned this pull request Apr 29, 2024
@Seercat3160 Seercat3160 deleted the Seercat/WebFilesOverride branch April 29, 2024 10:39
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.

2 participants