README: update integration example for new heartbeat/unregister signatures

This commit is contained in:
Zac Gaetano 2026-05-07 00:20:55 -04:00
parent 6fd5895adb
commit b3e7a57017

View file

@ -22,9 +22,9 @@ DragonMoonlight (client) Artemis (host)
Flow: Flow:
1. Artemis boots → logs into DragonRelay → provisions WG peer 1. Artemis boots → logs into DragonRelay → provisions WG peer
2. Artemis starts WireGuard tunnel → gets IP 10.99.0.3 2. Artemis starts WireGuard tunnel → gets IP 10.99.0.3
3. Artemis registers: POST /api/host/register {wg_ip: "10.99.0.3", port: 47984} 3. Artemis registers: POST /api/host/register {name, wg_ip, port, displays}
4. Artemis heartbeats: PUT /api/host/heartbeat every 60 s 4. Artemis heartbeats: PUT /api/host/heartbeat {wg_ip} every 60 s
5. DragonMoonlight: GET /api/hosts sees 10.99.0.3 in the list 5. DragonMoonlight: GET /api/hosts sees 10.99.0.3 in the list
6. DragonMoonlight connects to 10.99.0.3:47984 over the shared WG tunnel 6. DragonMoonlight connects to 10.99.0.3:47984 over the shared WG tunnel
``` ```
@ -39,9 +39,11 @@ Flow:
| `src/wg/wgclient_win.cpp` | Windows: Wintun kernel TUN + boringtun FFI | | `src/wg/wgclient_win.cpp` | Windows: Wintun kernel TUN + boringtun FFI |
| `src/wg/wgclient_linux.cpp` | Linux: `/dev/net/tun` + boringtun FFI | | `src/wg/wgclient_linux.cpp` | Linux: `/dev/net/tun` + boringtun FFI |
| `src/wg/relayreg.h/.cpp` | DragonRelay HTTP client (libcurl) | | `src/wg/relayreg.h/.cpp` | DragonRelay HTTP client (libcurl) |
| `src/wg/displayinfo.h` + `_linux.cpp` / `_win.cpp` | Display enumeration for relay registration |
| `src/wg/boringtun_ffi.h` | C ABI bindings for boringtun | | `src/wg/boringtun_ffi.h` | C ABI bindings for boringtun |
| `cmake/wg.cmake` | CMake integration snippet | | `cmake/wg.cmake` | CMake integration snippet |
| `scripts/build-boringtun.sh` | Build boringtun for Linux/macOS | | `scripts/build-boringtun.sh` | Build boringtun for Linux/macOS |
| `scripts/build-boringtun-win.ps1` | Build boringtun for Windows |
--- ---
@ -95,13 +97,13 @@ port = 47984 # Sunshine streaming port (default)
``` ```
Artemis reads this on startup, authenticates, provisions a WireGuard peer, and Artemis reads this on startup, authenticates, provisions a WireGuard peer, and
starts the tunnel automatically. The WireGuard `.conf` returned by DragonRelay starts the tunnel automatically. The WireGuard `.conf` returned by DragonRelay
is parsed in-memory — no file is written to disk. is parsed in-memory — no file is written to disk.
### 5. Linux: capabilities / root ### 5. Linux: capabilities / root
The Linux WireGuard client opens `/dev/net/tun` and runs `ip addr/route` The Linux WireGuard client opens `/dev/net/tun` and runs `ip addr/route`
commands. Either run Artemis as root, or grant `CAP_NET_ADMIN`: commands. Either run Artemis as root, or grant `CAP_NET_ADMIN`:
```bash ```bash
sudo setcap cap_net_admin+ep /usr/bin/artemis sudo setcap cap_net_admin+ep /usr/bin/artemis
@ -109,8 +111,8 @@ sudo setcap cap_net_admin+ep /usr/bin/artemis
### 6. Windows: Administrator ### 6. Windows: Administrator
Wintun requires Administrator to create the kernel TUN adapter. Artemis ships Wintun requires Administrator to create the kernel TUN adapter. Artemis ships
with a UAC manifest (`requireAdministrator`). Users will see a one-time with a UAC manifest (`requireAdministrator`). Users will see a one-time
elevation prompt on first launch. elevation prompt on first launch.
--- ---
@ -126,11 +128,15 @@ The key hooks are:
#include "wg/wgclient.h" #include "wg/wgclient.h"
#include "wg/wgconfig.h" #include "wg/wgconfig.h"
#include "wg/relayreg.h" #include "wg/relayreg.h"
#include "wg/displayinfo.h"
// Boot sequence (run before Sunshine starts accepting streams): // Boot sequence (run before Sunshine starts accepting streams):
wg::RelayReg relay; wg::RelayReg relay;
relay.setBaseURL(config::relay_url); relay.setBaseURL(config::relay_url);
relay.login(config::relay_user, config::relay_pass, err);
std::string err;
if (!relay.login(config::relay_user, config::relay_pass, err))
BOOST_LOG(error) << "Relay login failed: " << err;
wg::VPNConf vpnConf; wg::VPNConf vpnConf;
relay.provisionVPN(config::relay_device, vpnConf, err); relay.provisionVPN(config::relay_device, vpnConf, err);
@ -141,20 +147,23 @@ wg::Config::fromString(vpnConf.conf, wgCfg, err);
wg::Client wgClient; wg::Client wgClient;
wgClient.start(wgCfg); // tunnel up wgClient.start(wgCfg); // tunnel up
relay.registerHost(config::relay_name, wgClient.localIP(), config::relay_port, err); const std::string localIP = wgClient.localIP(); // e.g. "10.99.0.3"
const auto displays = wg::enumerateDisplays();
relay.registerHost(config::relay_name, localIP, config::relay_port, displays, err);
// Heartbeat thread (every 60 s): // Heartbeat thread (every 60 s):
std::thread([&]() { std::thread([&]() {
while (running) { while (running) {
std::this_thread::sleep_for(std::chrono::seconds(60)); std::this_thread::sleep_for(std::chrono::seconds(60));
relay.heartbeat(err); std::string err;
relay.heartbeat(localIP, err); // wg_ip required
} }
}).detach(); }).detach();
// Shutdown: // Shutdown:
relay.unregisterHost(err); { std::string err; relay.unregisterHost(localIP, err); } // wg_ip required
wgClient.stop(); wgClient.stop();
relay.deleteVPNPeer(vpnConf.id, err); { std::string err; relay.deleteVPNPeer(vpnConf.id, err); }
#endif #endif
``` ```
@ -171,7 +180,7 @@ relay.deleteVPNPeer(vpnConf.id, err);
## Upstream merge hygiene ## Upstream merge hygiene
Artemis adds only new files under `src/wg/` and `cmake/`. No Sunshine source Artemis adds only new files under `src/wg/` and `cmake/`. No Sunshine source
files are modified — this minimises merge conflicts when pulling upstream files are modified — this minimises merge conflicts when pulling upstream
Sunshine updates: Sunshine updates: