Find a server's gateway in DNS, like TeamSpeak finds the server

Users should not have to type a gateway URL: a server added by its address
should bring its tsgw along, the way TeamSpeak finds the voice server with
SRV _ts3._udp and TSDNS. voelin_core::discover::gateway looks at the
address's host and then each parent domain down to the registered domain,
the most specific first, for SRV _tsgws._tcp (wss) and _tsgw._tcp (ws)
records, TLS first at the same name, with the path from an optional TXT
record ("path=/v1" by default).

Without records, as TSDNS has its port 41144, the gateway itself is asked
on tsgw's default port: tsgw now answers GET /.well-known/tsgw with the URL
apps should use (listen.public_url, else the address the request came in
on), so a tsgw next to the server is found with no setup at all.

docs/gateway-admin.md says which records to publish, with examples. The
DNS lookups are injectable in the module: tests with fake SRV/TXT answers
and a local responder; the gateway's own test fetches the well-known URL
from the real router and logs in there. hickory-resolver is the version
the voice resolver already uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-03 23:24:57 +03:00
1 parent 2cd03ddb8e
commit feaf6fa76c
8 files changed
+456 -3

No files matched your search

+5
View File
@@ -19,6 +19,11 @@ frame:
{"v":1,"id":7,"type":"send_chat","data":{"target":{"kind":"channel","id":5},"text":"hi"}}
```
Next to it, `GET /.well-known/tsgw` answers `{"url": "…"}`, the URL apps
should use (`listen.public_url`, else the one the request came in on); apps
that find no DNS record ask there ([gateway-admin.md](gateway-admin.md#letting-voelin-find-the-gateway),
`voelin_core::discover`).
The client picks `id` for requests; the answer carries the same `id`.
Pushes have no `id`. Version 1 only grows: new message types and optional
fields. Both sides ignore unknown fields. The gateway answers a type it does