change dg-id mapping and fix gatekeeper bypass

This commit is contained in:
narspt 2021-10-10 02:10:31 +01:00 committed by GitHub
parent 32c9e0ce8f
commit e752b76376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 19 deletions

View File

@ -132,19 +132,6 @@ void CYsfProtocol::Task(void)
//std::cout << "YSF DV header:" << std::endl << *Header << std::endl;
//std::cout << "YSF DV header:" << std::endl;
// handle changing linked module by DG-ID
if ( (Fich.getSQ() >= 1) && (Fich.getSQ() <= NB_OF_MODULES) ) {
char cModule = 'A' + (char)(Fich.getSQ() - 1);
CClient *client = g_Reflector.GetClients()->FindClient(Ip, PROTOCOL_YSF);
if ( client != NULL ) {
if ( client->GetReflectorModule() != cModule ) {
std::cout << "YSF client " << client->GetCallsign() << " linking by DG-ID on module " << cModule << std::endl;
client->SetReflectorModule(cModule);
}
}
g_Reflector.ReleaseClients();
}
// node linked and callsign muted?
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_YSF, Header->GetRpt2Module()) )
{
@ -266,8 +253,17 @@ bool CYsfProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
{
// get client callsign
via = client->GetCallsign();
// get module it's linked to
Header->SetRpt2Module(client->GetReflectorModule());
if ( Header->GetRpt2Module() == ' ' ) {
// module not filled, get module it's linked to
Header->SetRpt2Module(client->GetReflectorModule());
} else {
// handle changing linked module to the one set on rpt2
if ( client->GetReflectorModule() != Header->GetRpt2Module() ) {
std::cout << "YSF client " << client->GetCallsign() << " linking on module " << Header->GetRpt2Module() << std::endl;
client->SetReflectorModule(Header->GetRpt2Module());
}
}
// and try to open the stream
if ( (stream = g_Reflector.OpenStream(Header, client)) != NULL )
@ -479,10 +475,16 @@ bool CYsfProtocol::IsValidDvHeaderPacket(const CIp &Ip, const CYSFFICH &Fich, co
CCallsign rpt1 = CCallsign((const char *)sz);
rpt1.SetModule(YSF_MODULE_ID);
CCallsign rpt2 = m_ReflectorCallsign;
// as YSF protocol does not provide a module-tranlatable
// destid, set module to none and rely on OnDvHeaderPacketIn()
// to later fill it with proper value
rpt2.SetModule(' ');
if ( (Fich.getSQ() >= 10) && (Fich.getSQ() < 10+NB_OF_MODULES) ) {
// set module based on DG-ID value
rpt2.SetModule( 'A' + (char)(Fich.getSQ() - 10) );
} else {
// as YSF protocol does not provide a module-tranlatable
// destid, set module to none and rely on OnDvHeaderPacketIn()
// to later fill it with proper value
rpt2.SetModule(' ');
}
// and packet
*header = new CDvHeaderPacket(csMY, CCallsign("CQCQCQ"), rpt1, rpt2, uiStreamId, Fich.getFN());