relay_server/README.md

52 lines
1.3 KiB
Markdown

relay_server
=====
An OTP application with an esockd-based UDP server.
Build
-----
$ rebar3 compile
Run
---
$ rebar3 shell
The UDP listener is configured in `config/sys.config`; the checked-in config
listens on port `1443`, while the code fallback default is `16380`. It accepts
RelayKit UDP relay frames.
Protocol
--------
Each UDP datagram is encrypted with ChaCha20-Poly1305. The encrypted datagram
uses the same combined format as CryptoKit `ChaChaPoly`:
nonce(12), ciphertext, tag(16)
The decrypted plaintext is one `RKP1` frame:
magic(4) = "RKP1", version(1) = 1, type(1), reserved(2),
stream_id(8), payload_len(4), payload(payload_len)
Frame types are `open = 1`, `open_ack = 2`, `data = 3`, `close = 4`, and
`error = 5`.
`open` payload is binary encoded as:
host_len(2), host(host_len), port(2),
username_len(2), username(username_len),
password_len(2), password(password_len)
Integer fields are unsigned big-endian values. `host`, `username`, and
`password` are binary strings. The server is a transparent TCP relay, so TLS
negotiation, HTTP methods, and request bytes are carried inside subsequent
`data` frames without being interpreted by the server.
`username` and `password` are checked against the `relay_server` application
`users` config:
{users, [
{admin, "password"}
]}