Skip to main content

Module network_files

Module network_files 

Source
Expand description

Headless network file service.

Spawned by the DLL on its FIRST request (Display_Config.exe network-files, stdin/stdout wired to two anonymous pipes), it serves the DLL’s whole session: every managed-file download and every game-write upload. The DLL performs no HTTP at all; this process owns all of it: the conditional GETs with their ETag cache and copy-if-different writes, the authoritative-404 removals, the POSTs with their transport retries, and the replay .dat analysis (moved here from the DLL, riding the push as dat_* params).

§Why a daemon

One process for the whole session instead of one per file transfer: the DLL keeps a handle on it (the pipe pair) for quick requests: a request is one short pipe write, not a process spawn. Requests are served concurrently (one worker thread each, replies tagged with the request id), so a slow body on one replay slot never starves the others.

§Not a zombie

The daemon’s main loop blocks on reading its STDIN. The stdin pipe’s write end lives in the DLL (inside the game process). When the game quits, is killed or crashes, the OS closes that write end and the next read returns EOF: the Windows equivalent of unix’s broken-pipe error. The daemon then stops accepting requests, drains the in-flight ones and exits.

§Wire format

Requests (one line, from stdin):

  <id> GET <timeout_ms> <url> <local-path>
  <id> POST <url> <local-path>

Replies (one line, to stdout):

  <id> OK|GONE|ERR <detail...>

local-path is always the LAST field (it may contain spaces); the URL never contains spaces (the mod interpolates it percent-encoded). For a GET the daemon answers OK when the remote content is mirrored on disk (freshly written, already identical or answered 304), GONE when the remote authoritatively vanished (404, it removes the stale local copy), ERR otherwise. A POST answers OK once uploaded or definitively refused, ERR when the transport kept failing.

Structs§

EtagCache
The ETag cache for conditional GETs, keyed by URL (verbatim header values; the server compares leniently). Session-scoped by design: a fresh daemon re-fetches bodies once.
LineAssembler
Incremental line assembler for the stdin stream: feed it whatever read() returned, it hands back every COMPLETE line (without the newline).

Enums§

Request
One parsed request line.

Functions§

is_replay_url
Does this managed-file URL address a replay slot? Both transfer directions key on it: pushes analyze the .dat and compress the body (the DAT-derived stamps + the compressed transfer form below), fetches announce the compressed transfer form with the capability marker (replay_fetch_url).
parse_request
Parse one request line. None for anything malformed (logged, then answered with ERR so the DLL’s waiter never hangs). Fields are space-split with the path as the LAST field (it may contain spaces); the URL is by construction a single token (the mod interpolates it percent-encoded).
run_network_files
Entry point. Serves requests until stdin closes (the hook side is gone, quit, kill or crash), then drains and exits. Never touches the GUI, the config or the update check.