[Suggestion] Enable downloading addons from a server-provided URL
This is something I'm very surprised isn't already a feature. Currently, the only way for the client to automatically download required addons is if the server itself sends them. This means it can only download as fast as the server can upload, and the process can also cause lag under certain conditions.
But I think this can be fixed pretty easily: let the server send a URL as an alternative to sending the entire file. Then, the client can fetch the needed content from that URL, instead of the game server having to do the heavy lifting.
As for how the server will know what URL to send to clients, here's how I'd do it if I was more familiar with the codebase:
-
First, the server host can create a file listing addon filenames paired with URL's. This file could have a fixed name, or it could be set via a console variable. Whenever a client requests an addon, and this config file exists, it will first look there for the URL.
-
If no URL list file is provided, or a client requests a file that is not listed there, the server will then look inside its own copy of the addon for a
DOWNLOAD
lump, containing the necessary information. This could possibly contain multiple URL's, so if the client fails to download from one of them, it can ask the server for a different URL. The client could also report a download failure from a URL provided by the first list, and that could be another situation in which it falls back to theDOWNLOAD
lump. -
If no
DOWNLOAD
lump is found, or the client fails to download from the provided URL(s), the client will query the Master Server with the MD5 hash of the needed file, and if an addon with that hash exists in Addons & More (assuming the official MS), it will return the file's URL, and the client will download from there. -
If the Master Server doesn't know about the file, or the client can't download from that URL either, it will ask the server to upload the file, at which point the process will proceed as it does currently. (i.e. the server will send the file if downloading is enabled; otherwise the player will get the error saying it doesn't have the needed files.)