Implement satellite reflectors
Satellite reflectors are lightweight relay instances that connect to a parent reflector instead of joining the full trunk mesh. Clients connect to the satellite normally; it relays all TGs bidirectionally to the parent. The parent forwards satellite events to local clients, trunk peers, and other satellites. New classes: - SatelliteLink: parent-side handler for each inbound satellite connection (HMAC auth, heartbeat, all-TG relay) - SatelliteClient: satellite-side outbound connection to parent Wire protocol: MsgTrunkHello gains m_role field (ROLE_PEER=0, ROLE_SATELLITE=1) to distinguish satellite handshakes. Config: - Parent: [SATELLITE] section with LISTEN_PORT and SECRET - Satellite: SATELLITE_OF, SATELLITE_PORT, SATELLITE_SECRET in [GLOBAL] HTTP /config endpoint now shows mode (reflector/satellite), satellite_server config on parents, and satellite connection info. Docs updated: README, DEPLOYMENT_ITALY, Italian translation.
This commit is contained in:
1 parent
166e57f445
commit
551cfa70cd
13 files changed
+1159
-20
No files matched your search
@@ -0,0 +1,65 @@
|
||||
#ifndef SATELLITE_LINK_INCLUDED
|
||||
#define SATELLITE_LINK_INCLUDED
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sigc++/sigc++.h>
|
||||
#include <json/json.h>
|
||||
#include <AsyncFramedTcpConnection.h>
|
||||
#include <AsyncTimer.h>
|
||||
|
||||
class Reflector;
|
||||
class ReflectorMsg;
|
||||
|
||||
/**
|
||||
@brief Handles one inbound satellite connection on the parent reflector
|
||||
|
||||
A SatelliteLink is created for each satellite that connects to the parent's
|
||||
satellite port. It relays ALL TGs bidirectionally (no prefix filtering).
|
||||
The parent always wins talker arbitration over satellites.
|
||||
*/
|
||||
class SatelliteLink : public sigc::trackable
|
||||
{
|
||||
public:
|
||||
SatelliteLink(Reflector* reflector, Async::FramedTcpConnection* con,
|
||||
const std::string& secret);
|
||||
~SatelliteLink(void);
|
||||
|
||||
bool isAuthenticated(void) const { return m_hello_received; }
|
||||
const std::string& satelliteId(void) const { return m_satellite_id; }
|
||||
Json::Value statusJson(void) const;
|
||||
|
||||
// Events from local clients or trunk peers → send down to satellite
|
||||
void onParentTalkerStart(uint32_t tg, const std::string& callsign);
|
||||
void onParentTalkerStop(uint32_t tg);
|
||||
void onParentAudio(uint32_t tg, const std::vector<uint8_t>& audio);
|
||||
void onParentFlush(uint32_t tg);
|
||||
|
||||
private:
|
||||
static const unsigned HEARTBEAT_TX_CNT_RESET = 10;
|
||||
static const unsigned HEARTBEAT_RX_CNT_RESET = 15;
|
||||
|
||||
Reflector* m_reflector;
|
||||
Async::FramedTcpConnection* m_con;
|
||||
std::string m_secret;
|
||||
std::string m_satellite_id;
|
||||
bool m_hello_received;
|
||||
Async::Timer m_heartbeat_timer;
|
||||
unsigned m_hb_tx_cnt;
|
||||
unsigned m_hb_rx_cnt;
|
||||
std::set<uint32_t> m_sat_active_tgs;
|
||||
|
||||
void onFrameReceived(Async::FramedTcpConnection* con,
|
||||
std::vector<uint8_t>& data);
|
||||
void handleMsgTrunkHello(std::istream& is);
|
||||
void handleMsgTrunkTalkerStart(std::istream& is);
|
||||
void handleMsgTrunkTalkerStop(std::istream& is);
|
||||
void handleMsgTrunkAudio(std::istream& is);
|
||||
void handleMsgTrunkFlush(std::istream& is);
|
||||
void handleMsgTrunkHeartbeat(void);
|
||||
void sendMsg(const ReflectorMsg& msg);
|
||||
void heartbeatTick(Async::Timer* t);
|
||||
};
|
||||
|
||||
#endif /* SATELLITE_LINK_INCLUDED */
|
||||
Reference in new issue
Block a user