Fix RelayReg API: heartbeat/unregisterHost now require wgIP per relay contract
This commit is contained in:
parent
7bb3ef95ec
commit
66b4721b34
1 changed files with 9 additions and 10 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue