refactor: rename MsgTrunk* -> MsgPeer*

The eight MsgTrunk* types flow over trunk, satellite, and twin links —
"Trunk" was a misleading prefix for what is actually a shared peer
protocol. Wire IDs (115-122) and field layouts are unchanged, so this
is wire-equivalent: a renamed reflector and an old reflector
interoperate identically.

Also renames docs/TRUNK_PROTOCOL.md -> docs/PEER_PROTOCOL.md.

Twin-only types MsgTwinExt* (123/124) stay as-is.
This commit is contained in:
Audric committed 2026-04-28 18:00:24 +02:00
1 parent 3d281e16d7
commit 18d92a2b11
17 files changed
+424 -422

No files matched your search

+3 -3
View File
@@ -329,7 +329,7 @@ void MqttPublisher::publishFullStatus(const Json::Value& status)
static Json::Value nodeListToJson(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
Json::Value arr(Json::arrayValue);
for (const auto& n : nodes)
@@ -356,7 +356,7 @@ static Json::Value nodeListToJson(
void MqttPublisher::publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
@@ -366,7 +366,7 @@ void MqttPublisher::publishLocalNodes(
void MqttPublisher::publishPeerNodes(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
+4 -4
View File
@@ -45,9 +45,9 @@ class MqttPublisher
// Node-list snapshots — published retained
void publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
void publishPeerNodes(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
private:
Async::Config& m_cfg;
@@ -98,9 +98,9 @@ class MqttPublisher
void onRxUpdate(const std::string&, const Json::Value&) {}
void publishFullStatus(const Json::Value&) {}
void publishLocalNodes(
const std::vector<MsgTrunkNodeList::NodeEntry>&) {}
const std::vector<MsgPeerNodeList::NodeEntry>&) {}
void publishPeerNodes(const std::string&,
const std::vector<MsgTrunkNodeList::NodeEntry>&) {}
const std::vector<MsgPeerNodeList::NodeEntry>&) {}
};
#endif /* WITH_MQTT */
+17 -17
View File
@@ -2428,7 +2428,7 @@ void Reflector::trunkClientConnected(Async::FramedTcpConnection* con)
m_trunk_pending_cons[con] = timer;
// Use a limited frame size — only a hello message is expected.
// MsgTrunkHello contains strings + HMAC, so needs more than PREAUTH (64).
// MsgPeerHello contains strings + HMAC, so needs more than PREAUTH (64).
// Cap at SSL_SETUP size (4096) which is plenty for a hello.
con->setMaxFrameSize(ReflectorMsg::MAX_SSL_SETUP_FRAME_SIZE);
con->frameReceived.connect(
@@ -2492,18 +2492,18 @@ void Reflector::trunkPendingFrameReceived(Async::FramedTcpConnection* con,
return;
}
if (header.type() != MsgTrunkHello::TYPE)
if (header.type() != MsgPeerHello::TYPE)
{
geulog::warn("trunk", "TRUNK inbound: expected MsgTrunkHello, got type=",
geulog::warn("trunk", "TRUNK inbound: expected MsgPeerHello, got type=",
header.type());
rejectPending();
return;
}
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(ss))
{
geulog::error("trunk", "TRUNK inbound: failed to unpack MsgTrunkHello");
geulog::error("trunk", "TRUNK inbound: failed to unpack MsgPeerHello");
rejectPending();
return;
}
@@ -3243,12 +3243,12 @@ void Reflector::scheduleNodeListUpdate(void)
void Reflector::sendNodeListToAllPeers(void)
{
// 1. Local clients — sat_id stays empty (recipient-relative: "on me").
std::vector<MsgTrunkNodeList::NodeEntry> local_nodes;
std::vector<MsgPeerNodeList::NodeEntry> local_nodes;
for (const auto& kv : m_client_con_map)
{
ReflectorClient* c = kv.second;
if (c->callsign().empty()) continue;
MsgTrunkNodeList::NodeEntry e;
MsgPeerNodeList::NodeEntry e;
e.callsign = c->callsign();
e.tg = c->currentTG();
// Attach the rich per-client status blob so peers can render partner
@@ -3278,7 +3278,7 @@ void Reflector::sendNodeListToAllPeers(void)
// 2. Combined view = local + every connected satellite's stamped roster.
// Each sat-supplied entry already carries sat_id == its satelliteId.
std::vector<MsgTrunkNodeList::NodeEntry> combined = local_nodes;
std::vector<MsgPeerNodeList::NodeEntry> combined = local_nodes;
for (const auto& kv : m_satellite_con_map)
{
const auto& sat_nodes = kv.second->partnerNodes();
@@ -3306,7 +3306,7 @@ void Reflector::sendNodeListToAllPeers(void)
SatelliteLink* link = kv.second;
const std::string& this_sat_id = link->satelliteId();
std::vector<MsgTrunkNodeList::NodeEntry> for_this_sat;
std::vector<MsgPeerNodeList::NodeEntry> for_this_sat;
for_this_sat.reserve(combined.size());
for (const auto& n : combined)
{
@@ -3325,7 +3325,7 @@ void Reflector::sendNodeListToAllPeers(void)
}
// 6. MQTT — keep scope to parent-local clients (sat-supplied entries
// already get a publish via SatelliteLink::handleMsgTrunkNodeList
// already get a publish via SatelliteLink::handleMsgPeerNodeList
// calling onPeerNodeList → MqttPublisher::publishPeerNodes).
if (m_mqtt != nullptr)
{
@@ -3335,7 +3335,7 @@ void Reflector::sendNodeListToAllPeers(void)
void Reflector::onPeerNodeList(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
if (m_mqtt != nullptr)
{
@@ -4374,26 +4374,26 @@ void Reflector::twinPendingFrameReceived(Async::FramedTcpConnection* con,
return;
}
if (header.type() != MsgTrunkHello::TYPE)
if (header.type() != MsgPeerHello::TYPE)
{
geulog::warn("twin", "TWIN inbound: expected MsgTrunkHello, got type=",
geulog::warn("twin", "TWIN inbound: expected MsgPeerHello, got type=",
header.type());
rejectPending();
return;
}
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(ss))
{
geulog::error("twin", "TWIN inbound: failed to unpack MsgTrunkHello");
geulog::error("twin", "TWIN inbound: failed to unpack MsgPeerHello");
rejectPending();
return;
}
if (msg.role() != MsgTrunkHello::ROLE_TWIN)
if (msg.role() != MsgPeerHello::ROLE_TWIN)
{
geulog::error("twin", "TWIN inbound: peer sent role=", int(msg.role()),
", expected ROLE_TWIN (", int(MsgTrunkHello::ROLE_TWIN),
", expected ROLE_TWIN (", int(MsgPeerHello::ROLE_TWIN),
")");
rejectPending();
return;
+3 -3
View File
@@ -308,7 +308,7 @@ class Reflector : public sigc::trackable
void scheduleNodeListUpdate(void);
// Called by TrunkLink when a peer sends us its node list.
void onPeerNodeList(const std::string& peer_id,
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
protected:
@@ -370,7 +370,7 @@ class Reflector : public sigc::trackable
static const size_t TRUNK_MAX_PENDING_CONS = 5;
FramedTcpServer* m_trunk_srv = nullptr;
// Inbound trunk connections waiting for MsgTrunkHello identification
// Inbound trunk connections waiting for MsgPeerHello identification
std::map<Async::FramedTcpConnection*, Async::Timer*> m_trunk_pending_cons;
// Handed-off inbound trunk connections mapped to their TrunkLink
std::map<Async::FramedTcpConnection*, TrunkLink*> m_trunk_inbound_map;
@@ -379,7 +379,7 @@ class Reflector : public sigc::trackable
TwinLink* m_twin_link = nullptr;
Async::TcpServer<Async::FramedTcpConnection>* m_twin_srv = nullptr;
uint16_t m_twin_listen_port = 5304;
// Pending inbound twin connections awaiting MsgTrunkHello
// Pending inbound twin connections awaiting MsgPeerHello
std::map<Async::FramedTcpConnection*, Async::Timer*> m_twin_pending_cons;
// Satellite support
+47 -47
View File
@@ -1399,19 +1399,19 @@ class MsgStartUdpEncryption : public ReflectorMsgBase<114>
}; /* MsgStartUdpEncryption */
/***************************** Trunk Messages *****************************/
/***************************** Peer Messages *****************************/
/**
@brief Trunk handshake message
@brief Peer handshake message
@date 2026-03-20
Sent by both sides immediately after TCP connection is established. Exchanges
the local trunk ID, this side's local TG prefix (the digit string that all TGs
the local peer ID, this side's local TG prefix (the digit string that all TGs
owned by this reflector start with, e.g. "1" means TGs 1, 10, 100, 1000 ...),
and a random priority nonce used for tie-breaking when both sides claim the
same TG simultaneously (lower priority value defers to the peer).
*/
class MsgTrunkHello : public ReflectorMsgBase<115>
class MsgPeerHello : public ReflectorMsgBase<115>
{
public:
static const size_t NONCE_LEN = 20;
@@ -1420,7 +1420,7 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
static const uint8_t ROLE_SATELLITE = 1;
static const uint8_t ROLE_TWIN = 2; // HA-pair partner
MsgTrunkHello(void) : m_priority(0), m_role(ROLE_PEER) {}
MsgPeerHello(void) : m_priority(0), m_role(ROLE_PEER) {}
/**
* @brief Constructor that generates a nonce and computes HMAC
@@ -1430,7 +1430,7 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
* @param secret Shared secret for HMAC authentication
* @param role ROLE_PEER (default) or ROLE_SATELLITE
*/
MsgTrunkHello(const std::string& id,
MsgPeerHello(const std::string& id,
const std::string& local_prefix,
uint32_t priority,
const std::string& secret,
@@ -1441,13 +1441,13 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
int rc = RAND_bytes(&m_nonce.front(), NONCE_LEN);
if (rc != 1)
{
geulog::warn("trunk", "RAND_bytes failed in MsgTrunkHello");
geulog::warn("trunk", "RAND_bytes failed in MsgPeerHello");
m_nonce.clear();
return;
}
if (!calcHMAC(m_digest, secret, m_nonce.data(), m_nonce.size()))
{
geulog::error("trunk", "HMAC calculation failed in MsgTrunkHello");
geulog::error("trunk", "HMAC calculation failed in MsgPeerHello");
}
}
@@ -1498,21 +1498,21 @@ class MsgTrunkHello : public ReflectorMsgBase<115>
ok = ok && dgst.sign(hmac, data, len);
return ok;
}
}; /* MsgTrunkHello */
}; /* MsgPeerHello */
/**
@brief Trunk talker start message
@brief Peer talker start message
@date 2026-03-20
Sent when a local client starts talking on a shared TG. The receiving reflector
locks that TG to the trunk so its own clients cannot pre-empt the remote talker.
*/
class MsgTrunkTalkerStart : public ReflectorMsgBase<116>
class MsgPeerTalkerStart : public ReflectorMsgBase<116>
{
public:
MsgTrunkTalkerStart(void) : m_tg(0) {}
MsgTrunkTalkerStart(uint32_t tg, const std::string& callsign)
MsgPeerTalkerStart(void) : m_tg(0) {}
MsgPeerTalkerStart(uint32_t tg, const std::string& callsign)
: m_tg(tg), m_callsign(callsign) {}
uint32_t tg(void) const { return m_tg; }
const std::string& callsign(void) const { return m_callsign; }
@@ -1520,41 +1520,41 @@ class MsgTrunkTalkerStart : public ReflectorMsgBase<116>
private:
uint32_t m_tg;
std::string m_callsign;
}; /* MsgTrunkTalkerStart */
}; /* MsgPeerTalkerStart */
/**
@brief Trunk talker stop message
@brief Peer talker stop message
@date 2026-03-20
Sent when the active talker on a shared TG releases the channel. The receiving
reflector clears the trunk lock on that TG and broadcasts a flush to its clients.
reflector clears the peer lock on that TG and broadcasts a flush to its clients.
*/
class MsgTrunkTalkerStop : public ReflectorMsgBase<117>
class MsgPeerTalkerStop : public ReflectorMsgBase<117>
{
public:
MsgTrunkTalkerStop(void) : m_tg(0) {}
MsgTrunkTalkerStop(uint32_t tg) : m_tg(tg) {}
MsgPeerTalkerStop(void) : m_tg(0) {}
MsgPeerTalkerStop(uint32_t tg) : m_tg(tg) {}
uint32_t tg(void) const { return m_tg; }
ASYNC_MSG_MEMBERS(m_tg)
private:
uint32_t m_tg;
}; /* MsgTrunkTalkerStop */
}; /* MsgPeerTalkerStop */
/**
@brief Trunk audio message
@brief Peer audio message
@date 2026-03-20
Carries a single encoded audio frame for a shared TG over the trunk TCP
Carries a single encoded audio frame for a shared TG over the peer TCP
connection. The receiving reflector broadcasts it to all local clients
subscribed to that TG.
*/
class MsgTrunkAudio : public ReflectorMsgBase<118>
class MsgPeerAudio : public ReflectorMsgBase<118>
{
public:
MsgTrunkAudio(void) : m_tg(0) {}
MsgTrunkAudio(uint32_t tg, const std::vector<uint8_t>& audio)
MsgPeerAudio(void) : m_tg(0) {}
MsgPeerAudio(uint32_t tg, const std::vector<uint8_t>& audio)
: m_tg(tg), m_audio(audio) {}
uint32_t tg(void) const { return m_tg; }
const std::vector<uint8_t>& audio(void) const { return m_audio; }
@@ -1562,40 +1562,40 @@ class MsgTrunkAudio : public ReflectorMsgBase<118>
private:
uint32_t m_tg;
std::vector<uint8_t> m_audio;
}; /* MsgTrunkAudio */
}; /* MsgPeerAudio */
/**
@brief Trunk flush message
@brief Peer flush message
@date 2026-03-20
Sent after the last audio frame of a transmission to signal end-of-audio on
a shared TG. Triggers MsgUdpFlushSamples broadcast on the receiving side.
*/
class MsgTrunkFlush : public ReflectorMsgBase<119>
class MsgPeerFlush : public ReflectorMsgBase<119>
{
public:
MsgTrunkFlush(void) : m_tg(0) {}
MsgTrunkFlush(uint32_t tg) : m_tg(tg) {}
MsgPeerFlush(void) : m_tg(0) {}
MsgPeerFlush(uint32_t tg) : m_tg(tg) {}
uint32_t tg(void) const { return m_tg; }
ASYNC_MSG_MEMBERS(m_tg)
private:
uint32_t m_tg;
}; /* MsgTrunkFlush */
}; /* MsgPeerFlush */
/**
@brief Trunk heartbeat message
@brief Peer heartbeat message
@date 2026-03-20
Sent periodically in both directions to keep the TCP connection alive and
detect peer disconnection.
*/
class MsgTrunkHeartbeat : public ReflectorMsgBase<120>
class MsgPeerHeartbeat : public ReflectorMsgBase<120>
{
public:
ASYNC_MSG_NO_MEMBERS
}; /* MsgTrunkHeartbeat */
}; /* MsgPeerHeartbeat */
/***************************** UDP Messages *****************************/
@@ -1822,7 +1822,7 @@ class MsgUdpAudio : public ReflectorUdpMsgBase<101>
/**
@brief Trunk node list message (jayReflector extension, type 121)
@brief Peer node list message (jayReflector extension, type 121)
Sent by a reflector to its trunk peer whenever its local client list changes
(login, logout, TG change). The receiving peer can publish it via its own
@@ -1848,7 +1848,7 @@ m_status_blobs, then to add m_sat_ids. Each extension is a hard
lockstep bump because the unpack expects an exact vector count. All
peers in a mesh must be upgraded together.
*/
class MsgTrunkNodeList : public ReflectorMsgBase<121>
class MsgPeerNodeList : public ReflectorMsgBase<121>
{
public:
struct NodeEntry
@@ -1865,8 +1865,8 @@ class MsgTrunkNodeList : public ReflectorMsgBase<121>
// the sender that this client lives on
};
MsgTrunkNodeList(void) {}
explicit MsgTrunkNodeList(const std::vector<NodeEntry>& nodes)
MsgPeerNodeList(void) {}
explicit MsgPeerNodeList(const std::vector<NodeEntry>& nodes)
{
Json::StreamWriterBuilder wb;
wb["indentation"] = "";
@@ -1929,22 +1929,22 @@ class MsgTrunkNodeList : public ReflectorMsgBase<121>
std::vector<std::string> m_qth_names;
std::vector<std::string> m_status_blobs;
std::vector<std::string> m_sat_ids;
}; /* MsgTrunkNodeList */
}; /* MsgPeerNodeList */
/**
@brief Trunk filter advertisement (jayReflector extension, type 122)
@brief Peer filter advertisement (jayReflector extension, type 122)
Optional message sent (typically by a satellite after Hello) to tell the
parent which TGs it wants to receive. Filter syntax matches TgFilter
(exact / "24*" prefix / "10-20" range, comma-separated). Older peers
silently ignore unknown message types.
*/
class MsgTrunkFilter : public ReflectorMsgBase<122>
class MsgPeerFilter : public ReflectorMsgBase<122>
{
public:
MsgTrunkFilter(void) {}
explicit MsgTrunkFilter(const std::string& filter)
MsgPeerFilter(void) {}
explicit MsgPeerFilter(const std::string& filter)
: m_filter(filter) {}
const std::string& filter(void) const { return m_filter; }
@@ -1953,14 +1953,14 @@ class MsgTrunkFilter : public ReflectorMsgBase<122>
private:
std::string m_filter;
}; /* MsgTrunkFilter */
}; /* MsgPeerFilter */
/**
* @brief Twin-link message: mirror an external trunk's talker-start
* @brief Twin-link message: mirror an external peer's talker-start
*
* Sent over the [TWIN] link when this reflector receives a
* MsgTrunkTalkerStart from one of its external trunk peers, so that the
* MsgPeerTalkerStart from one of its external peer reflectors, so that the
* partner twin can update its own TGHandler state and block local clients
* from keying up the TG.
*/
@@ -1986,7 +1986,7 @@ class MsgTwinExtTalkerStart : public ReflectorMsgBase<123>
/**
* @brief Twin-link message: mirror an external trunk's talker-stop
* @brief Twin-link message: mirror an external peer's talker-stop
*/
class MsgTwinExtTalkerStop : public ReflectorMsgBase<124>
{
+52 -52
View File
@@ -159,7 +159,7 @@ void SatelliteClient::onLocalTalkerStart(uint32_t tg,
{
if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkTalkerStart(tg, callsign));
sendMsg(MsgPeerTalkerStart(tg, callsign));
} /* SatelliteClient::onLocalTalkerStart */
@@ -167,7 +167,7 @@ void SatelliteClient::onLocalTalkerStop(uint32_t tg)
{
if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkTalkerStop(tg));
sendMsg(MsgPeerTalkerStop(tg));
} /* SatelliteClient::onLocalTalkerStop */
@@ -176,7 +176,7 @@ void SatelliteClient::onLocalAudio(uint32_t tg,
{
if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkAudio(tg, audio));
sendMsg(MsgPeerAudio(tg, audio));
} /* SatelliteClient::onLocalAudio */
@@ -184,7 +184,7 @@ void SatelliteClient::onLocalFlush(uint32_t tg)
{
if (!m_con.isConnected() || !m_hello_received) return;
if (!m_filter.empty() && !m_filter.matches(tg)) return;
sendMsg(MsgTrunkFlush(tg));
sendMsg(MsgPeerFlush(tg));
} /* SatelliteClient::onLocalFlush */
@@ -197,8 +197,8 @@ void SatelliteClient::onConnected(void)
m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET;
m_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET;
sendMsg(MsgTrunkHello(m_satellite_id, "", m_priority, m_secret,
MsgTrunkHello::ROLE_SATELLITE));
sendMsg(MsgPeerHello(m_satellite_id, "", m_priority, m_secret,
MsgPeerHello::ROLE_SATELLITE));
m_heartbeat_timer.setEnable(true);
} /* SatelliteClient::onConnected */
@@ -219,7 +219,7 @@ void SatelliteClient::onDisconnected(TcpConnection* con,
// Tombstone-clear Redis live:peer_node:<parent_id>:* and let MQTT
// emit an empty list so consumers see the partner roster drop.
m_reflector->onPeerNodeList(m_parent_id,
std::vector<MsgTrunkNodeList::NodeEntry>{});
std::vector<MsgPeerNodeList::NodeEntry>{});
m_parent_nodes.clear();
}
} /* SatelliteClient::onDisconnected */
@@ -240,8 +240,8 @@ void SatelliteClient::onFrameReceived(FramedTcpConnection* con,
}
if (!m_hello_received &&
header.type() != MsgTrunkHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE)
header.type() != MsgPeerHello::TYPE &&
header.type() != MsgPeerHeartbeat::TYPE)
{
return;
}
@@ -250,26 +250,26 @@ void SatelliteClient::onFrameReceived(FramedTcpConnection* con,
switch (header.type())
{
case MsgTrunkHeartbeat::TYPE:
handleMsgTrunkHeartbeat();
case MsgPeerHeartbeat::TYPE:
handleMsgPeerHeartbeat();
break;
case MsgTrunkHello::TYPE:
handleMsgTrunkHello(ss);
case MsgPeerHello::TYPE:
handleMsgPeerHello(ss);
break;
case MsgTrunkTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss);
case MsgPeerTalkerStart::TYPE:
handleMsgPeerTalkerStart(ss);
break;
case MsgTrunkTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss);
case MsgPeerTalkerStop::TYPE:
handleMsgPeerTalkerStop(ss);
break;
case MsgTrunkAudio::TYPE:
handleMsgTrunkAudio(ss);
case MsgPeerAudio::TYPE:
handleMsgPeerAudio(ss);
break;
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
case MsgPeerFlush::TYPE:
handleMsgPeerFlush(ss);
break;
case MsgTrunkNodeList::TYPE:
handleMsgTrunkNodeList(ss);
case MsgPeerNodeList::TYPE:
handleMsgPeerNodeList(ss);
break;
default:
break;
@@ -277,17 +277,17 @@ void SatelliteClient::onFrameReceived(FramedTcpConnection* con,
} /* SatelliteClient::onFrameReceived */
void SatelliteClient::handleMsgTrunkHeartbeat(void)
void SatelliteClient::handleMsgPeerHeartbeat(void)
{
} /* SatelliteClient::handleMsgTrunkHeartbeat */
} /* SatelliteClient::handleMsgPeerHeartbeat */
void SatelliteClient::handleMsgTrunkHello(std::istream& is)
void SatelliteClient::handleMsgPeerHello(std::istream& is)
{
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(is))
{
geulog::error("satellite", "Failed to unpack MsgTrunkHello");
geulog::error("satellite", "Failed to unpack MsgPeerHello");
return;
}
@@ -310,40 +310,40 @@ void SatelliteClient::handleMsgTrunkHello(std::istream& is)
// parent can fan it out (debounced) — otherwise the first node-list
// emission only happens on the next client login/TG-change.
m_reflector->scheduleNodeListUpdate();
} /* SatelliteClient::handleMsgTrunkHello */
} /* SatelliteClient::handleMsgPeerHello */
void SatelliteClient::sendFilter(void)
{
if (m_filter_str.empty()) return;
sendMsg(MsgTrunkFilter(m_filter_str));
sendMsg(MsgPeerFilter(m_filter_str));
geulog::info("satellite", "Sent TG filter to parent: ", m_filter_str);
} /* SatelliteClient::sendFilter */
void SatelliteClient::handleMsgTrunkTalkerStart(std::istream& is)
void SatelliteClient::handleMsgPeerTalkerStart(std::istream& is)
{
MsgTrunkTalkerStart msg;
MsgPeerTalkerStart msg;
if (!msg.unpack(is)) return;
// Register as trunk talker — fires trunkTalkerUpdated which
// broadcasts MsgTalkerStart to local clients
TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign());
} /* SatelliteClient::handleMsgTrunkTalkerStart */
} /* SatelliteClient::handleMsgPeerTalkerStart */
void SatelliteClient::handleMsgTrunkTalkerStop(std::istream& is)
void SatelliteClient::handleMsgPeerTalkerStop(std::istream& is)
{
MsgTrunkTalkerStop msg;
MsgPeerTalkerStop msg;
if (!msg.unpack(is)) return;
TGHandler::instance()->clearTrunkTalkerForTG(msg.tg());
} /* SatelliteClient::handleMsgTrunkTalkerStop */
} /* SatelliteClient::handleMsgPeerTalkerStop */
void SatelliteClient::handleMsgTrunkAudio(std::istream& is)
void SatelliteClient::handleMsgPeerAudio(std::istream& is)
{
MsgTrunkAudio msg;
MsgPeerAudio msg;
if (!msg.unpack(is)) return;
if (msg.audio().empty()) return;
@@ -351,34 +351,34 @@ void SatelliteClient::handleMsgTrunkAudio(std::istream& is)
MsgUdpAudio udp_msg(msg.audio());
m_reflector->broadcastUdpMsg(udp_msg,
ReflectorClient::TgFilter(msg.tg()));
} /* SatelliteClient::handleMsgTrunkAudio */
} /* SatelliteClient::handleMsgPeerAudio */
void SatelliteClient::handleMsgTrunkFlush(std::istream& is)
void SatelliteClient::handleMsgPeerFlush(std::istream& is)
{
MsgTrunkFlush msg;
MsgPeerFlush msg;
if (!msg.unpack(is)) return;
m_reflector->broadcastUdpMsg(MsgUdpFlushSamples(),
ReflectorClient::TgFilter(msg.tg()));
} /* SatelliteClient::handleMsgTrunkFlush */
} /* SatelliteClient::handleMsgPeerFlush */
void SatelliteClient::handleMsgTrunkNodeList(std::istream& is)
void SatelliteClient::handleMsgPeerNodeList(std::istream& is)
{
MsgTrunkNodeList msg;
MsgPeerNodeList msg;
if (!msg.unpack(is))
{
geulog::error("satellite", "Failed to unpack MsgTrunkNodeList");
geulog::error("satellite", "Failed to unpack MsgPeerNodeList");
return;
}
std::vector<MsgTrunkNodeList::NodeEntry> sanitized;
std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size());
unsigned dropped = 0;
for (const auto& n : msg.nodes())
{
MsgTrunkNodeList::NodeEntry e;
MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty()) { ++dropped; continue; }
e.tg = n.tg;
@@ -409,24 +409,24 @@ void SatelliteClient::handleMsgTrunkNodeList(std::istream& is)
m_reflector->onPeerNodeList(m_parent_id, sanitized);
}
m_parent_nodes = std::move(sanitized);
} /* SatelliteClient::handleMsgTrunkNodeList */
} /* SatelliteClient::handleMsgPeerNodeList */
void SatelliteClient::sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
if (!m_con.isConnected() || !m_hello_received) return;
// Apply our outbound TG filter so we only push roster entries the
// parent cares about (consistent with the audio-path scoping rule).
std::vector<MsgTrunkNodeList::NodeEntry> filtered;
std::vector<MsgPeerNodeList::NodeEntry> filtered;
filtered.reserve(nodes.size());
for (const auto& n : nodes)
{
if (!m_filter.empty() && !m_filter.matches(n.tg)) continue;
filtered.push_back(n);
}
sendMsg(MsgTrunkNodeList(filtered));
sendMsg(MsgPeerNodeList(filtered));
} /* SatelliteClient::sendNodeList */
@@ -449,7 +449,7 @@ void SatelliteClient::heartbeatTick(Async::Timer* t)
if (--m_hb_tx_cnt == 0)
{
m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET;
sendMsg(MsgTrunkHeartbeat());
sendMsg(MsgPeerHeartbeat());
}
if (--m_hb_rx_cnt == 0)
+13 -13
View File
@@ -26,7 +26,7 @@ An optional SATELLITE_FILTER scopes which TGs this satellite cares about,
in both directions (TgFilter syntax: exact, prefix "24*", range
"2427-2438", comma-separated):
- outbound: local events for non-matching TGs are not sent to the parent;
- inbound: the filter is sent to the parent via MsgTrunkFilter (type 122)
- inbound: the filter is sent to the parent via MsgPeerFilter (type 122)
after authentication; the parent skips forwarding non-matching TGs.
*/
class SatelliteClient : public sigc::trackable
@@ -46,11 +46,11 @@ class SatelliteClient : public sigc::trackable
// Send our local roster up to the parent. Caller has already filtered
// to "this satellite's local clients" (sat_id empty on the wire).
void sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
// Read-only access to the parent's combined-view roster, surfaced
// by Reflector::statusJson under /status.parent.nodes.
const std::vector<MsgTrunkNodeList::NodeEntry>& parentNodes(void) const
const std::vector<MsgPeerNodeList::NodeEntry>& parentNodes(void) const
{
return m_parent_nodes;
}
@@ -76,26 +76,26 @@ class SatelliteClient : public sigc::trackable
unsigned m_hb_tx_cnt;
unsigned m_hb_rx_cnt;
TgFilter m_filter; // optional TG filter (SATELLITE_FILTER)
std::string m_filter_str; // raw config string for MsgTrunkFilter
// Parent's id from MsgTrunkHello (used as the peer_id key for Redis
std::string m_filter_str; // raw config string for MsgPeerFilter
// Parent's id from MsgPeerHello (used as the peer_id key for Redis
// tombstone bookkeeping when storing the parent-supplied roster).
std::string m_parent_id;
// Parent's combined roster (parent-local + every sibling satellite,
// minus our own contribution). Surfaced via /status.parent.nodes.
std::vector<MsgTrunkNodeList::NodeEntry> m_parent_nodes;
std::vector<MsgPeerNodeList::NodeEntry> m_parent_nodes;
void onConnected(void);
void onDisconnected(Async::TcpConnection* con,
Async::TcpConnection::DisconnectReason reason);
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 handleMsgTrunkNodeList(std::istream& is);
void handleMsgPeerHello(std::istream& is);
void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgPeerAudio(std::istream& is);
void handleMsgPeerFlush(std::istream& is);
void handleMsgPeerHeartbeat(void);
void handleMsgPeerNodeList(std::istream& is);
void sendMsg(const ReflectorMsg& msg);
void sendFilter(void);
void heartbeatTick(Async::Timer* t);
+58 -58
View File
@@ -118,7 +118,7 @@ SatelliteLink::~SatelliteLink(void)
if (!m_partner_nodes.empty() && !m_satellite_id.empty())
{
m_reflector->onPeerNodeList(m_satellite_id,
std::vector<MsgTrunkNodeList::NodeEntry>{});
std::vector<MsgPeerNodeList::NodeEntry>{});
m_partner_nodes.clear();
}
} /* SatelliteLink::~SatelliteLink */
@@ -171,7 +171,7 @@ void SatelliteLink::onParentTalkerStart(uint32_t tg,
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkTalkerStart(tg, callsign));
sendMsg(MsgPeerTalkerStart(tg, callsign));
} /* SatelliteLink::onParentTalkerStart */
@@ -179,7 +179,7 @@ void SatelliteLink::onParentTalkerStop(uint32_t tg)
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkTalkerStop(tg));
sendMsg(MsgPeerTalkerStop(tg));
} /* SatelliteLink::onParentTalkerStop */
@@ -188,7 +188,7 @@ void SatelliteLink::onParentAudio(uint32_t tg,
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkAudio(tg, audio));
sendMsg(MsgPeerAudio(tg, audio));
} /* SatelliteLink::onParentAudio */
@@ -196,7 +196,7 @@ void SatelliteLink::onParentFlush(uint32_t tg)
{
if (!m_hello_received) return;
if (!filterPassesTg(tg)) return;
sendMsg(MsgTrunkFlush(tg));
sendMsg(MsgPeerFlush(tg));
} /* SatelliteLink::onParentFlush */
@@ -215,8 +215,8 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
}
if (!m_hello_received &&
header.type() != MsgTrunkHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE)
header.type() != MsgPeerHello::TYPE &&
header.type() != MsgPeerHeartbeat::TYPE)
{
geulog::warn("satellite", "Ignoring message type=", header.type(),
" before hello");
@@ -227,29 +227,29 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
switch (header.type())
{
case MsgTrunkHeartbeat::TYPE:
handleMsgTrunkHeartbeat();
case MsgPeerHeartbeat::TYPE:
handleMsgPeerHeartbeat();
break;
case MsgTrunkHello::TYPE:
handleMsgTrunkHello(ss);
case MsgPeerHello::TYPE:
handleMsgPeerHello(ss);
break;
case MsgTrunkTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss);
case MsgPeerTalkerStart::TYPE:
handleMsgPeerTalkerStart(ss);
break;
case MsgTrunkTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss);
case MsgPeerTalkerStop::TYPE:
handleMsgPeerTalkerStop(ss);
break;
case MsgTrunkAudio::TYPE:
handleMsgTrunkAudio(ss);
case MsgPeerAudio::TYPE:
handleMsgPeerAudio(ss);
break;
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
case MsgPeerFlush::TYPE:
handleMsgPeerFlush(ss);
break;
case MsgTrunkFilter::TYPE:
handleMsgTrunkFilter(ss);
case MsgPeerFilter::TYPE:
handleMsgPeerFilter(ss);
break;
case MsgTrunkNodeList::TYPE:
handleMsgTrunkNodeList(ss);
case MsgPeerNodeList::TYPE:
handleMsgPeerNodeList(ss);
break;
default:
geulog::warn("satellite", "Unknown message type=", header.type());
@@ -258,17 +258,17 @@ void SatelliteLink::onFrameReceived(FramedTcpConnection* con,
} /* SatelliteLink::onFrameReceived */
void SatelliteLink::handleMsgTrunkHeartbeat(void)
void SatelliteLink::handleMsgPeerHeartbeat(void)
{
} /* SatelliteLink::handleMsgTrunkHeartbeat */
} /* SatelliteLink::handleMsgPeerHeartbeat */
void SatelliteLink::handleMsgTrunkHello(std::istream& is)
void SatelliteLink::handleMsgPeerHello(std::istream& is)
{
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(is))
{
geulog::error("satellite", "Failed to unpack MsgTrunkHello");
geulog::error("satellite", "Failed to unpack MsgPeerHello");
return;
}
@@ -279,7 +279,7 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
return;
}
if (msg.role() != MsgTrunkHello::ROLE_SATELLITE)
if (msg.role() != MsgPeerHello::ROLE_SATELLITE)
{
geulog::error("satellite", "Expected ROLE_SATELLITE from '", msg.id(),
"' but got role=", (int)msg.role());
@@ -304,8 +304,8 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
// and start forwarding local events. This also generates early
// parent→satellite traffic, keeping the connection alive through
// firewalls / NAT devices that drop idle TCP sessions.
sendMsg(MsgTrunkHello("PARENT", "", 0, m_secret,
MsgTrunkHello::ROLE_PEER));
sendMsg(MsgPeerHello("PARENT", "", 0, m_secret,
MsgPeerHello::ROLE_PEER));
// Bring the new satellite up to speed: schedule a debounced node-list
// emission so it receives the parent's combined view (parent-local
@@ -313,12 +313,12 @@ void SatelliteLink::handleMsgTrunkHello(std::istream& is)
m_reflector->scheduleNodeListUpdate();
statusChanged(this);
} /* SatelliteLink::handleMsgTrunkHello */
} /* SatelliteLink::handleMsgPeerHello */
void SatelliteLink::handleMsgTrunkTalkerStart(std::istream& is)
void SatelliteLink::handleMsgPeerTalkerStart(std::istream& is)
{
MsgTrunkTalkerStart msg;
MsgPeerTalkerStart msg;
if (!msg.unpack(is)) return;
uint32_t tg = msg.tg();
@@ -333,12 +333,12 @@ void SatelliteLink::handleMsgTrunkTalkerStart(std::istream& is)
m_reflector->forwardSatelliteAudioToTrunks(tg, msg.callsign());
statusChanged(this);
} /* SatelliteLink::handleMsgTrunkTalkerStart */
} /* SatelliteLink::handleMsgPeerTalkerStart */
void SatelliteLink::handleMsgTrunkTalkerStop(std::istream& is)
void SatelliteLink::handleMsgPeerTalkerStop(std::istream& is)
{
MsgTrunkTalkerStop msg;
MsgPeerTalkerStop msg;
if (!msg.unpack(is)) return;
uint32_t tg = msg.tg();
@@ -349,12 +349,12 @@ void SatelliteLink::handleMsgTrunkTalkerStop(std::istream& is)
m_reflector->forwardSatelliteStopToTrunks(tg);
statusChanged(this);
} /* SatelliteLink::handleMsgTrunkTalkerStop */
} /* SatelliteLink::handleMsgPeerTalkerStop */
void SatelliteLink::handleMsgTrunkAudio(std::istream& is)
void SatelliteLink::handleMsgPeerAudio(std::istream& is)
{
MsgTrunkAudio msg;
MsgPeerAudio msg;
if (!msg.unpack(is)) return;
uint32_t tg = msg.tg();
@@ -370,12 +370,12 @@ void SatelliteLink::handleMsgTrunkAudio(std::istream& is)
// Forward to other satellites (not this one)
m_reflector->forwardAudioToSatellitesExcept(this, tg, msg.audio());
} /* SatelliteLink::handleMsgTrunkAudio */
} /* SatelliteLink::handleMsgPeerAudio */
void SatelliteLink::handleMsgTrunkFlush(std::istream& is)
void SatelliteLink::handleMsgPeerFlush(std::istream& is)
{
MsgTrunkFlush msg;
MsgPeerFlush msg;
if (!msg.unpack(is)) return;
uint32_t tg = msg.tg();
@@ -385,7 +385,7 @@ void SatelliteLink::handleMsgTrunkFlush(std::istream& is)
m_reflector->forwardSatelliteFlushToTrunks(tg);
m_reflector->forwardFlushToSatellitesExcept(this, tg);
} /* SatelliteLink::handleMsgTrunkFlush */
} /* SatelliteLink::handleMsgPeerFlush */
void SatelliteLink::sendMsg(const ReflectorMsg& msg)
@@ -407,7 +407,7 @@ void SatelliteLink::heartbeatTick(Async::Timer* t)
if (--m_hb_tx_cnt == 0)
{
m_hb_tx_cnt = HEARTBEAT_TX_CNT_RESET;
sendMsg(MsgTrunkHeartbeat());
sendMsg(MsgPeerHeartbeat());
}
if (--m_hb_rx_cnt == 0)
@@ -420,12 +420,12 @@ void SatelliteLink::heartbeatTick(Async::Timer* t)
} /* SatelliteLink::heartbeatTick */
void SatelliteLink::handleMsgTrunkFilter(std::istream& is)
void SatelliteLink::handleMsgPeerFilter(std::istream& is)
{
MsgTrunkFilter msg;
MsgPeerFilter msg;
if (!msg.unpack(is))
{
geulog::error("satellite", "Failed to unpack MsgTrunkFilter from '",
geulog::error("satellite", "Failed to unpack MsgPeerFilter from '",
m_satellite_id, "'");
return;
}
@@ -445,7 +445,7 @@ void SatelliteLink::handleMsgTrunkFilter(std::istream& is)
}
statusChanged(this);
} /* SatelliteLink::handleMsgTrunkFilter */
} /* SatelliteLink::handleMsgPeerFilter */
bool SatelliteLink::filterPassesTg(uint32_t tg) const
@@ -456,22 +456,22 @@ bool SatelliteLink::filterPassesTg(uint32_t tg) const
} /* SatelliteLink::filterPassesTg */
void SatelliteLink::handleMsgTrunkNodeList(std::istream& is)
void SatelliteLink::handleMsgPeerNodeList(std::istream& is)
{
MsgTrunkNodeList msg;
MsgPeerNodeList msg;
if (!msg.unpack(is))
{
geulog::error("satellite", "Failed to unpack MsgTrunkNodeList from '",
geulog::error("satellite", "Failed to unpack MsgPeerNodeList from '",
m_satellite_id, "'");
return;
}
std::vector<MsgTrunkNodeList::NodeEntry> sanitized;
std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size());
unsigned dropped = 0;
for (const auto& n : msg.nodes())
{
MsgTrunkNodeList::NodeEntry e;
MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty()) { ++dropped; continue; }
e.tg = n.tg;
@@ -507,22 +507,22 @@ void SatelliteLink::handleMsgTrunkNodeList(std::istream& is)
m_reflector->scheduleNodeListUpdate();
statusChanged(this);
} /* SatelliteLink::handleMsgTrunkNodeList */
} /* SatelliteLink::handleMsgPeerNodeList */
void SatelliteLink::sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
if (!m_hello_received) return;
// Apply this satellite's announced filter so we only forward TGs the
// satellite cares about (matches the audio-path scoping rule).
std::vector<MsgTrunkNodeList::NodeEntry> filtered;
std::vector<MsgPeerNodeList::NodeEntry> filtered;
filtered.reserve(nodes.size());
for (const auto& n : nodes)
{
if (!filterPassesTg(n.tg)) continue;
filtered.push_back(n);
}
sendMsg(MsgTrunkNodeList(filtered));
sendMsg(MsgPeerNodeList(filtered));
} /* SatelliteLink::sendNodeList */
+13 -13
View File
@@ -19,7 +19,7 @@ class Reflector;
A SatelliteLink is created for each satellite that connects to the parent's
satellite port. By default it relays ALL TGs bidirectionally. When the
satellite sends a MsgTrunkFilter (type 122), the parent applies the filter
satellite sends a MsgPeerFilter (type 122), the parent applies the filter
to outbound traffic — only matching TGs are forwarded to this satellite.
The parent always wins talker arbitration over satellites.
*/
@@ -60,13 +60,13 @@ class SatelliteLink : public sigc::trackable
// method additionally drops entries whose TG falls outside the
// satellite's announced filter (if any).
void sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
// Read-only access to the satellite-supplied roster (this satellite's
// local clients), already sanitised and stamped with sat_id =
// satelliteId(). Used by Reflector to merge into the parent's
// outbound advertisements.
const std::vector<MsgTrunkNodeList::NodeEntry>& partnerNodes(void) const
const std::vector<MsgPeerNodeList::NodeEntry>& partnerNodes(void) const
{
return m_partner_nodes;
}
@@ -86,22 +86,22 @@ class SatelliteLink : public sigc::trackable
std::set<uint32_t> m_sat_active_tgs;
TgFilter m_tg_filter;
// Roster of clients attached to this satellite, learned via
// MsgTrunkNodeList from the satellite. Each entry carries
// MsgPeerNodeList from the satellite. Each entry carries
// sat_id == m_satellite_id (stamped on ingest) so the Reflector can
// merge it into outbound trunk/twin/sibling-sat lists with correct
// attribution.
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes;
std::vector<MsgPeerNodeList::NodeEntry> m_partner_nodes;
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 handleMsgTrunkFilter(std::istream& is);
void handleMsgTrunkNodeList(std::istream& is);
void handleMsgPeerHello(std::istream& is);
void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgPeerAudio(std::istream& is);
void handleMsgPeerFlush(std::istream& is);
void handleMsgPeerHeartbeat(void);
void handleMsgPeerFilter(std::istream& is);
void handleMsgPeerNodeList(std::istream& is);
bool filterPassesTg(uint32_t tg) const;
void sendMsg(const ReflectorMsg& msg);
void heartbeatTick(Async::Timer* t);
+90 -90
View File
@@ -573,7 +573,7 @@ Json::Value TrunkLink::statusJson(void) const
if (!n.qth_name.empty()) entry["qth_name"] = n.qth_name;
if (!n.sat_id.empty()) entry["sat_id"] = n.sat_id;
// Derive isTalker from the live trunk-talker map maintained by
// MsgTrunkTalkerStart/Stop. Authoritative for partner nodes; the
// MsgPeerTalkerStart/Stop. Authoritative for partner nodes; the
// sender's own isTalker is stale by the time it arrives in the
// periodic node-list push.
entry["isTalker"] =
@@ -587,7 +587,7 @@ Json::Value TrunkLink::statusJson(void) const
void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello)
const MsgPeerHello& hello)
{
if (m_paired)
{
@@ -620,7 +620,7 @@ void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con,
// Send our hello back on this inbound connection
sendMsgOnPairedInbound(m_ib_cons.size() - 1,
MsgTrunkHello(m_peer_id_config, joinPrefixes(m_local_prefix),
MsgPeerHello(m_peer_id_config, joinPrefixes(m_local_prefix),
m_priority, m_secret));
return;
}
@@ -667,7 +667,7 @@ void TrunkLink::acceptInboundConnection(Async::FramedTcpConnection* con,
" ib_hb_tx=", m_ib_hb_tx_cnt, " ib_hb_rx=", m_ib_hb_rx_cnt);
// Send our hello back on the inbound connection
sendMsgOnInbound(MsgTrunkHello(m_peer_id_config,
sendMsgOnInbound(MsgPeerHello(m_peer_id_config,
joinPrefixes(m_local_prefix),
m_priority, m_secret));
} /* TrunkLink::acceptInboundConnection */
@@ -729,7 +729,7 @@ void TrunkLink::onLocalTalkerStart(uint32_t tg, const std::string& callsign)
{
return;
}
sendMsg(MsgTrunkTalkerStart(mapTgOut(tg), callsign));
sendMsg(MsgPeerTalkerStart(mapTgOut(tg), callsign));
} /* TrunkLink::onLocalTalkerStart */
@@ -749,7 +749,7 @@ void TrunkLink::onLocalTalkerStop(uint32_t tg)
{
return;
}
sendMsg(MsgTrunkTalkerStop(mapTgOut(tg)));
sendMsg(MsgPeerTalkerStop(mapTgOut(tg)));
} /* TrunkLink::onLocalTalkerStop */
@@ -767,7 +767,7 @@ void TrunkLink::onLocalAudio(uint32_t tg, const std::vector<uint8_t>& audio)
{
return;
}
sendMsg(MsgTrunkAudio(mapTgOut(tg), audio));
sendMsg(MsgPeerAudio(mapTgOut(tg), audio));
} /* TrunkLink::onLocalAudio */
@@ -781,7 +781,7 @@ void TrunkLink::onLocalFlush(uint32_t tg)
{
return;
}
sendMsg(MsgTrunkFlush(mapTgOut(tg)));
sendMsg(MsgPeerFlush(mapTgOut(tg)));
} /* TrunkLink::onLocalFlush */
@@ -808,7 +808,7 @@ void TrunkLink::onConnected(void)
m_ob_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET;
m_heartbeat_timer.setEnable(true);
sendMsgOnOutbound(MsgTrunkHello(m_peer_id_config,
sendMsgOnOutbound(MsgPeerHello(m_peer_id_config,
joinPrefixes(m_local_prefix),
m_priority, m_secret));
} /* TrunkLink::onConnected */
@@ -864,8 +864,8 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
// Only allow hello and heartbeat before hello exchange completes
if (!hello_done &&
header.type() != MsgTrunkHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE)
header.type() != MsgPeerHello::TYPE &&
header.type() != MsgPeerHeartbeat::TYPE)
{
geulog::warn("trunk", "[", m_section, "] Ignoring trunk message type=",
header.type(), " before hello");
@@ -882,7 +882,7 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
m_ob_hb_rx_cnt = HEARTBEAT_RX_CNT_RESET;
}
if (header.type() != MsgTrunkHeartbeat::TYPE)
if (header.type() != MsgPeerHeartbeat::TYPE)
{
geulog::debug("trunk", m_section, ": rx ", (is_inbound ? "IB" : "OB"),
" type=", header.type(), " len=", data.size());
@@ -890,26 +890,26 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
switch (header.type())
{
case MsgTrunkHeartbeat::TYPE:
handleMsgTrunkHeartbeat();
case MsgPeerHeartbeat::TYPE:
handleMsgPeerHeartbeat();
break;
case MsgTrunkHello::TYPE:
handleMsgTrunkHello(ss, is_inbound);
case MsgPeerHello::TYPE:
handleMsgPeerHello(ss, is_inbound);
break;
case MsgTrunkTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss);
case MsgPeerTalkerStart::TYPE:
handleMsgPeerTalkerStart(ss);
break;
case MsgTrunkTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss);
case MsgPeerTalkerStop::TYPE:
handleMsgPeerTalkerStop(ss);
break;
case MsgTrunkAudio::TYPE:
handleMsgTrunkAudio(ss);
case MsgPeerAudio::TYPE:
handleMsgPeerAudio(ss);
break;
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
case MsgPeerFlush::TYPE:
handleMsgPeerFlush(ss);
break;
case MsgTrunkNodeList::TYPE:
handleMsgTrunkNodeList(ss);
case MsgPeerNodeList::TYPE:
handleMsgPeerNodeList(ss);
break;
default:
geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=",
@@ -919,13 +919,13 @@ void TrunkLink::onFrameReceived(FramedTcpConnection* con,
} /* TrunkLink::onFrameReceived */
void TrunkLink::handleMsgTrunkHeartbeat(void)
void TrunkLink::handleMsgPeerHeartbeat(void)
{
// rx counter already reset in onFrameReceived
} /* TrunkLink::handleMsgTrunkHeartbeat */
} /* TrunkLink::handleMsgPeerHeartbeat */
void TrunkLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
void TrunkLink::handleMsgPeerHello(std::istream& is, bool is_inbound)
{
// Inbound hellos are already handled by acceptInboundConnection.
// A duplicate arriving here means the peer re-sent (e.g. TcpPrioClient
@@ -937,17 +937,17 @@ void TrunkLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
}
// Hello on outbound = peer's reply to our outbound hello
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(is))
{
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkHello");
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerHello");
return;
}
if (msg.id().empty())
{
geulog::error("trunk", "[", m_section,
"] Peer sent empty trunk ID in MsgTrunkHello");
"] Peer sent empty trunk ID in MsgPeerHello");
m_con.disconnect();
return;
}
@@ -974,15 +974,15 @@ void TrunkLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
" ib_connected=", (m_inbound_con != nullptr),
" ib_hello=", m_ib_hello_received,
" isActive=", isActive());
} /* TrunkLink::handleMsgTrunkHello */
} /* TrunkLink::handleMsgPeerHello */
void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is)
void TrunkLink::handleMsgPeerTalkerStart(std::istream& is)
{
MsgTrunkTalkerStart msg;
MsgPeerTalkerStart msg;
if (!msg.unpack(is))
{
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkTalkerStart");
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerTalkerStart");
return;
}
@@ -1034,15 +1034,15 @@ void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is)
m_reflector->forwardTrunkTalkerStartToOtherTrunks(this, local_tg,
msg.callsign());
}
} /* TrunkLink::handleMsgTrunkTalkerStart */
} /* TrunkLink::handleMsgPeerTalkerStart */
void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is)
void TrunkLink::handleMsgPeerTalkerStop(std::istream& is)
{
MsgTrunkTalkerStop msg;
MsgPeerTalkerStop msg;
if (!msg.unpack(is))
{
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkTalkerStop");
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerTalkerStop");
return;
}
@@ -1068,15 +1068,15 @@ void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is)
{
m_reflector->forwardTrunkTalkerStopToOtherTrunks(this, local_tg);
}
} /* TrunkLink::handleMsgTrunkTalkerStop */
} /* TrunkLink::handleMsgPeerTalkerStop */
void TrunkLink::handleMsgTrunkAudio(std::istream& is)
void TrunkLink::handleMsgPeerAudio(std::istream& is)
{
MsgTrunkAudio msg;
MsgPeerAudio msg;
if (!msg.unpack(is))
{
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkAudio");
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerAudio");
return;
}
@@ -1122,15 +1122,15 @@ void TrunkLink::handleMsgTrunkAudio(std::istream& is)
{
m_reflector->forwardTrunkAudioToOtherTrunks(this, local_tg, msg.audio());
}
} /* TrunkLink::handleMsgTrunkAudio */
} /* TrunkLink::handleMsgPeerAudio */
void TrunkLink::handleMsgTrunkFlush(std::istream& is)
void TrunkLink::handleMsgPeerFlush(std::istream& is)
{
MsgTrunkFlush msg;
MsgPeerFlush msg;
if (!msg.unpack(is))
{
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkFlush");
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerFlush");
return;
}
@@ -1158,7 +1158,7 @@ void TrunkLink::handleMsgTrunkFlush(std::istream& is)
{
m_reflector->forwardTrunkFlushToOtherTrunks(this, local_tg);
}
} /* TrunkLink::handleMsgTrunkFlush */
} /* TrunkLink::handleMsgPeerFlush */
void TrunkLink::sendMsg(const ReflectorMsg& msg)
@@ -1264,7 +1264,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{
geulog::debug("trunk", m_section, ": paired OB#", i, " heartbeat tx",
" hb_rx=", m_ob_states[i].hb_rx_cnt);
sendMsgOnPairedOutbound(i, MsgTrunkHeartbeat());
sendMsgOnPairedOutbound(i, MsgPeerHeartbeat());
}
if (--m_ob_states[i].hb_rx_cnt == 0)
{
@@ -1290,7 +1290,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{
geulog::debug("trunk", m_section, ": paired IB#", i, " heartbeat tx",
" hb_rx=", m_ib_states[i].hb_rx_cnt);
sendMsgOnPairedInbound(i, MsgTrunkHeartbeat());
sendMsgOnPairedInbound(i, MsgPeerHeartbeat());
}
if (--m_ib_states[i].hb_rx_cnt == 0)
{
@@ -1331,7 +1331,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{
geulog::debug("trunk", m_section, ": OB heartbeat tx ob_hb_rx=",
m_ob_hb_rx_cnt);
sendMsgOnOutbound(MsgTrunkHeartbeat());
sendMsgOnOutbound(MsgPeerHeartbeat());
}
if (--m_ob_hb_rx_cnt == 0)
{
@@ -1352,7 +1352,7 @@ void TrunkLink::heartbeatTick(Async::Timer* t)
{
geulog::debug("trunk", m_section, ": IB heartbeat tx ib_hb_rx=",
m_ib_hb_rx_cnt);
sendMsgOnInbound(MsgTrunkHeartbeat());
sendMsgOnInbound(MsgPeerHeartbeat());
}
if (--m_ib_hb_rx_cnt == 0)
{
@@ -1505,12 +1505,12 @@ void TrunkLink::onPairedInboundFrame(Async::FramedTcpConnection* con,
switch (header.type())
{
case MsgTrunkHello::TYPE:
case MsgPeerHello::TYPE:
// Duplicate hello — the hello was already processed by Reflector's
// acceptInboundConnection path; ignore silently.
break;
case MsgTrunkHeartbeat::TYPE:
case MsgPeerHeartbeat::TYPE:
// hb_rx_cnt already reset above; nothing else needed
break;
@@ -1518,20 +1518,20 @@ void TrunkLink::onPairedInboundFrame(Async::FramedTcpConnection* con,
// Dispatch data messages to shared handlers
switch (header.type())
{
case MsgTrunkTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss);
case MsgPeerTalkerStart::TYPE:
handleMsgPeerTalkerStart(ss);
break;
case MsgTrunkTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss);
case MsgPeerTalkerStop::TYPE:
handleMsgPeerTalkerStop(ss);
break;
case MsgTrunkAudio::TYPE:
handleMsgTrunkAudio(ss);
case MsgPeerAudio::TYPE:
handleMsgPeerAudio(ss);
break;
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
case MsgPeerFlush::TYPE:
handleMsgPeerFlush(ss);
break;
case MsgTrunkNodeList::TYPE:
handleMsgTrunkNodeList(ss);
case MsgPeerNodeList::TYPE:
handleMsgPeerNodeList(ss);
break;
default:
geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=",
@@ -1574,8 +1574,8 @@ void TrunkLink::onPairedOutboundConnected(FramedTcpClient* client)
" sending hello with priority=", m_priority);
sendMsgOnPairedOutbound(idx,
MsgTrunkHello(m_peer_id_config, joinPrefixes(m_local_prefix),
m_priority, m_secret, MsgTrunkHello::ROLE_PEER));
MsgPeerHello(m_peer_id_config, joinPrefixes(m_local_prefix),
m_priority, m_secret, MsgPeerHello::ROLE_PEER));
} /* TrunkLink::onPairedOutboundConnected */
@@ -1628,8 +1628,8 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
// Only allow hello and heartbeat before handshake completes
if (!m_ob_states[idx].hello_received &&
header.type() != MsgTrunkHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE)
header.type() != MsgPeerHello::TYPE &&
header.type() != MsgPeerHeartbeat::TYPE)
{
geulog::warn("trunk", "[", m_section, "] Ignoring paired ob#", idx,
" msg type=", header.type(), " before hello");
@@ -1638,9 +1638,9 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
switch (header.type())
{
case MsgTrunkHello::TYPE:
case MsgPeerHello::TYPE:
{
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(ss)) return;
if (msg.id().empty())
@@ -1672,7 +1672,7 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
break;
}
case MsgTrunkHeartbeat::TYPE:
case MsgPeerHeartbeat::TYPE:
// hb_rx_cnt already reset above; nothing else needed
break;
@@ -1682,20 +1682,20 @@ void TrunkLink::onPairedOutboundFrame(FramedTcpClient* client,
// `ss` is already positioned past the header so we can pass it directly.
switch (header.type())
{
case MsgTrunkTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss);
case MsgPeerTalkerStart::TYPE:
handleMsgPeerTalkerStart(ss);
break;
case MsgTrunkTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss);
case MsgPeerTalkerStop::TYPE:
handleMsgPeerTalkerStop(ss);
break;
case MsgTrunkAudio::TYPE:
handleMsgTrunkAudio(ss);
case MsgPeerAudio::TYPE:
handleMsgPeerAudio(ss);
break;
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
case MsgPeerFlush::TYPE:
handleMsgPeerFlush(ss);
break;
case MsgTrunkNodeList::TYPE:
handleMsgTrunkNodeList(ss);
case MsgPeerNodeList::TYPE:
handleMsgPeerNodeList(ss);
break;
default:
geulog::warn("trunk", "[", m_section, "] Unknown trunk message type=",
@@ -1787,31 +1787,31 @@ void TrunkLink::reloadConfig(void)
void TrunkLink::sendNodeList(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
if (!isActive()) return;
sendMsg(MsgTrunkNodeList(nodes));
sendMsg(MsgPeerNodeList(nodes));
} /* TrunkLink::sendNodeList */
void TrunkLink::handleMsgTrunkNodeList(std::istream& is)
void TrunkLink::handleMsgPeerNodeList(std::istream& is)
{
MsgTrunkNodeList msg;
MsgPeerNodeList msg;
if (!msg.unpack(is))
{
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgTrunkNodeList");
geulog::error("trunk", "[", m_section, "] Failed to unpack MsgPeerNodeList");
return;
}
// Sanitize every entry before handing off. Untrusted strings from peer
// reflectors flow into Redis key names, MQTT payloads and log output;
// keep them byte-bounded and free of control / delimiter characters.
std::vector<MsgTrunkNodeList::NodeEntry> sanitized;
std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size());
unsigned dropped = 0;
for (const auto& n : msg.nodes())
{
MsgTrunkNodeList::NodeEntry e;
MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty())
{
@@ -1852,7 +1852,7 @@ void TrunkLink::handleMsgTrunkNodeList(std::istream& is)
m_reflector->onPeerNodeList(peerId(), sanitized);
m_partner_nodes = std::move(sanitized);
} /* TrunkLink::handleMsgTrunkNodeList */
} /* TrunkLink::handleMsgPeerNodeList */
std::string TrunkLink::statusLine(void) const
+14 -14
View File
@@ -64,7 +64,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
class Reflector;
class ReflectorMsg;
class MsgTrunkHello;
class MsgPeerHello;
class MsgUdpAudio;
@@ -87,7 +87,7 @@ connection (with inbound as fallback). Heartbeats are sent on each connection
independently to detect dead sockets.
Talker arbitration tie-break: each side generates a random 32-bit priority at
startup and exchanges it in MsgTrunkHello. When both sides claim the same TG
startup and exchanges it in MsgPeerHello. When both sides claim the same TG
simultaneously, the side with the lower priority value defers (clears its local
talker and accepts the remote one).
*/
@@ -129,7 +129,7 @@ class TrunkLink : public sigc::trackable
// Accept an inbound connection from a peer that has already sent a hello
void acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello);
const MsgPeerHello& hello);
// Called by Reflector when the inbound connection disconnects
void onInboundDisconnected(Async::FramedTcpConnection* con,
@@ -147,7 +147,7 @@ class TrunkLink : public sigc::trackable
// Send the local node list (callsign + current TG per local client)
// to the peer. Called from Reflector after debounce.
void sendNodeList(const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
void sendNodeList(const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
// PTY-driven controls
void muteCallsign(const std::string& callsign)
@@ -189,7 +189,7 @@ class TrunkLink : public sigc::trackable
std::vector<std::string> m_local_prefix; // our authoritative TG prefixes
std::vector<std::string> m_remote_prefix; // peer's authoritative TG prefixes
uint32_t m_priority; // our tie-break nonce (random, set once)
uint32_t m_peer_priority; // peer's nonce, from MsgTrunkHello
uint32_t m_peer_priority; // peer's nonce, from MsgPeerHello
FramedTcpClient m_con; // outbound client connection
Async::FramedTcpConnection* m_inbound_con = nullptr; // accepted inbound
Async::Timer m_heartbeat_timer;
@@ -204,10 +204,10 @@ class TrunkLink : public sigc::trackable
// TGs currently held by this specific trunk peer (for scoped cleanup)
std::set<uint32_t> m_peer_active_tgs;
// Most recent MsgTrunkNodeList we received from the peer, sanitized.
// Most recent MsgPeerNodeList we received from the peer, sanitized.
// Surfaced in statusJson() so /status can attribute nodes to a peer.
// Cleared when the link goes fully inactive.
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes;
std::vector<MsgPeerNodeList::NodeEntry> m_partner_nodes;
// TGs the peer has shown interest in (sent TalkerStart for).
// Maps TG number to last activity timestamp. Entries expire after
@@ -256,13 +256,13 @@ class TrunkLink : public sigc::trackable
void onFrameReceived(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data);
void handleMsgTrunkHello(std::istream& is, bool is_inbound);
void handleMsgTrunkTalkerStart(std::istream& is);
void handleMsgTrunkTalkerStop(std::istream& is);
void handleMsgTrunkAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void);
void handleMsgTrunkNodeList(std::istream& is);
void handleMsgPeerHello(std::istream& is, bool is_inbound);
void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgPeerAudio(std::istream& is);
void handleMsgPeerFlush(std::istream& is);
void handleMsgPeerHeartbeat(void);
void handleMsgPeerNodeList(std::istream& is);
void sendMsg(const ReflectorMsg& msg);
void sendMsgOnOutbound(const ReflectorMsg& msg);
+59 -59
View File
@@ -242,7 +242,7 @@ bool TwinLink::initialize(void)
void TwinLink::acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello)
const MsgPeerHello& hello)
{
if (m_inbound_con != nullptr)
{
@@ -294,9 +294,9 @@ void TwinLink::acceptInboundConnection(Async::FramedTcpConnection* con,
"' priority=", m_peer_priority);
// Send our hello back on the inbound connection
sendMsgOnInbound(MsgTrunkHello(m_peer_id_config, m_local_prefix,
sendMsgOnInbound(MsgPeerHello(m_peer_id_config, m_local_prefix,
m_priority, m_secret,
MsgTrunkHello::ROLE_TWIN));
MsgPeerHello::ROLE_TWIN));
} /* TwinLink::acceptInboundConnection */
@@ -306,11 +306,11 @@ void TwinLink::onLocalTalkerUpdated(uint32_t tg,
if (!isActive()) return;
if (callsign.empty())
{
sendMsg(MsgTrunkTalkerStop(tg));
sendMsg(MsgPeerTalkerStop(tg));
}
else
{
sendMsg(MsgTrunkTalkerStart(tg, callsign));
sendMsg(MsgPeerTalkerStart(tg, callsign));
}
} /* TwinLink::onLocalTalkerUpdated */
@@ -319,14 +319,14 @@ void TwinLink::onLocalAudio(uint32_t tg,
const std::vector<uint8_t>& audio)
{
if (!isActive()) return;
sendMsg(MsgTrunkAudio(tg, audio));
sendMsg(MsgPeerAudio(tg, audio));
} /* TwinLink::onLocalAudio */
void TwinLink::onLocalFlush(uint32_t tg)
{
if (!isActive()) return;
sendMsg(MsgTrunkFlush(tg));
sendMsg(MsgPeerFlush(tg));
} /* TwinLink::onLocalFlush */
@@ -348,10 +348,10 @@ void TwinLink::onExternalTrunkTalkerStop(uint32_t tg,
void TwinLink::onLocalNodeListUpdated(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes)
const std::vector<MsgPeerNodeList::NodeEntry>& nodes)
{
if (!isActive()) return;
sendMsg(MsgTrunkNodeList(nodes));
sendMsg(MsgPeerNodeList(nodes));
} /* TwinLink::onLocalNodeListUpdated */
@@ -415,9 +415,9 @@ void TwinLink::onConnected(void)
m_ob_hb_rx_cnt = 0;
m_heartbeat_timer.setEnable(true);
sendMsgOnOutbound(MsgTrunkHello(m_peer_id_config, m_local_prefix,
sendMsgOnOutbound(MsgPeerHello(m_peer_id_config, m_local_prefix,
m_priority, m_secret,
MsgTrunkHello::ROLE_TWIN));
MsgPeerHello::ROLE_TWIN));
} /* TwinLink::onConnected */
@@ -461,8 +461,8 @@ void TwinLink::onFrameReceived(FramedTcpConnection* con,
// Only allow hello and heartbeat before hello exchange completes
if (!hello_done &&
header.type() != MsgTrunkHello::TYPE &&
header.type() != MsgTrunkHeartbeat::TYPE)
header.type() != MsgPeerHello::TYPE &&
header.type() != MsgPeerHeartbeat::TYPE)
{
geulog::warn("twin", "TWIN: Ignoring message type=", header.type(), " before hello");
return;
@@ -480,26 +480,26 @@ void TwinLink::onFrameReceived(FramedTcpConnection* con,
switch (header.type())
{
case MsgTrunkHello::TYPE:
handleMsgTrunkHello(ss, is_inbound);
case MsgPeerHello::TYPE:
handleMsgPeerHello(ss, is_inbound);
break;
case MsgTrunkHeartbeat::TYPE:
handleMsgTrunkHeartbeat();
case MsgPeerHeartbeat::TYPE:
handleMsgPeerHeartbeat();
break;
case MsgTrunkTalkerStart::TYPE:
handleMsgTrunkTalkerStart(ss);
case MsgPeerTalkerStart::TYPE:
handleMsgPeerTalkerStart(ss);
break;
case MsgTrunkTalkerStop::TYPE:
handleMsgTrunkTalkerStop(ss);
case MsgPeerTalkerStop::TYPE:
handleMsgPeerTalkerStop(ss);
break;
case MsgTrunkAudio::TYPE:
handleMsgTrunkAudio(ss);
case MsgPeerAudio::TYPE:
handleMsgPeerAudio(ss);
break;
case MsgTrunkFlush::TYPE:
handleMsgTrunkFlush(ss);
case MsgPeerFlush::TYPE:
handleMsgPeerFlush(ss);
break;
case MsgTrunkNodeList::TYPE:
handleMsgTrunkNodeList(ss);
case MsgPeerNodeList::TYPE:
handleMsgPeerNodeList(ss);
break;
case MsgTwinExtTalkerStart::TYPE:
handleMsgTwinExtTalkerStart(ss);
@@ -514,7 +514,7 @@ void TwinLink::onFrameReceived(FramedTcpConnection* con,
} /* TwinLink::onFrameReceived */
void TwinLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
void TwinLink::handleMsgPeerHello(std::istream& is, bool is_inbound)
{
// Inbound hellos are already handled by acceptInboundConnection.
// A duplicate arriving here means the peer re-sent — ignore it silently.
@@ -524,14 +524,14 @@ void TwinLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
}
// Hello on outbound = peer's reply to our outbound hello
MsgTrunkHello msg;
MsgPeerHello msg;
if (!msg.unpack(is))
{
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkHello");
geulog::error("twin", "TWIN: Failed to unpack MsgPeerHello");
return;
}
if (msg.role() != MsgTrunkHello::ROLE_TWIN)
if (msg.role() != MsgPeerHello::ROLE_TWIN)
{
geulog::error("twin", "TWIN: peer sent role=", int(msg.role()),
" but we expect ROLE_TWIN");
@@ -563,70 +563,70 @@ void TwinLink::handleMsgTrunkHello(std::istream& is, bool is_inbound)
geulog::info("twin", "TWIN: hello from partner '", msg.id(),
"' priority=", m_peer_priority, " (authenticated)");
} /* TwinLink::handleMsgTrunkHello */
} /* TwinLink::handleMsgPeerHello */
void TwinLink::handleMsgTrunkTalkerStart(std::istream& is)
void TwinLink::handleMsgPeerTalkerStart(std::istream& is)
{
MsgTrunkTalkerStart msg;
MsgPeerTalkerStart msg;
if (!msg.unpack(is))
{
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkTalkerStart");
geulog::error("twin", "TWIN: Failed to unpack MsgPeerTalkerStart");
return;
}
// setTrunkTalkerForTG fires trunkTalkerUpdated → onTrunkTalkerUpdated in
// Reflector, which broadcasts MsgTalkerStart to all local clients on this TG.
TGHandler::instance()->setTrunkTalkerForTG(msg.tg(), msg.callsign());
} /* TwinLink::handleMsgTrunkTalkerStart */
} /* TwinLink::handleMsgPeerTalkerStart */
void TwinLink::handleMsgTrunkTalkerStop(std::istream& is)
void TwinLink::handleMsgPeerTalkerStop(std::istream& is)
{
MsgTrunkTalkerStop msg;
MsgPeerTalkerStop msg;
if (!msg.unpack(is))
{
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkTalkerStop");
geulog::error("twin", "TWIN: Failed to unpack MsgPeerTalkerStop");
return;
}
// clearTrunkTalkerForTG fires trunkTalkerUpdated → onTrunkTalkerUpdated,
// which broadcasts MsgTalkerStop and MsgUdpFlushSamples to local clients.
TGHandler::instance()->clearTrunkTalkerForTG(msg.tg());
} /* TwinLink::handleMsgTrunkTalkerStop */
} /* TwinLink::handleMsgPeerTalkerStop */
void TwinLink::handleMsgTrunkAudio(std::istream& is)
void TwinLink::handleMsgPeerAudio(std::istream& is)
{
MsgTrunkAudio msg;
MsgPeerAudio msg;
if (!msg.unpack(is))
{
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkAudio");
geulog::error("twin", "TWIN: Failed to unpack MsgPeerAudio");
return;
}
if (msg.audio().empty()) return;
MsgUdpAudio udp_msg(msg.audio());
m_reflector->broadcastUdpMsg(udp_msg, ReflectorClient::TgFilter(msg.tg()));
m_reflector->forwardAudioToSatellitesExcept(nullptr, msg.tg(), msg.audio());
} /* TwinLink::handleMsgTrunkAudio */
} /* TwinLink::handleMsgPeerAudio */
void TwinLink::handleMsgTrunkFlush(std::istream& is)
void TwinLink::handleMsgPeerFlush(std::istream& is)
{
MsgTrunkFlush msg;
MsgPeerFlush msg;
if (!msg.unpack(is))
{
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkFlush");
geulog::error("twin", "TWIN: Failed to unpack MsgPeerFlush");
return;
}
m_reflector->broadcastUdpMsg(MsgUdpFlushSamples(),
ReflectorClient::TgFilter(msg.tg()));
m_reflector->forwardFlushToSatellitesExcept(nullptr, msg.tg());
} /* TwinLink::handleMsgTrunkFlush */
} /* TwinLink::handleMsgPeerFlush */
void TwinLink::handleMsgTrunkHeartbeat(void)
void TwinLink::handleMsgPeerHeartbeat(void)
{
// RX counter already reset in onFrameReceived
} /* TwinLink::handleMsgTrunkHeartbeat */
} /* TwinLink::handleMsgPeerHeartbeat */
void TwinLink::handleMsgTwinExtTalkerStart(std::istream& is)
@@ -660,21 +660,21 @@ void TwinLink::handleMsgTwinExtTalkerStop(std::istream& is)
} /* TwinLink::handleMsgTwinExtTalkerStop */
void TwinLink::handleMsgTrunkNodeList(std::istream& is)
void TwinLink::handleMsgPeerNodeList(std::istream& is)
{
MsgTrunkNodeList msg;
MsgPeerNodeList msg;
if (!msg.unpack(is))
{
geulog::error("twin", "TWIN: Failed to unpack MsgTrunkNodeList");
geulog::error("twin", "TWIN: Failed to unpack MsgPeerNodeList");
return;
}
std::vector<MsgTrunkNodeList::NodeEntry> sanitized;
std::vector<MsgPeerNodeList::NodeEntry> sanitized;
sanitized.reserve(msg.nodes().size());
unsigned dropped = 0;
for (const auto& n : msg.nodes())
{
MsgTrunkNodeList::NodeEntry e;
MsgPeerNodeList::NodeEntry e;
e.callsign = sanitizeIdent(n.callsign, 32);
if (e.callsign.empty())
{
@@ -705,7 +705,7 @@ void TwinLink::handleMsgTrunkNodeList(std::istream& is)
// the twin's peer_id. Keeps /status, MQTT and Redis consistent.
m_reflector->onPeerNodeList(peerId(), sanitized);
m_partner_nodes = std::move(sanitized);
} /* TwinLink::handleMsgTrunkNodeList */
} /* TwinLink::handleMsgPeerNodeList */
void TwinLink::clearPartnerRosterIfInactive(void)
@@ -717,7 +717,7 @@ void TwinLink::clearPartnerRosterIfInactive(void)
// clearPeerNode each callsign previously cached under peerId() in
// Redis and publish an empty list to MQTT.
m_reflector->onPeerNodeList(peerId(),
std::vector<MsgTrunkNodeList::NodeEntry>{});
std::vector<MsgPeerNodeList::NodeEntry>{});
} /* TwinLink::clearPartnerRosterIfInactive */
@@ -728,7 +728,7 @@ void TwinLink::heartbeatTick(Async::Timer* /*t*/)
{
if (++m_ob_hb_tx_cnt >= TWIN_HB_TX_THRESHOLD)
{
sendMsgOnOutbound(MsgTrunkHeartbeat());
sendMsgOnOutbound(MsgPeerHeartbeat());
m_ob_hb_tx_cnt = 0;
}
if (++m_ob_hb_rx_cnt >= TWIN_HB_RX_THRESHOLD)
@@ -744,7 +744,7 @@ void TwinLink::heartbeatTick(Async::Timer* /*t*/)
{
if (++m_ib_hb_tx_cnt >= TWIN_HB_TX_THRESHOLD)
{
sendMsgOnInbound(MsgTrunkHeartbeat());
sendMsgOnInbound(MsgPeerHeartbeat());
m_ib_hb_tx_cnt = 0;
}
if (++m_ib_hb_rx_cnt >= TWIN_HB_RX_THRESHOLD)
+10 -10
View File
@@ -86,7 +86,7 @@ class TwinLink
// Inbound path: the twin server accepted a connection and the hello
// HMAC verified — hand it off here.
void acceptInboundConnection(Async::FramedTcpConnection* con,
const MsgTrunkHello& hello);
const MsgPeerHello& hello);
// Called by Reflector when local TGHandler state changes
void onLocalTalkerUpdated(uint32_t tg, const std::string& callsign);
@@ -104,7 +104,7 @@ class TwinLink
// Called by Reflector when the local node roster changes, to mirror
// our connected-stations list to the twin partner.
void onLocalNodeListUpdated(
const std::vector<MsgTrunkNodeList::NodeEntry>& nodes);
const std::vector<MsgPeerNodeList::NodeEntry>& nodes);
bool isActive(void) const;
const std::string& partnerHost(void) const { return m_peer_host; }
@@ -145,7 +145,7 @@ class TwinLink
bool m_ib_hello_received;
unsigned m_ib_hb_tx_cnt;
unsigned m_ib_hb_rx_cnt;
std::vector<MsgTrunkNodeList::NodeEntry> m_partner_nodes;
std::vector<MsgPeerNodeList::NodeEntry> m_partner_nodes;
// No copy
TwinLink(const TwinLink&);
@@ -156,13 +156,13 @@ class TwinLink
Async::TcpConnection::DisconnectReason reason);
void onFrameReceived(Async::FramedTcpConnection* con,
std::vector<uint8_t>& data);
void handleMsgTrunkHello(std::istream& is, bool is_inbound);
void handleMsgTrunkTalkerStart(std::istream& is);
void handleMsgTrunkTalkerStop(std::istream& is);
void handleMsgTrunkAudio(std::istream& is);
void handleMsgTrunkFlush(std::istream& is);
void handleMsgTrunkHeartbeat(void);
void handleMsgTrunkNodeList(std::istream& is);
void handleMsgPeerHello(std::istream& is, bool is_inbound);
void handleMsgPeerTalkerStart(std::istream& is);
void handleMsgPeerTalkerStop(std::istream& is);
void handleMsgPeerAudio(std::istream& is);
void handleMsgPeerFlush(std::istream& is);
void handleMsgPeerHeartbeat(void);
void handleMsgPeerNodeList(std::istream& is);
void clearPartnerRosterIfInactive(void);
void handleMsgTwinExtTalkerStart(std::istream& is);
void handleMsgTwinExtTalkerStop(std::istream& is);
+1 -1
View File
@@ -178,7 +178,7 @@ CERT_CA_HOOK=@SVX_SHARE_INSTALL_DIR@/ca-hook.py
# Optional TG filter — restricts which TGs this satellite cares about.
# Applied in both directions: the satellite skips sending local events for
# non-matching TGs, and advertises the filter to the parent via
# MsgTrunkFilter (type 122) so the parent skips forwarding them back.
# MsgPeerFilter (type 122) so the parent skips forwarding them back.
# Syntax: exact "26200", prefix "24*", range "2427-2438", comma-separated.
# Empty or absent = no filtering (all TGs pass in both directions).
#SATELLITE_FILTER=24*,262*