Hosting The Dark Mod

From The DarkMod Wiki
Revision as of 17:17, 26 May 2021 by Stgatilov (talk | contribs) (Revamped the whole article for tdm_installer and SVN-based missions downloader)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

If you want to help to distribute The Dark Mod, this article offers help on what you need to do.

How it works

The game and missions are distributed via HTTP or HTTPS only. Both tdm_installer and the in-game missions downloader do not support FTP, HTTP redirects, meta-refreshes or other methods.

When the game itself is installed or updated, first tdm_installer.ini is downloaded. This file contains a list of mirror servers. Each mirror has weight, which defines probability that it will be used for a request. The weights can be used to distribute traffic across mirrors. See also: Tdm installer and zipsync

The in-game mission downloader downloads available_missions.xml, which contains list of URLs and their weights for every mission. The weights also define probability of each URL being used in a request. The XML file is generated from various XML files in the missions SVN repository. See also: Mission Database

What you need

  • A server with fast connection, preferably with either unlimited traffic, or at least 1000 GB per month.
  • Space: 6 GB for the game mirror, 10 GB for the missions mirror (about 20 GB is enough for both).
  • Synchronization with main server is done via rsync pull at regular intervals (once per day or week).
  • The server must respond to individual file requests via HTTP with a "200 OK" and the content. Things like redirects (302, 307 etc.) as well as intermediate HTML pages (meta refresh), or FTP are not supported.
  • Game mirror must also support multipart byterange requests. Missions mirror does not need to support byteranges at all.

Set up hosting

Here is the generic process of adding a mirror:

  1. Get in contact with TDM team about mirror hosting.
  2. Send IP address of your server to TDM server admin, so that he adds it to the whitelist for rsync access.
  3. Configure your server to perform rsync pull regularly (e.g. every day). Ask admin about rsync address to pull from.
  4. After all data is rsync-ed successfully, send base URL (where it is served at) to TDM release manager for testing.
  5. If everything works fine, then TDM release manager adds your mirror to config file, and players start using it.

Traffic

Please pay attention to additional traffic on your mirror:

  • for one month after the mirror is enabled;
  • for one month after a major release of TDM;

The initial amount of traffic can be pretty high, and there are typically traffic spikes shortly after every major release of the game. Make sure you won't have to pay extra money and won't get your server down.

If amount of traffic is too high for you, contact TDM team. It is possible to reduce weight of your mirror, then players will use it with less probability, and the traffic should decrease proportionally. Here is how exactly it can be done:

  • For game mirror: file tdm_installer.ini stores weights for every mirror. It can only be updated via SSH access to the main TDM server.
  • For mission mirror: file mirrors/mirrorinfo.xml in missions SVN repository supports "weight" attribute near "rootUrl" (default = 1).

Some interesting tendencies about traffic:

  • Tdm_installer always updates the game in differential fashion, so updates are cheap: 20 MB between close versions, hundreds of MB between major releases. However, clean install takes about 4 GB of traffic.
  • In-game mission downloader provides an easy way to download all FMs, which is very likely to increase traffic on mission mirrors. Aside from that, some recent missions are quite heavy by themselves.

Bots

What costs traffic, however, are bots, who are either blindly following links, or traversal directories on your server. Here are a few tips to keep them out and your traffic low:

  • disallow directory traversal on your server. If you can open http://yourserver/thedarkmodfiles/ on your server and see a listing, it is still enabled.
  • use a robots.txt to keep Google, Bing, Yahoo, Baidu etc out of this directory (better disallow all robots)
  • disallow anything that has a known bot or spider signature (wget, Java, libwww, common bot names, or anything that has a referrer of the file itself (PK4 files cannot be referring to themselves).

If all else fails, you can block everything except TDM programs by user agent:

  • Tdm_installer has user agent: tdm_installer/1.04 (version after slash changes over time).
  • In-game mission downloader has user agent: The Dark Mod Agent/2.09 Win32 (everything after slash may vary).

Note that blocking by user agent is rather inconvenient, since TDM team will not be able to test your mirror by inserting direct URL into browser or curl tool.

See also