mirror of https://github.com/ShaYmez/xlxd.git
version 1.3.9
This commit is contained in:
parent
4be0cb5fa4
commit
c0bab2822d
|
@ -209,7 +209,7 @@ bool CCallsign::HasSameCallsign(const CCallsign &Callsign) const
|
|||
return (::memcmp(m_Callsign, Callsign.m_Callsign, sizeof(m_Callsign)) == 0);
|
||||
}
|
||||
|
||||
bool CCallsign::HasSameCallsignWithWidlcard(const CCallsign &callsign) const
|
||||
bool CCallsign::HasSameCallsignWithWildcard(const CCallsign &callsign) const
|
||||
{
|
||||
bool same = true;
|
||||
bool done = false;
|
||||
|
|
|
@ -69,7 +69,7 @@ public:
|
|||
|
||||
// compare
|
||||
bool HasSameCallsign(const CCallsign &) const;
|
||||
bool HasSameCallsignWithWidlcard(const CCallsign &) const;
|
||||
bool HasSameCallsignWithWildcard(const CCallsign &) const;
|
||||
bool HasSameModule(const CCallsign &) const;
|
||||
|
||||
// operators
|
||||
|
|
|
@ -44,6 +44,7 @@ bool CCallsignList::LoadFromFile(const char *filename)
|
|||
{
|
||||
bool ok = false;
|
||||
char sz[256];
|
||||
char szStar[2] = "*";
|
||||
|
||||
// and load
|
||||
std::ifstream file (filename);
|
||||
|
@ -58,10 +59,24 @@ bool CCallsignList::LoadFromFile(const char *filename)
|
|||
{
|
||||
// remove leading & trailing spaces
|
||||
char *szt = TrimWhiteSpaces(sz);
|
||||
// and load if not comment
|
||||
|
||||
// crack it
|
||||
if ( (::strlen(szt) > 0) && (szt[0] != '#') )
|
||||
{
|
||||
push_back(CCallsignListItem(CCallsign(szt), CIp(), NULL));
|
||||
// 1st token is callsign
|
||||
if ( (szt = ::strtok(szt, " ,\t")) != NULL )
|
||||
{
|
||||
CCallsign callsign(szt);
|
||||
// 2nd token is modules list
|
||||
szt = ::strtok(NULL, " ,\t");
|
||||
// if token absent, use wildcard
|
||||
if ( szt == NULL )
|
||||
{
|
||||
szt = szStar;
|
||||
}
|
||||
// and add to list
|
||||
push_back(CCallsignListItem(callsign, CIp(), szt));
|
||||
}
|
||||
}
|
||||
}
|
||||
// close file
|
||||
|
@ -112,18 +127,33 @@ bool CCallsignList::NeedReload(void)
|
|||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// compare
|
||||
|
||||
bool CCallsignList::IsCallsignListed(const CCallsign &callsign) const
|
||||
bool CCallsignList::IsCallsignListedWithWildcard(const CCallsign &callsign) const
|
||||
{
|
||||
bool listed = false;
|
||||
|
||||
for ( int i = 0; (i < size()) && !listed; i++ )
|
||||
{
|
||||
listed = (data()[i]).HasSameCallsignWithWidlcard(callsign);
|
||||
listed = (data()[i]).HasSameCallsignWithWildcard(callsign);
|
||||
}
|
||||
|
||||
return listed;
|
||||
}
|
||||
|
||||
bool CCallsignList::IsCallsignListedWithWildcard(const CCallsign &callsign, char module) const
|
||||
{
|
||||
bool listed = false;
|
||||
|
||||
for ( int i = 0; (i < size()) && !listed; i++ )
|
||||
{
|
||||
const CCallsignListItem *item = &(data()[i]);
|
||||
listed = (item->HasSameCallsignWithWildcard(callsign) &&
|
||||
((module == ' ') || item->HasModuleListed(module)) );
|
||||
|
||||
}
|
||||
|
||||
return listed;
|
||||
}
|
||||
|
||||
bool CCallsignList::IsCallsignListed(const CCallsign &callsign, char module) const
|
||||
{
|
||||
bool listed = false;
|
||||
|
|
|
@ -51,7 +51,8 @@ public:
|
|||
bool NeedReload(void);
|
||||
|
||||
// compare
|
||||
bool IsCallsignListed(const CCallsign &) const;
|
||||
bool IsCallsignListedWithWildcard(const CCallsign &) const;
|
||||
bool IsCallsignListedWithWildcard(const CCallsign &, char) const;
|
||||
bool IsCallsignListed(const CCallsign &, char) const;
|
||||
bool IsCallsignListed(const CCallsign &, char*) const;
|
||||
|
||||
|
|
|
@ -43,7 +43,17 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const CIp &ip, c
|
|||
if ( modules != NULL )
|
||||
{
|
||||
:: memset(m_Modules, 0, sizeof(m_Modules));
|
||||
::memcpy(m_Modules, modules, MIN(strlen(modules), sizeof(m_Modules)-1));
|
||||
if ( modules[0] == '*' )
|
||||
{
|
||||
for ( char i = 0; i < NB_OF_MODULES; i++ )
|
||||
{
|
||||
m_Modules[i] = 'A' + i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::memcpy(m_Modules, modules, MIN(strlen(modules), sizeof(m_Modules)-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +65,17 @@ CCallsignListItem::CCallsignListItem(const CCallsign &callsign, const char *url,
|
|||
if ( modules != NULL )
|
||||
{
|
||||
:: memset(m_Modules, 0, sizeof(m_Modules));
|
||||
::memcpy(m_Modules, modules, MIN(strlen(modules), sizeof(m_Modules)-1));
|
||||
if ( modules[0] == '*' )
|
||||
{
|
||||
for ( char i = 0; i < NB_OF_MODULES; i++ )
|
||||
{
|
||||
m_Modules[i] = 'A' + i;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
::memcpy(m_Modules, modules, MIN(strlen(modules), sizeof(m_Modules)-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,9 +96,9 @@ bool CCallsignListItem::HasSameCallsign(const CCallsign &callsign) const
|
|||
return m_Callsign.HasSameCallsign(callsign);
|
||||
}
|
||||
|
||||
bool CCallsignListItem::HasSameCallsignWithWidlcard(const CCallsign &callsign) const
|
||||
bool CCallsignListItem::HasSameCallsignWithWildcard(const CCallsign &callsign) const
|
||||
{
|
||||
return m_Callsign.HasSameCallsignWithWidlcard(callsign);
|
||||
return m_Callsign.HasSameCallsignWithWildcard(callsign);
|
||||
}
|
||||
|
||||
bool CCallsignListItem::HasModuleListed(char module) const
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
|
||||
// compare
|
||||
bool HasSameCallsign(const CCallsign &) const;
|
||||
bool HasSameCallsignWithWidlcard(const CCallsign &) const;
|
||||
bool HasSameCallsignWithWildcard(const CCallsign &) const;
|
||||
bool HasModuleListed(char) const;
|
||||
bool CheckListedModules(char*) const;
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ void CDcsProtocol::Task(void)
|
|||
//std::cout << "DCS DV packet" << std::endl;
|
||||
|
||||
// callsign muted?
|
||||
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DCS) )
|
||||
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DCS, Header->GetRpt2Module()) )
|
||||
{
|
||||
// handle it
|
||||
if ( !OnDvHeaderPacketIn(Header, Ip) )
|
||||
|
|
|
@ -88,7 +88,7 @@ void CDextraProtocol::Task(void)
|
|||
//std::cout << "DExtra DV header:" << std::endl;
|
||||
|
||||
// callsign muted?
|
||||
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DEXTRA) )
|
||||
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DEXTRA, Header->GetRpt2Module()) )
|
||||
{
|
||||
// handle it
|
||||
OnDvHeaderPacketIn(Header, Ip);
|
||||
|
@ -363,7 +363,7 @@ bool CDextraProtocol::IsValidConnectPacket(const CBuffer &Buffer, CCallsign *cal
|
|||
{
|
||||
*revision = 1;
|
||||
}
|
||||
else if ( callsign->HasSameCallsignWithWidlcard(CCallsign("XRF*")) )
|
||||
else if ( callsign->HasSameCallsignWithWildcard(CCallsign("XRF*")) )
|
||||
{
|
||||
*revision = 2;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ void CDplusProtocol::Task(void)
|
|||
//std::cout << "DPlus DV header:" << std::endl << *Header << std::endl;
|
||||
|
||||
// callsign muted?
|
||||
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DPLUS) )
|
||||
if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, PROTOCOL_DPLUS, Header->GetRpt2Module()) )
|
||||
{
|
||||
// handle it
|
||||
OnDvHeaderPacketIn(Header, Ip);
|
||||
|
@ -225,7 +225,7 @@ bool CDplusProtocol::OnDvHeaderPacketIn(CDvHeaderPacket *Header, const CIp &Ip)
|
|||
if ( client != NULL )
|
||||
{
|
||||
// now we know if it's a dextra dongle or a genuine dplus node
|
||||
if ( Header->GetRpt2Callsign().HasSameCallsignWithWidlcard(CCallsign("XRF*")) )
|
||||
if ( Header->GetRpt2Callsign().HasSameCallsignWithWildcard(CCallsign("XRF*")) )
|
||||
{
|
||||
client->SetDextraDongle();
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ bool CGateKeeper::MayTransmit(const CCallsign &callsign, const CIp &ip, int prot
|
|||
case PROTOCOL_DPLUS:
|
||||
case PROTOCOL_DCS:
|
||||
// first check is IP & callsigned listed OK
|
||||
ok &= IsNodeListedOk(callsign, ip);
|
||||
ok &= IsNodeListedOk(callsign, ip, module);
|
||||
// todo: then apply any protocol specific authorisation for the operation
|
||||
break;
|
||||
|
||||
|
@ -193,7 +193,7 @@ void CGateKeeper::Thread(CGateKeeper *This)
|
|||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// operation helpers
|
||||
|
||||
bool CGateKeeper::IsNodeListedOk(const CCallsign &callsign, const CIp &ip) const
|
||||
bool CGateKeeper::IsNodeListedOk(const CCallsign &callsign, const CIp &ip, char module) const
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
|
@ -207,13 +207,13 @@ bool CGateKeeper::IsNodeListedOk(const CCallsign &callsign, const CIp &ip) const
|
|||
const_cast<CCallsignList &>(m_NodeWhiteList).Lock();
|
||||
if ( !m_NodeWhiteList.empty() )
|
||||
{
|
||||
ok = m_NodeWhiteList.IsCallsignListed(callsign);
|
||||
ok = m_NodeWhiteList.IsCallsignListedWithWildcard(callsign, module);
|
||||
}
|
||||
const_cast<CCallsignList &>(m_NodeWhiteList).Unlock();
|
||||
|
||||
// then check if not blacklisted
|
||||
const_cast<CCallsignList &>(m_NodeBlackList).Lock();
|
||||
ok &= !m_NodeBlackList.IsCallsignListed(callsign);
|
||||
ok &= !m_NodeBlackList.IsCallsignListedWithWildcard(callsign);
|
||||
const_cast<CCallsignList &>(m_NodeBlackList).Unlock();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ protected:
|
|||
static void Thread(CGateKeeper *);
|
||||
|
||||
// operation helpers
|
||||
bool IsNodeListedOk(const CCallsign &, const CIp &) const;
|
||||
bool IsNodeListedOk(const CCallsign &, const CIp &, char = ' ') const;
|
||||
bool IsPeerListedOk(const CCallsign &, const CIp &, char) const;
|
||||
bool IsPeerListedOk(const CCallsign &, const CIp &, char *) const;
|
||||
|
||||
|
|
|
@ -349,10 +349,12 @@ void CReflector::XmlReportThread(CReflector *This)
|
|||
// and close file
|
||||
xmlFile.close();
|
||||
}
|
||||
#ifndef NO_ERROR_ON_XML_OPEN_FAIL
|
||||
else
|
||||
{
|
||||
std::cout << "Failed to open " << XML_PATH << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// and wait a bit
|
||||
CTimePoint::TaskSleepFor(XML_UPDATE_PERIOD * 1000);
|
||||
|
|
|
@ -48,12 +48,13 @@
|
|||
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 3
|
||||
#define VERSION_REVISION 8
|
||||
#define VERSION_REVISION 9
|
||||
|
||||
// global ------------------------------------------------------
|
||||
|
||||
#define RUN_AS_DAEMON
|
||||
#define JSON_MONITOR
|
||||
//#define NO_ERROR_ON_XML_OPEN_FAIL
|
||||
|
||||
// reflector ---------------------------------------------------
|
||||
|
||||
|
|
Loading…
Reference in New Issue