Fix trunk receive-side TG filtering and add integration test suite
The receive-side handlers (handleMsgTrunkTalkerStart, handleMsgTrunkAudio, etc.) used isSharedTG() which only checks the remote peer's prefix. This caused non-cluster TGs to be silently dropped on the receiving reflector — e.g. a client on reflector-a talking on TG 40001 (owned by reflector-b) would never reach reflector-b because reflector-b checked the TG against reflector-a's prefix instead of its own. Add isOwnedTG() that accepts TGs matching either the local or remote prefix, and use it in all four receive handlers. The send-side still uses isSharedTG() (remote prefix only) which is correct. Also add a Docker-based integration test suite (tests/) with 11 automated tests covering handshake, routing, cross-reflector audio delivery, cluster TGs, heartbeat, disconnect cleanup, and trunk-to-trunk isolation. An interactive mode lets users test arbitrary TG numbers with routing verified via reflector logs. Topology is defined once in tests/topology.py. Fix Dockerfile to copy built shared libraries to the runtime image.
This commit is contained in:
1 parent
3b7831c307
commit
685d7253ff
12 files changed
+1501
-16
No files matched your search
@@ -230,6 +230,36 @@ bool TrunkLink::isSharedTG(uint32_t tg) const
|
||||
} /* TrunkLink::isSharedTG */
|
||||
|
||||
|
||||
bool TrunkLink::isOwnedTG(uint32_t tg) const
|
||||
{
|
||||
const std::string s = std::to_string(tg);
|
||||
|
||||
// Accept TGs matching our local prefix (TG belongs to us — a peer's
|
||||
// client is talking on one of our TGs)
|
||||
for (const auto& prefix : m_local_prefix)
|
||||
{
|
||||
if (s.size() >= prefix.size() &&
|
||||
s.compare(0, prefix.size(), prefix) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Accept TGs matching the remote prefix (TG belongs to the peer —
|
||||
// the peer is reporting its own talker state for our awareness)
|
||||
for (const auto& prefix : m_remote_prefix)
|
||||
{
|
||||
if (s.size() >= prefix.size() &&
|
||||
s.compare(0, prefix.size(), prefix) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
} /* TrunkLink::isOwnedTG */
|
||||
|
||||
|
||||
Json::Value TrunkLink::statusJson(void) const
|
||||
{
|
||||
Json::Value obj(Json::objectValue);
|
||||
@@ -540,7 +570,7 @@ void TrunkLink::handleMsgTrunkTalkerStart(std::istream& is)
|
||||
}
|
||||
|
||||
uint32_t tg = msg.tg();
|
||||
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||
if (!isOwnedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -584,7 +614,7 @@ void TrunkLink::handleMsgTrunkTalkerStop(std::istream& is)
|
||||
}
|
||||
|
||||
uint32_t tg = msg.tg();
|
||||
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||
if (!isOwnedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -606,7 +636,7 @@ void TrunkLink::handleMsgTrunkAudio(std::istream& is)
|
||||
}
|
||||
|
||||
uint32_t tg = msg.tg();
|
||||
if ((!isSharedTG(tg) && !m_reflector->isClusterTG(tg)) || msg.audio().empty())
|
||||
if ((!isOwnedTG(tg) && !m_reflector->isClusterTG(tg)) || msg.audio().empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -637,7 +667,7 @@ void TrunkLink::handleMsgTrunkFlush(std::istream& is)
|
||||
}
|
||||
|
||||
uint32_t tg = msg.tg();
|
||||
if (!isSharedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||
if (!isOwnedTG(tg) && !m_reflector->isClusterTG(tg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ class TrunkLink : public sigc::trackable
|
||||
bool isActive(void) const;
|
||||
bool isOutboundReady(void) const;
|
||||
bool isInboundReady(void) const;
|
||||
bool isOwnedTG(uint32_t tg) const;
|
||||
|
||||
void onConnected(void);
|
||||
void onDisconnected(Async::TcpConnection* con,
|
||||
|
||||
Reference in new issue
Block a user