Browse Source

debugging

master
Tom Early 12 months ago
parent
commit
da7c1e0c35
  1. 3
      callsignlist.cpp
  2. 6
      callsignlistitem.h
  3. 42
      gatekeeper.cpp

3
callsignlist.cpp

@ -164,6 +164,7 @@ bool CCallsignList::IsCallsignListed(const CCallsign &callsign, char module) con
bool CCallsignList::IsCallsignListed(const CCallsign &callsign, const CIp &ip, const char *modules) const
{
std::cout << "Searching for " << callsign << " " << ip << " " << modules << std::endl;
for ( const auto &item : m_Callsigns )
{
if ( item.HasSameCallsign(callsign) )
@ -172,10 +173,12 @@ bool CCallsignList::IsCallsignListed(const CCallsign &callsign, const CIp &ip, c
{
if ( ip == item.GetIp() )
{
std::cout << "FOUND!" << std::endl;
return true;
}
}
}
std::cout << "NOPE " << item.GetCallsign() << " " << item.GetIp() << " " << item.GetModules() << std::endl;
}
return false;

6
callsignlistitem.h

@ -54,9 +54,9 @@ public:
bool CheckListedModules(const char*) const;
// get
const CCallsign &GetCallsign(void) const { return m_Callsign; }
const CIp &GetIp(void) const { return m_Ip; }
const std::string &GetModules(void) { return m_Mods; }
const CCallsign &GetCallsign(void) const { return m_Callsign; }
const CIp &GetIp(void) const { return m_Ip; }
const std::string &GetModules(void) const { return m_Mods; }
protected:
// data

42
gatekeeper.cpp

@ -152,22 +152,19 @@ bool CGateKeeper::IsNodeListedOk(const CCallsign &callsign, const CIp &ip, char
// first check IP
// next, check callsign
if ( ok )
// first check if callsign is in white list
// note if white list is empty, everybody is authorized
const_cast<CCallsignList &>(m_NodeWhiteList).Lock();
if ( !m_NodeWhiteList.empty() )
{
// first check if callsign is in white list
// note if white list is empty, everybody is authorized
const_cast<CCallsignList &>(m_NodeWhiteList).Lock();
if ( !m_NodeWhiteList.empty() )
{
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.IsCallsignListedWithWildcard(callsign);
const_cast<CCallsignList &>(m_NodeBlackList).Unlock();
ok = m_NodeWhiteList.IsCallsignListedWithWildcard(callsign, module);
}
const_cast<CCallsignList &>(m_NodeWhiteList).Unlock();
// then check if not blacklisted
const_cast<CCallsignList &>(m_NodeBlackList).Lock();
ok = ok && !m_NodeBlackList.IsCallsignListedWithWildcard(callsign);
const_cast<CCallsignList &>(m_NodeBlackList).Unlock();
// done
return ok;
@ -176,19 +173,16 @@ bool CGateKeeper::IsNodeListedOk(const CCallsign &callsign, const CIp &ip, char
bool CGateKeeper::IsPeerListedOk(const CCallsign &callsign, const CIp &ip, const char *modules) const
{
bool ok = true;
bool ok;
if ( ok )
// look for an exact match in the list
const_cast<CPeerCallsignList &>(m_PeerList).Lock();
if ( !m_PeerList.empty() )
{
// look for an exact match in the list
const_cast<CPeerCallsignList &>(m_PeerList).Lock();
if ( !m_PeerList.empty() )
{
// find an exact match
ok = m_PeerList.IsCallsignListed(callsign, ip, modules);
}
const_cast<CPeerCallsignList &>(m_PeerList).Unlock();
// find an exact match
ok = m_PeerList.IsCallsignListed(callsign, ip, modules);
}
const_cast<CPeerCallsignList &>(m_PeerList).Unlock();
// done
return ok;

Loading…
Cancel
Save