mirror of
https://github.com/g4klx/DAPNETGateway.git
synced 2026-08-26 12:32:45 -04:00
commit
14b86da9ea
4 changed files with 31 additions and 1 deletions
14
Conf.cpp
14
Conf.cpp
|
|
@ -107,6 +107,15 @@ bool CConf::read()
|
|||
m_whiteList.push_back(ric);
|
||||
p = ::strtok(NULL, ",\r\n");
|
||||
}
|
||||
} else if (::strcmp(key, "BlackList") == 0) {
|
||||
char* p = ::strtok(value, ",\r\n");
|
||||
while (p != NULL) {
|
||||
unsigned int ric = (unsigned int)::atoi(p);
|
||||
if (ric > 0U)
|
||||
m_blackList.push_back(ric);
|
||||
p = ::strtok(NULL, ",\r\n");
|
||||
}
|
||||
|
||||
} else if (::strcmp(key,"BlacklistRegexfile") == 0)
|
||||
m_blacklistRegexfile = value;
|
||||
else if (::strcmp(key,"WhitelistRegexfile") == 0)
|
||||
|
|
@ -161,6 +170,11 @@ std::vector<uint32_t> CConf::getWhiteList() const
|
|||
return m_whiteList;
|
||||
}
|
||||
|
||||
std::vector<uint32_t> CConf::getBlackList() const
|
||||
{
|
||||
return m_blackList;
|
||||
}
|
||||
|
||||
std::string CConf::getblacklistRegexfile() const
|
||||
{
|
||||
return m_blacklistRegexfile;
|
||||
|
|
|
|||
3
Conf.h
3
Conf.h
|
|
@ -33,6 +33,7 @@ public:
|
|||
// The General section
|
||||
std::string getCallsign() const;
|
||||
std::vector<unsigned int> getWhiteList() const;
|
||||
std::vector<unsigned int> getBlackList() const;
|
||||
std::string getblacklistRegexfile() const;
|
||||
std::string getwhitelistRegexfile() const;
|
||||
std::string getRptAddress() const;
|
||||
|
|
@ -58,6 +59,8 @@ private:
|
|||
|
||||
std::string m_callsign;
|
||||
std::vector<unsigned int> m_whiteList;
|
||||
std::vector<unsigned int> m_blackList;
|
||||
|
||||
std::string m_blacklistRegexfile;
|
||||
std::string m_whitelistRegexfile;
|
||||
std::string m_rptAddress;
|
||||
|
|
|
|||
|
|
@ -267,6 +267,8 @@ int CDAPNETGateway::run()
|
|||
}
|
||||
|
||||
std::vector<unsigned int> whiteList = m_conf.getWhiteList();
|
||||
std::vector<unsigned int> blackList = m_conf.getBlackList();
|
||||
|
||||
std::vector<std::regex> regexBlacklist;
|
||||
std::vector<std::regex> regexWhitelist;
|
||||
|
||||
|
|
@ -312,6 +314,7 @@ int CDAPNETGateway::run()
|
|||
CPOCSAGMessage* message = m_dapnetNetwork->readMessage();
|
||||
if (message != NULL) {
|
||||
bool found = true;
|
||||
bool blackListRIC = false;
|
||||
bool blacklistRegexmatch = false;
|
||||
bool whitelistRegexmatch = true;
|
||||
|
||||
|
|
@ -319,6 +322,15 @@ int CDAPNETGateway::run()
|
|||
if (!whiteList.empty())
|
||||
found = std::find(whiteList.begin(), whiteList.end(), message->m_ric) != whiteList.end();
|
||||
|
||||
// If we have a black list of RICs, use it.
|
||||
if (!blackList.empty())
|
||||
blackListRIC = std::find(blackList.begin(), blackList.end(), message->m_ric) != blackList.end();
|
||||
if (blackListRIC)
|
||||
LogDebug("Blacklist match: Not queueing message to %07u, type %u, message: \"%.*s\"", message->m_ric, message->m_type, message->m_length, message->m_message);
|
||||
|
||||
|
||||
|
||||
|
||||
std::string messageBody(reinterpret_cast<char*>(message->m_message));
|
||||
//If we have a list of blacklist REGEXes, use them
|
||||
if (!regexBlacklist.empty()) {
|
||||
|
|
@ -343,7 +355,7 @@ int CDAPNETGateway::run()
|
|||
}
|
||||
}
|
||||
|
||||
if (found && !blacklistRegexmatch && whitelistRegexmatch) {
|
||||
if (found && !blackListRIC && !blacklistRegexmatch && whitelistRegexmatch) {
|
||||
switch (message->m_functional) {
|
||||
case FUNCTIONAL_ALPHANUMERIC:
|
||||
LogDebug("Queueing message to %07u, type %u, func Alphanumeric: \"%.*s\"", message->m_ric, message->m_type, message->m_length, message->m_message);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[General]
|
||||
Callsign=g9bf
|
||||
# WhiteList=12345,78901
|
||||
# BlackList=
|
||||
#BlacklistRegexfile=/tmp/blregexes.txt
|
||||
#WhitelistRegexfile=/tmp/wlregexes.txt
|
||||
RptAddress=127.0.0.1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue