Networking and data services
Networking and data services provide the client with the shared support needed to acquire remote data, understand torrent metadata, and enrich peer addresses. They connect user actions and Transmission data to external network services while keeping the main desktop workflows focused on torrent control. The detailed remote download and bencode flow is described in Remote downloads and bencode, and the peer address enrichment flow is described in IP resolution and geolocation.
Service boundaries
The supporting services form two related paths. One path obtains and interprets data before it reaches Transmission. The other adds readable network context to peer data already returned by Transmission.
Supporting service map
Each service has a clear input and output contract. This keeps network access, data interpretation, and user-facing display separate even when one user action crosses more than one service.
| Service | Input | Result | Main consumer |
|---|---|---|---|
| HTTP acquisition | A supported remote URL | A local file or an error | Torrent intake and support-data setup |
| Address lookup | A peer IPv4 address | A host name, with the address as fallback | Peer list |
| Geographic enrichment | A peer IPv4 address and a local GeoIP database | Country name and country code | Peer list and country flag display |
| Bencode parsing | A torrent metadata stream | Typed torrent values and selected metadata | Torrent intake and tracker handling |
References: download.pas• L91-123 bencode.pas• L39-80 ipresolver.pas• L58-89 main.pas• L6659-6733
Shared network assumptions
The client uses one HTTP model for its supporting downloads and its daemon communication. URLs can use HTTP or HTTPS. A configured HTTP proxy can route requests, and HTTPS depends on the available OpenSSL libraries. These choices affect both torrent acquisition and optional support data such as the GeoIP database and flag archive.
The HTTP layer also separates the response body from its status and headers. Callers can therefore decide whether the returned data is suitable before they pass it to a file or parser.
References: download.pas• L97-123 download.pas• L151-188 rpc.pas• L1287-1304 synapse/…/httpsend.pas• L127-158 synapse/…/httpsend.pas• L187-213
Remote data acquisition
Remote data acquisition turns a URL into a controlled local input. The client fetches the data in a worker, reports progress in a modal download view, and returns success only after the destination is complete. A failed or canceled transfer does not remain as a usable partial file.
Download uses
The same acquisition service supports more than torrent links. Torrent intake uses it to fetch a remote torrent file, while setup uses it to obtain compressed geographic data and the flag archive. The caller chooses the destination and display name, so the service can serve both user-started downloads and internal support-data updates.
References: download.pas• L91-123 main.pas• L2504-2513 main.pas• L3180-3221 main.pas• L3955-3980
Acquisition flow
The acquisition flow keeps transport errors at the network boundary. The next service sees either a complete local artifact or a failure and does not need to interpret an incomplete response.
flowchart LR
A[Remote URL] --> B[HTTP or HTTPS request]
B --> C{Successful response?}
C -->|Yes| D[Complete local data]
C -->|No or canceled| E[Error and cleanup]
D --> F[Metadata parser or support-data loader]
References: download.pas• L127-189 synapse/…/httpsend.pas• L384-513
Address and geographic enrichment
Address and geographic enrichment adds human-readable context to peer rows without changing the peer data received from Transmission. An IP address remains the stable source value. The client can add a host name and country details when the user enables those views.
Peer enrichment
The peer list asks the resolver for each peer address while it refreshes peer data. The resolver keeps one cached entry per address and returns the address immediately as the initial host value. When name lookup is enabled, a background worker later publishes a complete host-name snapshot without changing strings in a snapshot already returned to the peer view.
Country lookup uses a local GeoIP database during entry creation. Concurrent country lookups are serialized so the shared database stays safe. The resolver also keeps UI-owned display metadata shared across refreshed snapshots, so a later host-name result does not discard related peer-row state.
This design lets the peer list remain useful when name lookup is slow or unavailable. Rows can show the raw address first and later show the resolved host name. Country names and flag images are optional display enrichments rather than requirements for peer tracking.
References: ipresolver.pas• L58-89 ipresolver.pas• L143-191 ipresolver.pas• L193-263 ipresolver.pas• L337-395 main.pas• L6659-6733
GeoIP data lifecycle
Geographic enrichment depends on a local country database. The client looks for that database in the user data area or beside the program. If it is missing or the user requests an update, the client can download compressed data, unpack it into the local database, and release the active resolver before replacement.
The country lookup layer accepts an IPv4 address and returns a country code and name when the database has a match. It can report no data without blocking the rest of the peer row.
References: main.pas• L3170-3221 GeoIP.pas• L53-100 GeoIP.pas• L368-391 ipresolver.pas• L265-286 ipresolver.pas• L337-395
Torrent data interpretation
Torrent data uses bencode, a compact format that represents strings, integers, lists, and dictionaries. The parser changes a byte stream into a typed value tree so the client can inspect torrent identity and tracker metadata before it sends the torrent to Transmission.
Metadata handoff
The add flow uses the parser for local or downloaded torrent files. It can read the info value to derive the torrent identity and inspect announce-list or announce to find tracker data. After this inspection, the original torrent bytes continue to the Transmission add request through the normal RPC path.
Magnet links use a different boundary. They carry an identity and optional tracker hints directly, so they do not need a torrent file to be parsed by the client before Transmission resolves their metadata.
References: main.pas• L2476-2558 main.pas• L2628-2662 main.pas• L2728-2757 main.pas• L2802-2859
Data integrity boundary
The bencode parser accepts only complete values with valid type markers and lengths. Invalid torrent data raises an error before the client uses its metadata. A parsed value can also be encoded again, which lets the client derive the identity from the exact info value rather than from a display name or file path.
References: bencode.pas• L68-80 bencode.pas• L106-234 bencode.pas• L236-274 main.pas• L2514-2526
Downstream relationships
These services support higher-level client flows rather than owning them. Torrent intake owns the choice of source and the final RPC add request. The peer view owns the presentation of enriched values. The support-data setup owns database and flag updates.
The boundaries matter when a service changes: acquisition must preserve complete-file behavior, parsing must preserve torrent identity and tracker meaning, and enrichment must preserve the raw peer address when optional lookups fail.
Child workflow pages
Use the child pages for the two main service paths:
- Remote downloads and bencode explains URI intake, HTTP download behavior, magnet handling, bencode parsing, and tracker metadata.
- IP resolution and geolocation explains peer address lookup, GeoIP data, caching, and country presentation.
References: main.pas• L2422-2436 main.pas• L2438-2558 main.pas• L6659-6733
Change checklist
When these files or sections are changed, remember to consider these:
- Keep remote download callers aligned with the complete-file and cleanup contract.
- Keep HTTPS library checks and proxy settings consistent across daemon requests and supporting downloads.
- Keep the GeoIP database replacement path aligned with resolver lifetime and the peer list's optional country fields.
- Preserve the raw peer address as a usable fallback when asynchronous name lookup or country lookup fails.
- Preserve complete peer snapshots and shared display metadata when background name lookup publishes an updated result.
- Keep bencode field interpretation aligned with torrent identity, tracker fallback, and the later Transmission add request.
- Keep links to the child pages aligned with the split between remote torrent data and peer metadata enrichment.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| HTTPS support libraries are not available | A remote torrent or support-data download cannot start | Check OpenSSL availability before an HTTPS download |
| A request fails, returns a non-success status, or is canceled | The caller receives no usable downloaded file | Report the error and remove the partial destination |
| The GeoIP database is missing, unreadable, or has no matching address | Country fields remain empty while the peer address can still display | Treat country data as optional and keep the IP value as the fallback |
| Host-name resolution is slow or fails | A peer row shows its IP address instead of a host name | Resolve in the background and retain the cached address entry |
| A background host-name result updates a cached peer | A refreshed row can lose or expose partial peer data | Publish a complete replacement snapshot and keep display metadata in shared cache state |
| Torrent bytes contain invalid bencode | Metadata inspection stops before the add or tracker flow | Reject malformed stream input at the parser boundary |
Key files
| File | Why to read it |
|---|---|
download.pas | Defines the shared user-visible HTTP acquisition contract, including progress, cancellation, and cleanup. |
bencode.pas | Defines the typed torrent data model and the parse and re-encode boundary. |
ipresolver.pas | Defines cached peer address enrichment, background name lookup, serialized country lookup, and stable peer snapshots. |
GeoIP.pas | Defines the local geographic database interface and country result behavior. |
main.pas | Shows how the client connects these services to torrent intake, support-data setup, and the peer list. |
synapse/source/lib/httpsend.pas | Defines the shared HTTP, HTTPS, proxy, response, and transfer behavior used by the client. |
synapse/source/lib/synaip.pas | Defines the IP address validation and conversion support used by network address handling. |
utils.pas | Provides the UTF-8-aware file and stream support used for downloaded and local service data. |