Skip to content

Latest commit

 

History

History
438 lines (376 loc) · 35.9 KB

api.md

File metadata and controls

438 lines (376 loc) · 35.9 KB

Tether relay API (tether-api) — wire contract

The contract between the technician app (apps/desktop), the customer module (apps/quick), the management app (apps/manage) and the relay service (server/api). Shared types and crypto live in crates/tether-trust; do not reimplement them.

Base URL: https://<relay> (production https://tether-desk.duckdns.org). With several servers (compiled-in TETHER_SERVER list plus policy servers.list) clients use the first one that answers, the last one that answered first; every server must serve the same API and releases. Caddy routes:

  • /api/* → tether-api on 127.0.0.1:21120
  • /download/* → static files in /var/lib/tether-api/download/ (served by Caddy file_server; latest.json with Cache-Control: no-cache)
  • / → /var/lib/tether-api/download/index.html (the download page)
  • /ws/id and /ws/relay are unchanged.

Clients reach the API through the same route racer as the relay (443/80, proxy/direct), using the system proxy. Everything is TLS; plain HTTP is never used.

Keys

Key Holder Public half lives in
Admin key (Ed25519) management app, encrypted at rest clients: compile-time TETHER_ADMIN_PUB_KEY (base64); server: ADMIN_PUB_KEY in /etc/tether/api.env
Updater key (Tauri minisign) management app, encrypted at rest compile-time TETHER_UPDATER_PUB_KEY (technician app and customer module)
Server key (Ed25519, hbbs/hbbr) relays (/var/lib/tether/id_ed25519); new ones generated by the management app for a rotation clients: compile-time TETHER_PUB_KEY, replaced by the signed server key list below (key-rotation.md)

Several admin public keys may be trusted (comma-separated) to allow key rotation.

Signed documents

tether_trust::envelope::Signed JSON: {"payload": b64(bytes), "sig": b64(sig), "key": b64(pubkey)}. The payload of a policy document is the JSON of tether_trust::policy::Bundle; of a server key list, tether_trust::serverkeys::KeyList: {"serial":3,"issued_at":…,"keys":[{"key":"<b64>","not_before":0,"expires":0}]} (1–8 keys, at least one without expires; the first active key is the one clients present).

Public endpoints (no auth)

GET /api/policy

Returns the stored signed policy document (application/json), or 404 if none was published. Clients verify it with envelope::open_json(raw, &[admin keys]), parse with Bundle::from_json, reject serial lower than the last accepted one (stored locally), then policy::resolve. Response header ETag: "<serial>"; clients send If-None-Match and get 304 when unchanged.

GET /api/server-keys

The signed server key list (404 if none was published), served and cached like the policy: ETag: "<serial>", If-None-Match → 304. Clients verify it with the admin keys (serverkeys::KeyList::open), reject a serial lower than the cached one or the stored floor (serverkeys::accept, server-keys.serial), fetch it before every policy check and cache it as server-keys.json. Clients stop reading after 16 KiB + 1 byte (tether_trust::read_limited); the policy is read the same way with its own limit. See key-rotation.md.

POST /api/heartbeat

Body (JSON, ≤ 2048 bytes, unknown fields rejected):

{"uuid":"<install uuid, 8-64 [A-Za-z0-9-]>","id":"<Tether ID, ≤ 32>","profile":"technician|customer",
 "version":"0.3.0","os":"windows 10.0.26300","serial":12,"server_keys_serial":3}

server_keys_serial (optional, default 0): the server key list the device applied. Clients send it only once they have a list, so relay APIs from before it keep accepting their heartbeats. Optional update fields (clients send them only to a relay that answered {"releases": …}, and retry without them on a 400): release_serial (release index serial the device accepted), update_state (idle, waiting-rollout, downloading, staged, waiting-idle, failed, stale, halted), update_version (the version in flight). 200 {"releases": G} on success (relays before 0.5.24: 204, no body): G is the relay's release generation, bumped by every change of a releases.json or latest.json. A client that sees it change checks for updates (after a random delay); it is unsigned and only triggers a fetch. Clients up to 0.5.23 accept any 2xx and ignore the body. 429 when the same uuid posts more than once per 60 s, or when one IP sends more than 30 heartbeats per minute for uuids the relay does not know yet (known devices are not counted per IP; an IPv6 client counts as its /64, see "Limits"). The server stores {…, "ip": <client ip from X-Forwarded-For>, "last_seen": unix} per uuid, at most 50 000 devices (oldest last_seen evicted; ~30 MB of memory, scaling.md), entries older than 180 days dropped. Clients send it after each policy check.

POST /api/diag/<ticket>

Upload a diagnostics zip for a ticket an admin opened. <ticket> is 8 characters [A-HJ-NP-Z2-9] (no ambiguous letters). Body application/zip, ≤ 2 MiB. 204 if the ticket is open (state open, below) on this relay, else 404, answered before the body is read: body not found when the relay does not know the ticket, ticket not open when it is used, expired or closed there. One upload per ticket. Upload limits as for release uploads ("Limits" below): 503 with Retry-After: 30 while 4 diagnostics uploads run, 413 over 2 MiB, 408 below the minimum rate, 400 request body incomplete when the client went away before its Content-Length arrived (the ticket stays open; up to 0.5.26 such a truncated body was stored and used the ticket up).

Tickets are per relay: Tether Manage opens the same code on every relay it knows, and an app uploads to the relay it reaches. The apps (0.5.27 and later) try every relay in turn: on to the next after 404 not found or 503, stop at ticket not open (so a used code gets no second upload on another relay); Manage lists the tickets of all relays merged and finds the upload.

Ticket states (state in the admin listing):

State Meaning Uploads Kept
open created, no upload yet, younger than 24 h accepted (one) –
uploaded the zip is there 404 7 days after the upload
expired 24 h passed without an upload 404 listed until 7 days after creation
closed closed by an admin (archived), with its zip if there was one 404 90 days after closing

open → uploaded → closed, open → expired → closed. After its keep time a ticket and its zip are removed (checked every minute). DELETE removes one at once, in any state.

POST /api/audit/conn, POST /api/audit/file, POST /api/audit/alarm (session audit log)

The host side of every Tether app (vendor/rustdesk/src/server/connection.rs, post_conn_audit / post_file_audit / post_alarm_audit, RustDesk Pro shape) posts one record per event to <api-server>/api/audit/<kind>. api-server is https://<first TETHER_SERVER host> (netpolicy.rs), so every host posts to the first relay of its build, through Caddy's /api/* route; Tether Manage reads every relay and merges. Bodies (JSON, ≤ 8 KiB, unknown fields rejected), all with "id" (Tether ID, ≤ 32), "uuid" (base64 machine uuid, ≤ 128; not the heartbeat install uuid), "conn_id" (per-process connection number) and "nonce" (unique per record, ≤ 64 [A-Za-z0-9-]):

conn, TCP connection opened:  {"action":"new","ip":"<technician ip>","session_id":0,…}
conn, technician logged in:   {"peer":["<technician id>","<technician name>"],"type":0,"primary_auth":1,"two_factor":1,"session_id":<u64>,…}
conn, connection closed:      {"action":"close","session_id":<u64>,…}
file, files sent/received:    {"peer_id":"…","type":0,"path":"<folder or file>","is_file":false,
                               "info":"{\"ip\":\"…\",\"name\":\"<technician name>\",\"num\":12,\"files\":[[\"name\",size],…≤10]}",…}
alarm (whitelist block, …):   {"typ":0,"info":"<JSON text ≤ 1024>",…}

type (conn): 0 remote, 1 file transfer, 2 port forward, 3 camera, 4 terminal. type (file): 0 = the host sent files to the technician, 1 = the host received files. primary_auth: 1 click, 2 one-time password, 3 permanent password, 4 switch sides. Optional conn_audit_ref (≤ 128).

Answers: 204 with an empty body when stored (also when the same nonce was stored in the last 10 minutes: a client retry), 400 invalid (the client drops it), 413 too large, 429 more than 120 posts/min from one IP (IPv6: one /64) or 60/min from one device uuid (the client retries 429 and 5xx for up to 120 s), 507 disk low or the log at its size cap. Not authenticated: see SECURITY.md "Session audit log". Records never change devices, policy or anything else on the relay.

Stored record (one JSON line in audit/<YYYY-MM-DD>.jsonl, UTC day; files 0600): {"ts": <server unix time>, "src": "<poster ip from X-Forwarded-For>", "kind": "conn|file|alarm", "action": "connect|login|disconnect|send|receive|alarm", "id", "uuid", "conn_id", "nonce", …} plus, when present: session_id (string, u64), ip (technician address as the host saw it), peer_id, peer_name, conn_type (remote, file_transfer, port_forward, view_camera, terminal), primary_auth (click, temporary_password, permanent_password, switch_sides), two_factor, ref, path, is_file, num, files, typ, info.

Retention (/etc/tether/api.env, read at start): AUDIT_RETENTION_DAYS (default 90; whole UTC days; 0 = accept and store nothing), AUDIT_MAX_MB (default 50; above it the oldest days are deleted, never today's; if today's file alone reaches the cap, new records get 507). Applied at start and every minute.

Admin endpoints (signed requests)

Every request carries Tether-Sig: v2 host=<relay host> ts=<unix secs> nonce=<16-64 [A-Za-z0-9]> sig=<b64> (tether_trust::reqauth). The signed message is

tether-admin-v2\n<host>\n<METHOD>\n<path with query>\n<ts>\n<nonce>\n<hex sha256 of the body>

<host> is the relay the request is for (reqauth::host_of: the host of its base URL, lower case, without scheme, port and path), so a captured request is worth nothing at another relay. host_of accepts only a plain host name or an IPv6 literal, with an optional numeric port; anything else (a user name, \, %, spaces) names no host, and no relay accepts that. The body hash covers the exact bytes sent. The server verifies against every trusted admin key (strictly: a weak key or a non-canonical signature never verifies), allows ±300 s clock skew, and rejects a nonce seen in the last 601 s (longer than the whole window a signature is accepted in). The nonce of a release upload is remembered for about 70 minutes, longer than the slowest upload the server lets finish, so a captured upload cannot be replayed as a slow upload that ends after the nonce was forgotten. Failure: 401 with a short reason. Bodies over the limits: 413.

The relay must know its own name. tether-api accepts a v2 signature only when host is one of the names in its environment variable RELAY_HOST (comma-separated; an entry may be a host name or a URL). install.sh writes it to /etc/tether/server.env, which tether-api.service reads (api.env, read after it, may override it); the Helm chart sets it from publicUrl. Without RELAY_HOST every v2 request gets 401 (this relay does not know its own host name …) and tether-api logs warning: RELAY_HOST is not set at start. A request signed for another name gets 401 request signed for another relay.

v1 (apps before this change). Tether-Sig: v1 ts=… nonce=… sig=… has no host= and signs tether-admin-v1\n<METHOD>\n<path>\n<ts>\n<nonce>\n<body hash>. A relay accepts it until TETHER_SIG_V1=off is set in /etc/tether/api.env (then: 401 v1 signatures are switched off on this relay: update the app). While v1 is accepted, a captured v1 request can be replayed at another relay that trusts the same key within ±300 s (each relay keeps its own nonces). Tether Manage and the technician app (team requests) sign v2 and follow no HTTP redirects. They never fall back to v1 by themselves. Rollout order: first every relay, with RELAY_HOST set to the host name(s) entered for it in Tether Manage; then Tether Manage and the apps; last TETHER_SIG_V1=off on every relay.

Used nonces are stored in nonces.json, so a restart does not reopen the replay window. When that file cannot be written (disk full) the request still succeeds and the error is logged; the nonce keeps blocking replays in memory.

Method & path Body Result
PUT /api/admin/policy signed policy document (≤ 256 KiB) 204. The server also verifies the signature, validates the bundle strictly (Bundle::validate; 400 for an unknown feature, a bad value, an update.minimum-version that is not empty or a version, an update.channel that is not empty or a channel name) and requires serial > current (409 otherwise). Stored atomically, previous versions kept in policy-history/<serial>.json (last 50).
PUT /api/admin/server-keys signed server key list (≤ 16 KiB) 204. Verified against the admin keys, validated (KeyList::validate), serial > current (409 otherwise). Stored as server-keys.json.
GET /api/admin/policy-history – [{"serial":…, "issued_at":…}] newest first
GET /api/admin/policy-history/<serial> – the signed document exactly as published (404 if not kept)
GET /api/admin/devices – [{uuid,id,profile,version,os,serial,server_keys_serial,ip,last_seen}]
POST /api/admin/diag-ticket {"note":"…"} (≤ 256 chars) {"ticket":"K7Q2M9XD","expires":unix} (open 24 h)
GET /api/admin/diag[?archived=1] – [{ticket,note,created,uploaded,size,state}]: tickets not closed (open, uploaded, expired); with ?archived=1 the closed ones, each with closed (unix). Other parameters: 400. Relays before 0.5.27 ignore the query and send all, without state.
GET /api/admin/diag/<ticket> – the zip (application/zip, also of a closed ticket) or 404
POST /api/admin/diag/<ticket>/close – 204: the ticket is closed (archived), uploads get 404, kept 90 days with its zip. Closing again: 204, no change. Unknown: 404. Journal line diag ticket <code> closed.
DELETE /api/admin/diag/<ticket> – 204: ticket and zip removed for good, in any state. Unknown (or deleted already): 404. Journal line diag ticket <code> deleted.
PUT /api/admin/release/<channel>/<path> file bytes (≤ 200 MiB) 204. Writes download/<channel>/<path> atomically. <channel> [a-z0-9-]{1,32}; <path> segments [A-Za-z0-9._-], no ... Upload artifacts first, latest.json last. Refused before the body is read: admin API off (503), bad path (400), no Tether-Sig or its ts outside ±300 s (401); the signature itself is checked after the body arrived, its ts against the time the upload began (a slow upload may outlast the skew). At most 4 release uploads at once (503, Retry-After: 30); diagnostics uploads have their own 4 slots. The slot is granted on the unverified header, see "Limits".
DELETE /api/admin/release/<channel>/<path>[?force=1] – 204; 404 if missing. 409 "published release: …" for releases.json, any latest.json, and every file of the version the channel's release index or the folder's latest.json publishes, unless ?force=1 (part of the signed URL). Forced deletes are logged (release-prune.jsonl, journal).
POST /api/admin/releases/prune JSON (≤ 64 KiB, below) Release clean-up: the plan (dry_run: true) or the deletion of the listed versions (below).
GET /api/admin/releases – [{channel,path,size,modified}]
PUT /api/admin/download-page HTML (≤ 512 KiB) 204, stored as download/index.html
GET /api/admin/audit?since=<unix>&limit=<n>&device=<id or uuid> – Session audit records (above), newest first. All optional: since (default 0), limit 1–5000 (default 1000), device matches id or uuid exactly (URL-encoded). Unknown parameter or bad value: 400. One answer holds at most about 8 MiB of records; when older ones were left out for that, it carries the header X-Audit-Truncated: 1 (the Sessions page of Tether Manage then names the relay).
GET /api/admin/status – {version, disk_free, devices, policy_serial, server_keys_serial, release_generation, release_indexes: {<channel>: {serial, expires}}, uptime, last_prune: {time, files, bytes} | null}
PUT /api/admin/team team roster (≤ 64 KiB, below) 204. Validated (tether_trust::team::Roster::validate), stored atomically as team/roster.json (0600). {"members":[]} turns team access off.
GET /api/admin/team – the roster ({"members":[]} when none)

The server refuses uploads that would leave less than 2 GiB free on the disk (507).

Team (technician) endpoints

Technicians do not hold the admin key. Each technician app generates its own Ed25519 key; the admin adds the public key to the team roster in Tether Manage and publishes it to every relay (PUT /api/admin/team). The roster (tether_trust::team, unknown fields rejected):

{"members":[{"name":"Anna Berger","key":"<std base64 of the 32-byte public key>","write":true,"audit":false}]}

At most 500 members; name 1–64 characters, no control characters, no leading or trailing spaces; key a valid Ed25519 public key; keys unique; all four fields required. Both apps show a key as its fingerprint: hex(sha256(raw 32-byte key)), first 16 hex digits, uppercase, in groups of 4 (630D-CD29-66C4-3366 for the key bytes 00 01 … 1f; tether_trust::team::fingerprint).

Member requests carry the same Tether-Sig header as admin requests (same message, v2 or v1 under the same rules, ±300 s skew), signed with the member's key. The relay tries every roster key; the nonce cache is the one admin requests use. Unknown key, bad signature, no roster or an empty roster: 401 with a short reason. Limits: 120 requests/min per member key and 60 failed signatures/min per IP (IPv6: per /64; 429). Unknown path: 404.

Method & path Body Result
GET /api/team/me – {"name":…, "write":bool, "audit":bool}
GET /api/team/devices – [{uuid,id,profile,version,os,last_seen}] newest first, from the heartbeats (no IP, no serials)
GET /api/team/tags – {"rev":<u64>,"doc":<JSON or null>,"updated_by":"<name>","updated_at":<unix>}; rev 0, doc null, updated_by "" and updated_at 0 when none was stored
PUT /api/team/tags a JSON object (≤ 512 KiB), header If-Match: <rev> (decimal, quotes tolerated) 200 {"rev":<new>}. Member without write: 403. Missing or bad If-Match, body not a JSON object: 400. rev is not the current one: 409 with the current {"rev","doc","updated_by","updated_at"}. Too large: 413. Stored atomically as team/tags.json (0600) with rev + 1, updated_by = the member's roster name. The relay does not look inside the document.
GET /api/team/audit?device=<id or uuid>&since=<unix>&limit=<n> – Session audit records of one device, same format as GET /api/admin/audit, newest first. Members with audit only (else 403). device required (400 without); since default 0; limit 1–500, default 200; unknown parameter 400.

The roster is per relay: publish it to every relay (Tether Manage does). Tags are stored per relay too: a client should read and write them on one relay (the first that answers).

Download layout and update manifests

download/
  index.html                                  download page
  <channel>/technician/windows-x86_64/latest.json
  <channel>/technician/windows-x86_64/Tether_<v>_x64-setup.exe(.sig)
  <channel>/customer/windows-x86_64/latest.json
  <channel>/customer/windows-x86_64/TetherQS-<v>.exe(.sig)   versioned, so uploads never touch the live file
  <channel>/technician/darwin-universal/latest.json
  <channel>/technician/darwin-universal/Tether_<v>_universal.app.tar.gz(.sig)   updater archive
  <channel>/technician/darwin-universal/Tether_<v>_universal.dmg(.sig)          manual download
  <channel>/customer/darwin-universal/latest.json
  <channel>/customer/darwin-universal/TetherQS-<v>-universal.zip(.sig)          zipped .app

Each platform folder has its own latest.json (the technician app requests …/technician/{{target}}/latest.json, {{target}} = windows-x86_64 or darwin-universal). A macOS manifest lists the universal build under darwin-universal, darwin-aarch64 and darwin-x86_64. Tether Manage reads the existing latest.json before writing it: platform entries of the same version are kept, entries of another version are replaced. Channel default stable (policy feature update.channel). latest.json is the Tauri updater format plus three optional fields:

{"version":"0.3.1","notes":"…","pub_date":"2026-11-04T10:00:00Z",
 "platforms":{"windows-x86_64":{"signature":"<minisign sig, as Tauri writes it>","url":"https://…/Tether_0.3.1_x64-setup.exe"}},
 "mandatory":false,"minimumVersion":"","forced":false}
  • mandatory: the update must be installed before the app can be used for sessions.
  • minimumVersion: versions below it are blocked (same effect as policy update.minimum-version).
  • forced: install without asking after update.restart-seconds. Clients enforce the stricter of manifest and policy. Blocking is done in the backend (session start, accepting incoming sessions), not only in the UI.

Release clean-up (POST /api/admin/releases/prune)

Design and rationale: release-cleanup.md. Per relay, per folder download/<channel>/<app>/<platform>/, a version is the set of files tether_trust::release::file_version assigns to it (artifact, .sig, TetherQS .exe.gz, mac .dmg + .dmg.sig). A version is kept when any of these holds (reason in why):

why Rule
index the version of <app>/<platform> in the channel's releases.json (halted or not, any rollout percent; verified with the key it names)
latest.json the version in the folder's latest.json
newer above the published one (the higher of the two above), or nothing is published in the folder
previous one of the keep newest versions below the published one (keep 0-20, default 2)
download page a file of it is linked from download/index.html
pinned named in pin (Tether Manage pins every version in its cdn-assets.json)
recent a file of it was modified in the last 24 h
unreadable release index or latest.json the folder's releases.json / latest.json cannot be read: nothing in it goes

Everything else is dropped as whole versions. Files no release name matches (latest.json, releases.json, index.html, anything unknown) are never touched.

Dry run: {"dry_run": true, "keep": 2, "pin": [{"channel":"stable","dir":"customer/windows-x86_64","version":"0.5.23"}]} →

{"keep_older":2,"drop_bytes":2054613901,"drop_files":190,"kept_bytes":204116694,
 "groups":[{"channel":"stable","dir":"customer/windows-x86_64","published":"0.5.24","index_serial":8,
   "keep":[{"version":"0.5.24","files":["TetherQS-0.5.24.exe","…"],"bytes":69797888,"why":["index","latest.json","download page"]}],
   "drop":[{"version":"0.5.21","files":["TetherQS-0.5.21.exe","TetherQS-0.5.21.exe.sig"],"bytes":34898944}]}]}

Execute: {"dry_run": false, "keep": 2, "pin": […], "delete": [{"channel":…,"dir":…,"version":…}]}. The relay recomputes the plan (under its state lock, so no upload runs in between) and deletes only versions that are both in delete and in its own drop list; empty folders are removed. Answer: {"deleted":[{channel,dir,version,files,bytes}], "kept":[{channel,dir,version,"result":"kept",why}], "gone":[{channel,dir,version,"result":"gone"}], "failed":[{channel,dir,version,error}], "freed_bytes":n}: kept = protected now (e.g. published since the dry run), gone = no such version (already deleted: repeating an execute is safe). 400 for keep > 20, an execute without delete, or unknown fields. Each execute writes a journal line (release prune: …) and a record to release-prune.jsonl in the data dir (last 100 records, with the deleted versions; forced DELETEs are recorded there too).

Release index (download/<channel>/releases.json)

Written by Tether Manage (PUT /api/admin/release/<channel>/releases.json, signed request) before the latest.json files. tether-api accepts it only if it is a tether_trust::envelope::Signed document from a trusted admin key, of type tether-releases/1, for the channel of its path, with a serial above the stored one (409 otherwise; the identical document again is 204). Served by tether-api (Caddy and nginx route GET /download/<channel>/releases.json and releases-v2.json to it) with ETag: "<serial>" (equal on every relay), 304 on If-None-Match, Cache-Control: no-cache. Payload (≤ 64 KiB):

{"type":"tether-releases/1","channel":"stable","serial":57,"issued":1762527600,"expires":1765119600,
 "releases":{"customer/windows-x86_64":{
   "version":"0.5.24","file":"TetherQS-0.5.24.exe","size":34900000,"sha256":"<64 hex>",
   "signature":"<base64 of the .sig, as in latest.json>",
   "urls":["https://{relay}/download/stable/customer/windows-x86_64/TetherQS-0.5.24.exe"],
   "packed":{"encoding":"gzip","size":14600000,"sha256":"<64 hex>","urls":[
     "https://tether-dl.thomas-schend.workers.dev/stable/customer/windows-x86_64/TetherQS-0.5.24.exe.gz",
     "https://{relay}/download/stable/customer/windows-x86_64/TetherQS-0.5.24.exe.gz"]},
   "notes":"…","mandatory":false,"minimumVersion":"","forced":false,"security":false,
   "rollout":{"start":1762527600,"steps":[[0,1],[3600,10],[21600,50],[86400,100]]},"halted":false}}}
  • Keys <app>/<platform>: technician|customer / windows-x86_64|darwin-universal. Unknown fields are rejected (deny_unknown_fields).
  • https://{relay} stands for the relay the index came from: one document is valid on every relay.
  • Clients ask every relay; the highest valid serial wins and becomes the floor. Downloads are tried packed.urls first (gzip or xz; its own size and sha256 checked before unpacking), then urls; the result must match size, sha256, the minisign signature and the signed trusted comment (file:, version:). https only (except the {relay} base a debug build chooses).
  • Rollout: a device is eligible when its bucket u16(SHA-256("tether-rollout"‖0‖uuid‖0‖app‖0‖version‖0)[0..2]) / 655.36 is below the step's percent (now - start); policy update.rollout early joins at the first step, late waits for 100 %. security skips the ramp; halted stops devices that did not install it (they re-check right before installing).
  • expires (Manage: issued + 30 days): afterwards clients keep using it and report stale.

Release index v2 (download/<channel>/releases-v2.json)

The same document (type, channel, serial, entries) with packed copies in xz ("encoding":"xz", files <artifact>.xz on the relays and the CDN) for TetherQS.exe and both macOS apps; it replaces the gzip copy of TetherQS.exe there. It is a separate file because every build before TetherQS 0.5.31 / Tether 0.5.33 rejects a packed.encoding other than gzip and with it the whole index (deny_unknown_fields applies to new fields too), so releases.json keeps the old format for them.

  • Written by Manage right after releases.json (PUT …/releases-v2.json, same checks: trusted admin key, channel, serial above the stored v2 serial); served by tether-api the same way (Caddy's @index matcher and the nginx location cover both names). Deleted on disk: 404 at once.
  • TetherQS 0.5.31 / Tether 0.5.33 and later ask every relay for both files, v2 first, and take the highest serial over all of them (v2 on a tie). A stale v2 (published with it switched off, see docs/updates.md "Two index files") or a missing one costs nothing: releases.json wins.
  • These builds skip a packed copy whose encoding they do not know (the index stays valid), so a later encoding needs no third file.

Custom apps (branded TetherQS downloads)

A custom app is a signed tether_trust::custom::CustomProfile (id, name, accent colour, welcome text, PNG logo, a customer-profile settings Layer) plus a private download link. Tether Manage signs the profile with the admin key and stores it on every relay with the same token, so the link works on any relay. The relay never modifies the profile; TetherQS verifies the signature itself.

Method & path Body Result
PUT /api/admin/custom/<id> (signed) {"profile": <signed CustomProfile document>, "token": "<43 chars base64url>", "expires": <unix>, "channel": "stable"} (≤ 300 KiB) 204. The server verifies the signature against its admin keys, runs CustomProfile::validate, requires profile.id == <id>, custom::valid_token(token) and expires in the future (≤ 366 days). Replaces an existing entry with that id (new token = old link stops working). Stored in custom/<id>.json (0600).
GET /api/admin/custom (signed) – [{id, name, token, expires, channel, created, downloads, last_download}]
DELETE /api/admin/custom/<id> (signed) – 204; the link stops working at once. 404 if unknown.
GET /q/<token> (public) – Windows: the current TetherQS-<v>.exe of the entry's channel (from download/<channel>/customer/windows-x86_64/latest.json) with custom::attach(<exe>, <signed profile>) (the trailer appended, or for an Authenticode-signed exe placed at the end of its certificate table so the signature stays valid), Content-Disposition: attachment; filename="<Name>-Support.exe" (name reduced to [A-Za-z0-9 _.-]). A User-Agent containing Macintosh (every Mac browser; iPhones say "like Mac OS X" and get the exe) gets the macOS zip instead, as /mac. 404 for unknown, revoked and expired tokens (same answer, no oracle). Rate-limited to 30 requests/min per IP (IPv6: per /64; all /q/ requests together). Counts downloads.
GET /q/<token>/windows, GET /q/<token>/mac (public) – The same link for one platform, whatever the browser. /mac: the channel's TetherQS-<v>-universal.zip (customer/darwin-universal/latest.json, key darwin-universal) with its one top-level TetherQS.app folder renamed to <Name>-Support [<mac id>].app (also in __MACOSX/), Content-Type: application/zip, filename="<Name>-Support.zip". Only the names in the zip headers change (data, CRCs, modes, the signature inside are byte-for-byte the same; zip64 refused).
GET /q/m/<mac id> (public) – The signed profile document of the custom app whose token gives this mac id (custom::mac_id: the first 16 hex characters of SHA-256 over "tetherqs-mac-id\0" + token), Cache-Control: no-store. Answers also after the link expired (a copy downloaded before keeps its branding, as on Windows); 404 once the app is deleted or got a new link. Not counted as a download.

Caddy routes /q/* to tether-api, which checks the token and, when Caddy sends X-Tether-Accel: 1, answers with X-Accel-Redirect: /qcache/<id>--<key>--<file> (<key>: 16 hex characters of a SHA-256 over the token and profile it was made from) and the Content-Type (the exe with the trailer or the renamed zip, prepared once in the data dir outside download/; the exe and the zip copy of an app exist side by side); Caddy then sends that file, so slow downloads hold no worker (scaling.md). Without the header the same prepared copy is sent by tether-api itself. Both copies are made file to file, never in memory (MemoryMax=64M). Tokens are 256-bit random (custom::new_token), compared exactly; links are not listed anywhere public. TetherQS self-updates keep the profile: after verifying a new plain exe it attaches its own profile again the same way (custom::attach).

macOS. The TetherQS .app is code-signed: appending to the Mach-O or adding a file breaks the signature, and the relay has no signing key. The .app folder name is not sealed, so the relay renames it, and TetherQS (apps/quick/src-tauri/src/custom.rs) reads the mac id from its own folder name (custom::mac_id_from_bundle: the last [<16 hex>], so Finder's … 2.app still works), fetches /q/m/<mac id> from its relays in turn, verifies the profile against the compiled-in admin keys exactly like the trailer and caches it as custom-<mac id>.json in its config folder. Later starts and self-updates (which keep the folder name) use the cache. The mac id, not the token, is in the folder name: paths end up in logs, crash reports and diagnostics, and the id cannot be turned back into a download link; it only reveals the (signed, non-secret) profile. Evidence and limits: macos.md.

Limits (1 GB relay VM)

tether-api is a tiny_http service with MemoryMax=64M. It serves up to 32 requests at once (more get 503 busy, answered without reading the body) and keeps its state behind one lock that is never held while a body is read or a response written, nor for the release signature check, audit log queries or preparing a /q/ copy; each read and write times out after 30 s, and a body must arrive within 60 s plus 64 KiB/s and, after its first 30 s, average at least 16 KiB/s (else 408 for uploads, 400 otherwise).

Request bodies are streamed to disk for uploads and held in memory otherwise (512 KiB at most). Uploads have two separate pools of 4 slots, one for release uploads and one for diagnostics uploads (more get 503 with Retry-After: 30), so uploads never hold more than 8 workers and heartbeats keep 24 of the 32. A diagnostics upload gets its slot only for an open ticket. A release upload gets its slot on a Tether-Sig header with a current ts: the signature covers the body, so it is verified only after the body arrived. Somebody without a key can therefore occupy the 4 release slots with made-up uploads (each for as long as the minimum rate allows) and keep real release uploads out meanwhile. The diagnostics slots and all other requests are not affected (shortcut: note at MAX_UPLOADS in server/api/src/main.rs).

Only POST and PUT routes take a body. Any other request that announces one (Content-Length above 0, or Transfer-Encoding) and any request with Connection: upgrade gets 400 unexpected request body before anything is read. A request refused before its body was read (these, 503 busy, a refused upload, 413) is answered with Connection: close and the rest of the body is not read. /metrics reads no body.

The patched tiny_http (server/api/patched/tiny_http) gives every accepted connection a 30 s read timeout: a client that stalls in the request head or in a small body, and an idle kept-alive connection, are dropped after 30 s (the proxy reconnects). It also starts a thread for every connection of a burst at once and really sends Connection: close (upstream dropped that header). What remains: reached directly (not through the proxies), 32 clients that each stall a POST body can hold all workers for up to 30 s. Caddy reads the first 600 KiB of a body on /api/*, /q/* and the release-index route before it connects to tether-api, so a slow client waits in Caddy; nginx buffers request bodies too, except on the two upload routes.

tether-api closes an idle connection after 30 s; Caddy and nginx keep idle connections to it for 20 s only (keepalive 20s in the Caddyfile, keepalive_timeout 20s in the nginx upstream), so they never reuse one that tether-api is closing. The new Caddyfile / nginx.conf therefore go out together with the new tether-api. The audit answer is sent with Content-Length.

Per-IP limits (heartbeats of new devices, audit posts, /q/, failed team signatures) count an IPv6 client by its /64; an IPv4 client reported in the mapped form (::ffff:a.b.c.d) is counted as that IPv4 address. Device lists are written through a temp file, not a buffer; custom-app profiles stay on disk (custom/<id>.json). Every JSON write is temp file + rename; no database.