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:
1 parent
3d281e16d7
commit
18d92a2b11
17 files changed
+424
-422
No files matched your search
@@ -521,7 +521,7 @@ The PTY path is set by `COMMAND_PTY` in `[GLOBAL]` (default
|
||||
as a drop-in replacement for an existing SvxReflector installation
|
||||
- [`docs/DOCKER.md`](docs/DOCKER.md) — running GeuReflector in a Docker container
|
||||
as a drop-in replacement for an existing SvxReflector installation
|
||||
- [`docs/TRUNK_PROTOCOL.md`](docs/TRUNK_PROTOCOL.md) — full wire protocol
|
||||
- [`docs/PEER_PROTOCOL.md`](docs/PEER_PROTOCOL.md) — full wire protocol
|
||||
specification: message format, handshake sequence, talker arbitration
|
||||
tie-breaking, heartbeat, and the complete message type table
|
||||
- [`docs/DEPLOYMENT_ITALY.md`](docs/DEPLOYMENT_ITALY.md) — complete national
|
||||
|
||||
+1
-1
@@ -241,6 +241,6 @@ the `LOCAL_PREFIX` and `[TRUNK_x]` entries.
|
||||
|
||||
## Further reading
|
||||
|
||||
- [`docs/TRUNK_PROTOCOL.md`](TRUNK_PROTOCOL.md) — wire protocol specification
|
||||
- [`docs/PEER_PROTOCOL.md`](PEER_PROTOCOL.md) — wire protocol specification
|
||||
- [`docs/DEPLOYMENT_ITALY.md`](DEPLOYMENT_ITALY.md) — full national deployment
|
||||
example with configuration for all regions
|
||||
@@ -1,4 +1,6 @@
|
||||
# GeuReflector — Server-to-Server Trunk Protocol
|
||||
# GeuReflector — Server-to-Server Peer Protocol
|
||||
|
||||
> **Renamed in 2026-04 (wire-format unchanged).** Message types were previously called `MsgTrunk*`; they are now `MsgPeer*`. Wire IDs (115-122) and field layouts are identical — a renamed reflector and an old reflector interoperate identically.
|
||||
|
||||
## Overview
|
||||
|
||||
@@ -18,7 +20,7 @@ authoritative home reflector (the one whose prefix matches); all other
|
||||
reflectors are transparent proxies for that TG.
|
||||
|
||||
> **Important:** Both reflectors in a trunk link **must use the same `[TRUNK_x]`
|
||||
> section name**. The section name is transmitted in the `MsgTrunkHello`
|
||||
> section name**. The section name is transmitted in the `MsgPeerHello`
|
||||
> handshake and both sides must agree on it for the connection to be matched to
|
||||
> the correct `TrunkLink` instance. The convention is to use sorted pair
|
||||
> identifiers — for example, the link between reflector 1 and reflector 2 uses
|
||||
@@ -104,8 +106,8 @@ reflectors, the owner is also the only reflector that sees every non-owner's
|
||||
traffic on that TG — so for every non-owner to hear every other, the owner
|
||||
must fan out.
|
||||
|
||||
When `TrunkLink::handleMsgTrunkTalkerStart` / `handleMsgTrunkTalkerStop` /
|
||||
`handleMsgTrunkAudio` / `handleMsgTrunkFlush` runs on the reflector that
|
||||
When `TrunkLink::handleMsgPeerTalkerStart` / `handleMsgPeerTalkerStop` /
|
||||
`handleMsgPeerAudio` / `handleMsgPeerFlush` runs on the reflector that
|
||||
**owns** the TG (`Reflector::isLocalTG(tg)`), after the existing local
|
||||
delivery the event is re-forwarded to every **other** trunk peer through the
|
||||
same per-link filter (`isSharedTG` / `isClusterTG` / `isPeerInterestedTG`).
|
||||
@@ -179,8 +181,8 @@ using different prefix checks appropriate to each direction:
|
||||
to the peer. Additionally, `isPeerInterestedTG` matches TGs that the
|
||||
peer has previously sent traffic for, enabling the return path for
|
||||
bidirectional conversations (see below).
|
||||
- **Receiving side:** `TrunkLink::handleMsgTrunkTalkerStart`,
|
||||
`handleMsgTrunkAudio`, and `handleMsgTrunkFlush` check
|
||||
- **Receiving side:** `TrunkLink::handleMsgPeerTalkerStart`,
|
||||
`handleMsgPeerAudio`, and `handleMsgPeerFlush` check
|
||||
`isOwnedTG(tg) || isClusterTG(tg)` before accepting. `isOwnedTG` matches
|
||||
the TG against both the **local** prefix (TG belongs to us — a peer's client
|
||||
is talking on one of our TGs) and the **remote** prefix (TG belongs to the
|
||||
@@ -201,11 +203,11 @@ forward to B. But when B's client replies on that same TG, B sees it as a
|
||||
local TG and has no reason to forward back to A.
|
||||
|
||||
To enable the return path, each `TrunkLink` tracks **peer interest**: when
|
||||
a peer sends `MsgTrunkTalkerStart(tg)`, the receiving side records that the
|
||||
a peer sends `MsgPeerTalkerStart(tg)`, the receiving side records that the
|
||||
peer has active clients on that TG. From that point, local talker activity
|
||||
on the same TG is also forwarded to the peer via `isPeerInterestedTG`.
|
||||
|
||||
Interest is refreshed on each `MsgTrunkAudio` received for the TG (keeping
|
||||
Interest is refreshed on each `MsgPeerAudio` received for the TG (keeping
|
||||
it alive during long transmissions). It expires after 10 minutes of
|
||||
inactivity on that TG from the peer, and is cleared immediately on trunk
|
||||
disconnect. The interest map is per-link — disconnecting one peer does not
|
||||
@@ -237,16 +239,16 @@ not ready, the inbound connection is used as fallback.
|
||||
### Outbound connection
|
||||
|
||||
When a `TrunkLink` connects outbound to a peer, it immediately sends
|
||||
`MsgTrunkHello`. The peer's trunk server accepts the connection, verifies the
|
||||
`MsgPeerHello`. The peer's trunk server accepts the connection, verifies the
|
||||
HMAC-authenticated shared secret, matches it to the corresponding `TrunkLink`,
|
||||
and sends its own `MsgTrunkHello` in response.
|
||||
and sends its own `MsgPeerHello` in response.
|
||||
|
||||
```
|
||||
Reflector A (prefix "1") Reflector B (prefix "2")
|
||||
│──── TCP connect to B:5302 ──────────────────────────►│
|
||||
│──── MsgTrunkHello(id, prefix="1", priority, HMAC) ──►│
|
||||
│──── MsgPeerHello(id, prefix="1", priority, HMAC) ──►│
|
||||
│ B verifies HMAC, matches TrunkLink
|
||||
│◀─── MsgTrunkHello(id, prefix="2", priority, HMAC) ───│
|
||||
│◀─── MsgPeerHello(id, prefix="2", priority, HMAC) ───│
|
||||
│ (both sides ready) │
|
||||
```
|
||||
|
||||
@@ -256,7 +258,7 @@ The trunk server (`Reflector::m_trunk_srv`) listens on the configured
|
||||
`TRUNK_LISTEN_PORT` (default 5302). When a peer connects:
|
||||
|
||||
1. The connection enters a **pending** state with a 10-second hello timeout
|
||||
2. The server waits for a `MsgTrunkHello` frame
|
||||
2. The server waits for a `MsgPeerHello` frame
|
||||
3. The shared secret is verified via HMAC against each configured `TrunkLink`
|
||||
4. On match, the connection is handed off to the corresponding `TrunkLink`
|
||||
5. The `TrunkLink` stores the inbound connection alongside any existing
|
||||
@@ -282,7 +284,7 @@ If a second inbound connection arrives while one is already active, the new one
|
||||
is rejected. Outbound reconnection is handled automatically by
|
||||
`TcpPrioClient`.
|
||||
|
||||
### `MsgTrunkHello` fields
|
||||
### `MsgPeerHello` fields
|
||||
|
||||
- `id` — the config section name (e.g. `TRUNK_1_2`), used for logging and
|
||||
connection matching — both sides must use the same section name
|
||||
@@ -301,15 +303,15 @@ When a local client starts transmitting on a TG owned by the peer:
|
||||
Reflector A (owns prefix "1") Reflector B (owns prefix "2")
|
||||
│ SM0ABC starts on TG 25 │
|
||||
│ setTalkerForTG(25, SM0ABC) │
|
||||
│──── MsgTrunkTalkerStart(25, "SM0ABC") ──►│
|
||||
│──── MsgPeerTalkerStart(25, "SM0ABC") ──►│
|
||||
│ setTrunkTalkerForTG(25, "SM0ABC")
|
||||
│ broadcast MsgTalkerStart(25, "SM0ABC") to B clients
|
||||
│──── MsgTrunkAudio(25, <frame>) ─►│
|
||||
│──── MsgPeerAudio(25, <frame>) ─►│
|
||||
│ broadcast MsgUdpAudio to B TG25 clients
|
||||
│ (repeats for each audio frame) │
|
||||
│──── MsgTrunkFlush(25) ──────────►│
|
||||
│──── MsgPeerFlush(25) ──────────►│
|
||||
│ setTalkerForTG(25, null) │
|
||||
│──── MsgTrunkTalkerStop(25) ─────►│
|
||||
│──── MsgPeerTalkerStop(25) ─────►│
|
||||
│ clearTrunkTalkerForTG(25)
|
||||
│ broadcast MsgTalkerStop(25, "SM0ABC") to B clients
|
||||
│ broadcast MsgUdpFlushSamples to B TG25 clients
|
||||
@@ -324,19 +326,19 @@ The reverse direction (B client talking on a TG owned by A) is symmetric.
|
||||
Each reflector arbitrates talkers independently for its own clients. The trunk
|
||||
adds a second layer of arbitration for shared TGs.
|
||||
|
||||
**Normal case (one side talking at a time):** the first `MsgTrunkTalkerStart`
|
||||
**Normal case (one side talking at a time):** the first `MsgPeerTalkerStart`
|
||||
to arrive locks the TG on the receiving side. Local clients on that side cannot
|
||||
grab the talker slot while the trunk lock is held — their audio packets are
|
||||
silently dropped by the existing `talker != client` check in the reflector's
|
||||
UDP handler.
|
||||
|
||||
**Simultaneous claim (both sides start at the same instant):** resolved using
|
||||
the `priority` nonce exchanged in `MsgTrunkHello`:
|
||||
the `priority` nonce exchanged in `MsgPeerHello`:
|
||||
|
||||
- The side with the **lower** priority value wins
|
||||
- The losing side calls `setTalkerForTG(tg, nullptr)` to clear its local talker,
|
||||
then calls `setTrunkTalkerForTG(tg, peer_callsign)` to accept the remote claim
|
||||
- The losing side suppresses the spurious `MsgTrunkTalkerStop` that would
|
||||
- The losing side suppresses the spurious `MsgPeerTalkerStop` that would
|
||||
otherwise be sent when the local talker is cleared (tracked via `m_yielded_tgs`)
|
||||
|
||||
---
|
||||
@@ -362,7 +364,7 @@ interruption by local clients.
|
||||
|
||||
## Keepalive / Heartbeat
|
||||
|
||||
Both sides send `MsgTrunkHeartbeat` periodically to keep the TCP connection
|
||||
Both sides send `MsgPeerHeartbeat` periodically to keep the TCP connection
|
||||
alive and detect peer disconnection:
|
||||
|
||||
- TX: sent when no other message has been sent for 10 timer ticks (10 s)
|
||||
@@ -382,14 +384,14 @@ payload, packed using the `ASYNC_MSG_MEMBERS` macro.
|
||||
|
||||
| Type | Name | Fields |
|
||||
|------|-----------------------|--------------------------------------------------|
|
||||
| 115 | `MsgTrunkHello` | `string id`, `string local_prefix`, `uint32 priority`, `uint8[] nonce`, `uint8[] hmac`, `uint8 role` |
|
||||
| 116 | `MsgTrunkTalkerStart` | `uint32 tg`, `string callsign` |
|
||||
| 117 | `MsgTrunkTalkerStop` | `uint32 tg` |
|
||||
| 118 | `MsgTrunkAudio` | `uint32 tg`, `uint8[] audio` |
|
||||
| 119 | `MsgTrunkFlush` | `uint32 tg` |
|
||||
| 120 | `MsgTrunkHeartbeat` | *(no fields)* |
|
||||
| 121 | `MsgTrunkNodeList` | `string[] callsigns`, `uint32[] tgs`, `float[] lats`, `float[] lons`, `string[] qth_names`, `string[] status_blobs`, `string[] sat_ids` |
|
||||
| 122 | `MsgTrunkFilter` | `string filter` (shared-syntax TG filter: exact / `24*` / `10-20`, comma-separated) |
|
||||
| 115 | `MsgPeerHello` | `string id`, `string local_prefix`, `uint32 priority`, `uint8[] nonce`, `uint8[] hmac`, `uint8 role` |
|
||||
| 116 | `MsgPeerTalkerStart` | `uint32 tg`, `string callsign` |
|
||||
| 117 | `MsgPeerTalkerStop` | `uint32 tg` |
|
||||
| 118 | `MsgPeerAudio` | `uint32 tg`, `uint8[] audio` |
|
||||
| 119 | `MsgPeerFlush` | `uint32 tg` |
|
||||
| 120 | `MsgPeerHeartbeat` | *(no fields)* |
|
||||
| 121 | `MsgPeerNodeList` | `string[] callsigns`, `uint32[] tgs`, `float[] lats`, `float[] lons`, `string[] qth_names`, `string[] status_blobs`, `string[] sat_ids` |
|
||||
| 122 | `MsgPeerFilter` | `string filter` (shared-syntax TG filter: exact / `24*` / `10-20`, comma-separated) |
|
||||
|
||||
Type numbers 115–120 are chosen to follow the last existing SvxReflector TCP
|
||||
message type (114 = `MsgStartUdpEncryption`) without collision. Types 121–122
|
||||
@@ -397,7 +399,7 @@ were added by the jayReflector integration (v1.1.0) and are optional —
|
||||
older peers silently ignore unknown message types, preserving backward
|
||||
compatibility.
|
||||
|
||||
`MsgTrunkNodeList` is emitted by the reflector on local client login, logout,
|
||||
`MsgPeerNodeList` is emitted by the reflector on local client login, logout,
|
||||
or TG change, debounced to 500 ms, and broadcast to every trunk peer. Peers
|
||||
republish it via MQTT under `nodes/<peer_id>` so a central dashboard can see
|
||||
who is connected to each reflector.
|
||||
@@ -411,8 +413,8 @@ under `/status.trunks[<section>].nodes[i]`, MQTT `nodes/<peer_id>`, and
|
||||
the `status` field of Redis hash `live:peer_node:<peer_id>:<callsign>`.
|
||||
The `isTalker` flag on each peer node is **not** carried in the blob (it
|
||||
would be stale by the time it arrives); it is derived on the receive side
|
||||
from the live trunk-talker map maintained by `MsgTrunkTalkerStart` /
|
||||
`MsgTrunkTalkerStop`.
|
||||
from the live trunk-talker map maintained by `MsgPeerTalkerStart` /
|
||||
`MsgPeerTalkerStop`.
|
||||
|
||||
The optional `sat_ids[i]` field tags each entry with the satellite that
|
||||
the client is actually attached to. Interpretation is **recipient-relative**:
|
||||
@@ -456,8 +458,8 @@ physically lives. Re-broadcasts are debounced (500 ms) and triggered by:
|
||||
local client login/logout/TG change, satellite hello completion, and
|
||||
inbound satellite node-list updates.
|
||||
|
||||
`MsgTrunkFilter` is used by satellite links to advertise TG interest to the
|
||||
parent. A satellite with `SATELLITE_FILTER` set sends one `MsgTrunkFilter`
|
||||
`MsgPeerFilter` is used by satellite links to advertise TG interest to the
|
||||
parent. A satellite with `SATELLITE_FILTER` set sends one `MsgPeerFilter`
|
||||
right after authenticating; the parent stores the filter and skips forwarding
|
||||
non-matching TGs to that satellite. Absent or empty filter means pass-all
|
||||
(pre-existing behavior). Trunk peers do not emit it.
|
||||
@@ -596,7 +598,7 @@ REMOTE_PREFIX=2
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/svxlink/reflector/ReflectorMsg.h` | Added `MsgTrunkHello`–`MsgTrunkHeartbeat` (types 115–120); `MsgTrunkHello` carries `local_prefix` string instead of TG list |
|
||||
| `src/svxlink/reflector/ReflectorMsg.h` | Added `MsgPeerHello`–`MsgPeerHeartbeat` (types 115–120); `MsgPeerHello` carries `local_prefix` string instead of TG list |
|
||||
| `src/svxlink/reflector/TGHandler.h` | Added trunk talker map, 5 methods + snapshot accessor, `trunkTalkerUpdated` signal |
|
||||
| `src/svxlink/reflector/TGHandler.cpp` | Implemented trunk talker methods including `clearAllTrunkTalkers` |
|
||||
| `src/svxlink/reflector/Reflector.h` | Added `m_trunk_links`, `m_trunk_srv`, `initTrunkLinks()`, `initTrunkServer()`, `onTrunkTalkerUpdated()`, trunk inbound connection handling |
|
||||
@@ -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"] = "";
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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>
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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*
|
||||
|
||||
Reference in new issue
Block a user