Rubylight Download 7.0.3
On this page
  1. The order a device tries
  2. What the host does
  3. Finding each other on the Mainline DHT
  4. Punching and the tunnel
  5. Away wake relay
  6. Limits

Play over the internet #

Rubylight docs › Play anywhere · Configuration · Privacy

Devices reach your PC from outside your network without forwarding ports by hand, and without any server run by the Rubylight project: no relay carries your stream and no rendezvous server knows your devices. Two settings are involved:

The order a device tries #

  1. The local network. At home nothing else is tried and nothing is added to the stream.
  2. The PC's IPv6 address. No router mapping is needed where the router lets it in (or the host opened a pinhole).
  3. A forwarded IPv4 port, at the PC's public address, when every streaming port is forwarded under its own number.
  4. A punched path. Only Nightjar, only with a host that offers it (RustHostInternetPlayVersion 1 in a paired serverinfo), and only after the device was on the PC's network once with the option on, or opened an invite.

The PC's line in Nightjar names the path in use (Internet (IPv6), Internet (forwarded port) or Internet (direct path)). When none works, it lists every path and why it failed, such as "IPv6: no answer; a direct internet path: both routers change ports per destination".

What the host does #

Finding each other on the Mainline DHT #

The Mainline DHT is a public peer-to-peer directory, the same one BitTorrent apps use to find each other. Rubylight and Nightjar use it only as a directory for their encrypted records: nothing is downloaded, shared or seeded through it. The records are mutable items (BEP 44), stored by public DHT nodes for about two hours. The host and the device each publish one and read the other's:

Punching and the tunnel #

Both sides send authenticated punches to every endpoint the other published, every 100 ms for 3 s and then every 500 ms, for up to 30 s. The device starts with the endpoints the PC gave it on its network while it looks up the PC's record, and punches on until 51 s after its own record is stored, the time the host needs to find it. A side behind a symmetric NAT is also tried at the next eight ports. The first authenticated answer fixes the path, including a peer address neither side published (peer-reflexive).

Punching works for IPv4 when at least one side has a cone NAT, or both are port-restricted cones. Two symmetric NATs, or a symmetric NAT opposite a port-restricted one, cannot be punched; then only a forwarded port or IPv6 reaches the PC.

Away wake relay #

A sleeping PC publishes nothing and answers no punch. With Away wake relay on (away_wake_relay, besides internet_play), an always-on paired device on the PC's network, a relay, wakes it for a paired device that is away. The same records, punches and sealed datagrams carry it, and the relay only ever sends Wake-on-LAN on its own network.

The relay forwards no port: like the PC for internet play it uses one UDP socket for the DHT, STUN and punches, and sends the magic packets from its own interface addresses.

Running a relay. Any always-on box on the PC's network with Nightjar's desktop client can be the relay, such as a Linux mini PC or server. Pair it with the PC once in Nightjar's window (add the PC and type the PIN, or open the console's pairing link with nightjar 'rubylight://pair?…', which asks in the window before it pairs; a box without a screen needs a desktop session for that once). In the Rubylight console turn on Host control for it, and Away wake relay with Play over the internet. Then keep nightjar wake-relay running (--name "Living room NUC" is how the PC lists it when it enrolls). It enrolls with every paired PC that offers a relay, prints a line for each change (the PCs it serves and their devices, its public address and NAT, STUN or DHT trouble, each wake), and stops on Ctrl-C or SIGTERM with its enrollments kept. It saves the assignments, which hold its secrets, in wake-relay.json in Nightjar's config directory (~/.config/nightjar on Linux, readable by its owner only), so a relay started again while the PC sleeps still wakes it. A PC that cannot be reached keeps its enrollment. A PC with the setting off, or that sees the relay off its network, is not served until a refresh succeeds again; a PC that removed the relay, took Host control away or unpaired it is dropped at once and not enrolled again until nightjar wake-relay --enroll. nightjar wake-relay --leave leaves every PC and deletes the file. As a systemd user service, with loginctl enable-linger so it runs without a login:

# ~/.config/systemd/user/nightjar-wake-relay.service, then: systemctl --user enable --now nightjar-wake-relay
[Unit]
Description=Nightjar wake relay

[Service]
ExecStart=/usr/bin/nightjar wake-relay
Restart=on-failure
RestartSec=30

[Install]
WantedBy=default.target

Limits #

View this page on GitHub