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