1.3 KiB
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 and listens on port 16380
by default. 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, data = 2, close = 3, and error = 4.
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"}
]}