README: update integration example for new heartbeat/unregister signatures
This commit is contained in:
parent
6fd5895adb
commit
b3e7a57017
1 changed files with 22 additions and 13 deletions
23
README.md
23
README.md
|
|
@ -22,8 +22,8 @@ DragonMoonlight (client) Artemis (host)
|
|||
Flow:
|
||||
1. Artemis boots → logs into DragonRelay → provisions WG peer
|
||||
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}
|
||||
4. Artemis heartbeats: PUT /api/host/heartbeat every 60 s
|
||||
3. Artemis registers: POST /api/host/register {name, wg_ip, port, displays}
|
||||
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
|
||||
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_linux.cpp` | Linux: `/dev/net/tun` + boringtun FFI |
|
||||
| `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 |
|
||||
| `cmake/wg.cmake` | CMake integration snippet |
|
||||
| `scripts/build-boringtun.sh` | Build boringtun for Linux/macOS |
|
||||
| `scripts/build-boringtun-win.ps1` | Build boringtun for Windows |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -126,11 +128,15 @@ The key hooks are:
|
|||
#include "wg/wgclient.h"
|
||||
#include "wg/wgconfig.h"
|
||||
#include "wg/relayreg.h"
|
||||
#include "wg/displayinfo.h"
|
||||
|
||||
// Boot sequence (run before Sunshine starts accepting streams):
|
||||
wg::RelayReg relay;
|
||||
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;
|
||||
relay.provisionVPN(config::relay_device, vpnConf, err);
|
||||
|
|
@ -141,20 +147,23 @@ wg::Config::fromString(vpnConf.conf, wgCfg, err);
|
|||
wg::Client wgClient;
|
||||
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):
|
||||
std::thread([&]() {
|
||||
while (running) {
|
||||
std::this_thread::sleep_for(std::chrono::seconds(60));
|
||||
relay.heartbeat(err);
|
||||
std::string err;
|
||||
relay.heartbeat(localIP, err); // wg_ip required
|
||||
}
|
||||
}).detach();
|
||||
|
||||
// Shutdown:
|
||||
relay.unregisterHost(err);
|
||||
{ std::string err; relay.unregisterHost(localIP, err); } // wg_ip required
|
||||
wgClient.stop();
|
||||
relay.deleteVPNPeer(vpnConf.id, err);
|
||||
{ std::string err; relay.deleteVPNPeer(vpnConf.id, err); }
|
||||
#endif
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue