Skip to content

About

Stateless WebSocket signaling relay for KryptoPass. Never sees vault data or keys.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

KryptoPass signaling relay

kryptopass-relay is a small, stateless WebSocket signaling relay for the KryptoPass Internet transport. It only routes a bounded exchange between one host and one join connection. A room value is an untrusted routing label; it is not a password or proof of identity. Pairing invitations, Noise messages, vault frames, and OpenPGP keys do not pass through this service.

The relay implements the path and message contract in internet-transport-v1.md. The relay cannot grant trust. A malicious relay can observe connection metadata, block messages, or replace signaling. Identity checks, Noise, and the human SAS comparison remain the clients' responsibility.

Build and run

This is a standalone Cargo project. Its binary is named kryptopass-relay.

cargo build --release
cargo run --release

By default it listens on 127.0.0.1:8787. Override the address with --bind or KRYPTOPASS_RELAY_BIND:

cargo run --release -- --bind 127.0.0.1:8787
KRYPTOPASS_RELAY_BIND=127.0.0.1:8787 ./target/release/kryptopass-relay

The default is loopback so the process is not exposed directly to the public network. GET /healthz returns a static JSON status and the package version. No room enumeration, metrics endpoint, or browser CORS permission is provided.

WebSocket contract

Clients connect to exactly one of these paths, with no query string:

/kp/relay/v1/<64 lowercase hex room characters>/host
/kp/relay/v1/<64 lowercase hex room characters>/join

The room must not be all zeroes. One connection per role is accepted; a second connection for the same role receives HTTP 409. The relay rejects WebSocket requests with an Origin header. Native clients should omit it. When both roles are present, each receives exactly {"v":1,"type":"ready"} once. The relay does not forward application messages before this point.

After ready, the relay accepts only these exact JSON shapes, with no duplicate or unknown fields:

{"v":1,"type":"request","device":"<64 lowercase hex characters>"}
{"v":1,"type":"resume","session":"<32 nonzero lowercase hex characters>"}
{"v":1,"type":"offer","sdp":"<opaque SDP text>"}
{"v":1,"type":"answer","sdp":"<opaque SDP text>"}

The expected order is join request, host resume, join offer, host answer. The relay checks message shape and order only. It does not decide whether the device selector, session, or SDP is trusted, and it does not parse or rewrite SDP. The clients close signaling when the WebRTC DataChannel opens.

Bounds are fixed in the server:

Resource Limit
Active TCP/WebSocket connections, including handshakes 256
Active rooms 128
HTTP handshake header 16 KiB and 10 seconds
Time waiting for the other room role 300 seconds
Paired signaling window 90 seconds
One client text message 256 KiB
Outbound queue per connection 4 messages
Total client signaling per pair 1 MiB and 32 messages
Client signaling rate per pair 8 messages per second

Any overflow, malformed message, unexpected binary frame, or disconnect closes the pair and removes its room. Queue backpressure closes the pair instead of growing memory use. WebSocket control frames are rate limited as well.

Cloudflare Tunnel

The intended deployment uses a separate cloudflared tunnel for signal.kryptopass.org. TLS/WSS ends at Cloudflare; the tunnel forwards WebSocket traffic to the loopback HTTP origin. The YAML template is deployment/cloudflared/config.yml.example. It contains placeholders for the tunnel UUID and credentials-file path; do not commit credentials. The tunnel forwards signaling only and does not provide WebRTC STUN or TURN service.

The origin and its tunnel process must both be running for the public endpoint to work. The repository contains portable configuration templates. The separately authorized local deployment is documented in OPERATIONS.es.md. Building this crate alone does not install services or change DNS. The systemd user-unit templates are kryptopass-relay.service and kryptopass-signal-tunnel.service. An authorized deployment operator handles installation and activation of that unit outside the build. A user service follows that account's systemd user manager lifecycle; without a separately configured lingering policy it may stop when the user logs out and will not by itself provide independent 24/7 hosting.

To install the template as a user service after placing the binary at /usr/local/bin/kryptopass-relay, copy it to ~/.config/systemd/user/kryptopass-relay.service, then run:

systemctl --user daemon-reload
systemctl --user enable --now kryptopass-relay.service
systemctl --user status kryptopass-relay.service

The unit binds only to 127.0.0.1:8787 and runs with a restricted systemd profile. The process writes only fixed startup/failure messages; it never logs room paths, payloads, SDP, ICE credentials, invitation tokens, or client identities. There is no database or message store.

License

GPL-3.0-or-later. See LICENSE.

About

Stateless WebSocket signaling relay for KryptoPass. Never sees vault data or keys.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages