This page describes the protocol used by the Map/Mod Downloader.

services

  • torrent tracker: http://tracker.caspring.org:8201/announce
  • p2p coordinator: tracker.caspring.org:8202 (tcp stream)
  • site: http://tracker.caspring.org/
  • backups: backup-tracker.licho.eu

site

The site provides torrent browsing in /torrents subfolder, each torrent named by unitsync hash. Site also provides torrent uploading (using upload_torrent.php <- put file to fname file variable).

The torrent file must contains special data in its comment: "name|type" type being MOD or MAP now and name name of mod or map from unitsync.

Site also contains and maintains several legacy files, like torrent.txt, requests.txt and battles.txt

P2P coordinator

This service runs at tracker.caspring.org:8202 - its purpose is to notify clients about new torrents and to distribute information that seeding is needed for some torrent. It can also provide "tracking" - it can take lobby user name and direct client to start downloading maps needed for his game or notify client that his spring started.

Protocol used by coordinator is similar to TasServer?, each command is one line and arguments are divided by "|" symbol. To escape | symbol in data, use this string "&divider&"

server commands

command meaning
T+|hash|name|type informs client that new torrent was added to server (type is either MOD or MAP)
T-|hash informs client that torrent was removed from server
S+|hash|seeders|leechers tells client that seed is needed for this torrent
S-|hash tells client that seed is no longer neede for this torrent
L+|hash tells client that it should leech this torrent
L-|hash tells client that he no longer needs this torrent
INGAME|mode tells client that his ingame status changed - mode is 1 or 0
PING every minute - client must respond with its own "PING"
M+|hash|url It tells the client if url is given that http mirror exists for given hash, else there are no mirrors.
IH|hash|infohash sends infohash from torrent for given spring hash. Infohash is in base64 - response to client IH command

client commands

TRACK_MAP|mode|username this tells server that client requests tracking. Mode is either "NONE", "ALL", "PLAYER"
NONE - server only informs about ingame status changes
PLAYER - server only sends leech commands for maps needed by this player (if he joins some lobby game or lobby map changes server sends leech commands)
ALL - leech commands will be sent for all currently hosted maps
TSMODE|username|mode this enables or disables automatic TS channel moves for user. Mode is either "1" or "0"
PING in response to server PING
N+|hash requests mirror list and seeding from server
N-|hash stop requesting seeding from server
IH|hash requests torrent infohash from server
SCRIPT|founder|ally|name|ally2|name2|.. sends parsed script info to server - for voice integration. Founder is name of game founder followed by ally id and then name of player for each player

basic client operations

  • Upon start or when map folder changes, torrent files are created for all maps and mods and stored in special folder. Torrents have announce address set to tracker and comment set by special rules notified earlier.
  • Client connects to p2p coordinator and coordinator and coordinator sends its list of known torrents.
  • When seed command is recieved, client starts seeding requested file (if it has it).
  • When client wants to download new file it gets torrent for it from http://tracker.caspring.org/torrents/<map hash>.torrent and starts leeching it. All other clients are notified instantly that seeding is needed using p2p coordinator.
  • New files are added to system using torrent upload to http://tracker.caspring.org/upload_torrent.php (again all clients are notified instantly through p2p coordinator that file has been added).

General remarks

  • Client should not download more than 5 torrents at once, server enforces this internally by not sending further seed requests if more than 5 files are requested.
  • Client should reannounce every 15s during first minute of leeching/seeding to ensure optimal performance and after that every minute.

Lobby integration protocol

  • You should start downloader with "-silentstart" - this prevents it from alerting user if two copies are started - instead duplicated copy quits silently
  • Downloader integrates with lobby using registry. Downloader stores its data in HKEY_CURRENT_USER\Software\SpringDownloader subtree
  • There can be multiple downloaders running at same time, each for every spring installed on computer, so actual registry key is HKEY_CURRENT_USER\Software\SpringDownloader\<SpringPathWithForwardSlashes>

Sending download request

  • 1) read value HKEY_CURRENT_USER\Software\SpringDownloader\<SpringPathWithForwardSlashes>\DownloaderPath and start executable stored there. It contains path to downloader serving that spring - you can start downloader multiple times, only one will launch for given spring path
  • 2) stored your request in HKEY_CURRENT_USER\Software\SpringDownloader\<SpringPathWithForwardSlashes>\request\<arbitraryValue> Value is of type REG_MULTI_SZ (array of strings). Name of the value should be your "tag".
    • first string is type of resource (atm "MOD" or "MAP", in the future "ENGINE" etc)
    • second string is unitsync hash of the file (in signed int format), if its 0, hash wont be used (just name)
    • third string is name of the requested file ("Balanced Annihilation 6.31")

Monitoring download status

  • when downloader accepts request, its deleted from request key and moved to transfer key
  • read value HKEY_CURRENT_USER\Software\SpringDownloader\<SpringPathWithForwardSlashes>\transfer\<arbitraryValue> Its value is of type REG_MULTI_SZ and contains these strings:
    • first string is type of resource (atm "MOD" or "MAP", in the future "ENGINE" etc)
    • second string is unitsync hash of the file (in signed int format)
    • third string is name of the requested file ("Balanced Annihilation 6.31")
    • fourth is download progress in 0-1 real number format
  • when downloader completes download, value is deleted from transfer

Controlling downloads

  • create request key with same name you used to start download and one REG_MULTI_SZ value
  • "stop" stops ongoing download
  • "display" tells downloader to show iself and display correct tab handling this download
  • "exit" tells downloader to exit

Example with real values

  • 1) run program references by HKEY_CURRENT_USER\Software\SpringDownloader\c:/programy/hry/ta spring\DownloaderPath
  • 2) create value HKEY_CURRENT_USER\Software\SpringDownloader\c:/programy/hry/ta spring\request\lobbyRequest1 with these lines:
    • MOD
    • 1385869248
    • Complete Annihilation test-2103
  • 3) keep reading value HKEY_CURRENT_USER\Software\SpringDownloader\c:/programy/hry/ta spring\transfer\lobbyRequest1 and displaying its 4th string (progress) until value is null