In UDP-less environments (like web browsers, virtual machines, containers and firewalled networks) clients need to rely on a remote server that can relay their PUT and GET messages.
Public relays need to setup cors headers.
PUT /:z-base32-encoded-key HTTP/2
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, OPTIONS
If-Match: 1741107004412159
<body>
HTTP/2 204 NO CONTENT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, OPTIONS
Body is described at Payload encoding section.
On receiving a PUT request, the relay server should:
seq and v to a bencode message as follows: 3:seqi<sequence>e1:v<v's length>:<v's bytes>sig matches the encoded message from step 1, if it is invalid, return a 400 Bad Request response.If-Match as the CAS field, where the header value is the utf8-encoded u64 timestamp.204 No Content response, otherwise if any error occurred return a 500 Internal Server Error response.400 Bad Request if the public key in the path is invalid, or the payload has invalid signature, or DNS packet.409 Conflict if the timestamp is older than what the server or the DHT network already seen (equivalent to error code 302 in BEP0044).412 Precondition Failed if the If-Match condition fails (equivalent to error code 301 in BEP0044).413 Payload Too Large if the payload is larger than 1072 bytes.428 Precondition Required if the server is already publishing another packet for the same key, it should require a If-Match header.429 Too Many Requests if the server is rate limiting requests from the same IP.GET /:z-base32-encoded-key HTTP/2
If-Modified-Since: Fri, 18 Oct 2024 13:24:21 GMT
HTTP/2 200 OK
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, PUT, OPTIONS
Content-Type: application/pkarr.org/relays#payload
Cache-Control: public, max-age=300
Last-Modified: Fri, 18 Oct 2024 13:24:21 GMT
<body>
Cache-Control header would help browsers reduce their reliance on the relay, the max-age should be set to be the minimum ttl in the resource records in the packet or some minimum ttl chosen by the relay.
If-Modified-Since can be sent by the client to avoid downloading packets they already have, when the relay responds with 304 Not Modified.
Body is described at Payload encoding section.
On receiving a GET request, the relay server should:
sig, big-endian encoded seq, and v.404 Not Found.400 Bad Request if the public key in the path is invalid.404 Not Found if the packet is not found.Relay payload is a subset of the Canonical encoding, omitting the leading public key:
RelayPayload = signature timestamp dns-packet
signature = 64 OCTET ; ed25519 signature over encoded DNS packet
timestamp = 8 OCTET ; big-endian UNIX timestamp in microseconds
dns-packet = * OCTET ; compressed encoded DNS answer packet, less than 1000 bytes