From 66b4721b342b3e51f5eb91b46afb602bfa7ad0f5 Mon Sep 17 00:00:00 2001 From: ZGaetano Date: Thu, 7 May 2026 00:18:24 -0400 Subject: [PATCH] Fix RelayReg API: heartbeat/unregisterHost now require wgIP per relay contract --- src/wg/relayreg.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/wg/relayreg.h b/src/wg/relayreg.h index 583a487..7a66aaf 100644 --- a/src/wg/relayreg.h +++ b/src/wg/relayreg.h @@ -1,5 +1,5 @@ #pragma once -// src/wg/relayreg.h — DragonRelay HTTP registration client for Artemis. +// src/wg/relayreg.h - DragonRelay HTTP registration client for Artemis. // // Artemis (the Sunshine fork) uses this to: // 1. Authenticate with the DragonRelay server (POST /api/auth/login) @@ -10,6 +10,10 @@ // // Built on libcurl (synchronous, no event loop dependency). // The caller is responsible for starting heartbeats in a background thread. +// +// IMPORTANT: heartbeat() and unregisterHost() require the local WireGuard IP +// (wgIP) so the relay can validate ownership. The relay rejects requests +// without this field with HTTP 400. #include "displayinfo.h" @@ -52,12 +56,8 @@ public: // ── VPN provisioning ────────────────────────────────────────────────────── - // Request a new WireGuard peer from DragonRelay. - // deviceName is appended to username: "user@devicename". - // Returns false and sets errOut on failure. bool provisionVPN(const std::string &deviceName, VPNConf &out, std::string &errOut); - // Delete a previously provisioned peer (cleanup on re-provision or shutdown). bool deleteVPNPeer(const std::string &peerId, std::string &errOut); // ── Host registration ───────────────────────────────────────────────────── @@ -72,19 +72,18 @@ public: std::string &errOut); // Must be called every ~60 seconds to keep the host visible (5-min TTL). - bool heartbeat(std::string &errOut); + // wgIP is required so the relay can validate ownership. + bool heartbeat(const std::string &wgIP, std::string &errOut); // Called on Artemis shutdown. - bool unregisterHost(std::string &errOut); + // wgIP is required so the relay can validate ownership. + bool unregisterHost(const std::string &wgIP, std::string &errOut); private: std::string m_base; std::string m_jwt; LogFn m_log; - // Perform a JSON HTTP request. method: "GET","POST","PUT","DELETE". - // body: JSON string to send (empty = no body). - // Returns HTTP status code; responseOut is set to the response body. int request(const std::string &method, const std::string &path, const std::string &body,