fixed crash when no autolink module was specified

pull/5/head
Tom Early 1 year ago
parent 8424d8d3eb
commit 6af8b0150f

@ -37,7 +37,7 @@ IPv4Binding = 0.0.0.0
# Modules = ABCDEFGHIJKLMNOPQRSTUVWXYZ # Modules = ABCDEFGHIJKLMNOPQRSTUVWXYZ
Modules = ADMSZ Modules = ADMSZ
# Create Descriptions as needed... # Create Descriptions as needed...
DescriptionA = Transcoded DescriptionA = All Modes
DescriptionD = DMR Chat DescriptionD = DMR Chat
DescriptionM = M17 Chat DescriptionM = M17 Chat
DescriptionS = DStar Chat DescriptionS = DStar Chat
@ -91,7 +91,7 @@ Port = 10017
[USRP] [USRP]
Enable = false Enable = false
Callsign = ALLSTAR # set to NONE if you don't want to create this client Callsign = ALLSTAR
IPAddress = 1.2.3.4 # the IP address of the USRP client (the Allstar node) IPAddress = 1.2.3.4 # the IP address of the USRP client (the Allstar node)
RxPort = 34000 RxPort = 34000
TxPort = 32000 TxPort = 32000

@ -819,21 +819,19 @@ bool CConfigure::isDefined(ErrorLevel level, const std::string &section, const s
return false; return false;
} }
void CConfigure::checkAutoLink(const std::string &section, const std::string &pname, const std::string &key, bool &rval) void CConfigure::checkAutoLink(const std::string &section, const std::string &pname, const std::string &key, bool &rval) const
{ {
if (data.contains(key)) const auto autolinkModule = GetAutolinkModule(key);
if (' ' != autolinkModule)
{ {
auto ismods = data.contains(g_Keys.modules.modules); auto ismods = data.contains(g_Keys.modules.modules);
const auto mods(ismods ? data[g_Keys.modules.modules].get<std::string>() : ""); const auto mods(ismods ? data[g_Keys.modules.modules].get<std::string>() : "");
const auto c = data[key].get<std::string>().at(0); if (std::string::npos == mods.find(autolinkModule))
if (std::string::npos == mods.find(c))
{ {
std::cerr << "ERROR: [" << section << ']' << pname << " module '" << c << "' not a configured module" << std::endl; std::cerr << "ERROR: [" << section << ']' << pname << " module '" << autolinkModule << "' not a configured module" << std::endl;
rval = true; rval = true;
} }
} }
else
data[key] = nullptr;
} }
std::string CConfigure::getDataRefreshType(ERefreshType type) const std::string CConfigure::getDataRefreshType(ERefreshType type) const
@ -865,7 +863,7 @@ void CConfigure::badParam(const std::string &key) const
bool CConfigure::checkModules(std::string &m) const bool CConfigure::checkModules(std::string &m) const
{ {
bool rval = false; // return true on error bool rval = false; // return true on error
for(unsigned i=0; i<m.size(); i++) for (unsigned i=0; i<m.size(); i++)
if (islower(m[i])) if (islower(m[i]))
m[i] = toupper(m[i]); m[i] = toupper(m[i]);
@ -988,7 +986,7 @@ bool CConfigure::GetBoolean(const std::string &key) const
char CConfigure::GetAutolinkModule(const std::string &key) const char CConfigure::GetAutolinkModule(const std::string &key) const
{ {
char c = 0; char c = ' ';
if (data.contains(key)) if (data.contains(key))
{ {
if (data[key].is_string()) if (data[key].is_string())

@ -57,5 +57,5 @@ private:
void checkFile(const std::string &section, const std::string &key, const std::string &filepath) const; void checkFile(const std::string &section, const std::string &key, const std::string &filepath) const;
void setAutolink(const std::string &section, const std::string &key, const std::string &value); void setAutolink(const std::string &section, const std::string &key, const std::string &value);
bool isDefined(ErrorLevel level, const std::string &section, const std::string &pname, const std::string &key, bool &rval); bool isDefined(ErrorLevel level, const std::string &section, const std::string &pname, const std::string &key, bool &rval);
void checkAutoLink(const std::string &section, const std::string &pname, const std::string &key, bool &rval); void checkAutoLink(const std::string &section, const std::string &pname, const std::string &key, bool &rval) const;
}; };

@ -62,7 +62,7 @@ CURLcode CCurlGet::GetURL(const std::string &url, std::stringstream &ss, long ti
} }
if (code != CURLE_OK) if (code != CURLE_OK)
{ {
std::cout << "ERROR: was not able retrieve data at '" << url << "'\nCurl returned: " << code << std::endl; std::cout << "WARNING: was not able retrieve data at '" << url << "'\nCurl returned: " << code << std::endl;
} }
return code; return code;
} }

@ -28,7 +28,7 @@ SJsonKeys g_Keys;
CReflector g_Reflector; CReflector g_Reflector;
CGateKeeper g_GateKeeper; CGateKeeper g_GateKeeper;
CConfigure g_Configure; CConfigure g_Configure;
CVersion g_Version(3,1,3); // The major byte should only change if the interlink packet changes! CVersion g_Version(3,1,4); // The major byte should only change if the interlink packet changes!
CLookupDmr g_LDid; CLookupDmr g_LDid;
CLookupNxdn g_LNid; CLookupNxdn g_LNid;
CLookupYsf g_LYtr; CLookupYsf g_LYtr;

@ -133,7 +133,7 @@ void CNXDNProtocol::Task(void)
auto newclient = std::make_shared<CNXDNClient>(Callsign, Ip); auto newclient = std::make_shared<CNXDNClient>(Callsign, Ip);
// aautolink, if enabled // aautolink, if enabled
if (m_AutolinkModule) if (' ' != m_AutolinkModule)
newclient->SetReflectorModule(m_AutolinkModule); newclient->SetReflectorModule(m_AutolinkModule);
// and append // and append

@ -122,7 +122,7 @@ void CP25Protocol::Task(void)
auto newclient = std::make_shared<CP25Client>(Callsign, Ip); auto newclient = std::make_shared<CP25Client>(Callsign, Ip);
// aautolink, if enabled // aautolink, if enabled
if (m_AutolinkModule) if (' ' != m_AutolinkModule)
newclient->SetReflectorModule(m_AutolinkModule); newclient->SetReflectorModule(m_AutolinkModule);
// and append // and append

@ -94,7 +94,7 @@ bool CProtocols::Init(void)
if (g_Configure.GetBoolean(g_Keys.usrp.enable)) if (g_Configure.GetBoolean(g_Keys.usrp.enable))
{ {
m_Protocols.emplace_back(std::unique_ptr<CUSRPProtocol>(new CUSRPProtocol)); m_Protocols.emplace_back(std::unique_ptr<CUSRPProtocol>(new CUSRPProtocol));
if (! m_Protocols.back()->Initialize("USRP", EProtocol::usrp, uint16_t(g_Configure.GetUnsigned(g_Keys.usrp.rxport)), USRP_IPV4, USRP_IPV6)) if (! m_Protocols.back()->Initialize("USRP", EProtocol::usrp, uint16_t(g_Configure.GetUnsigned(g_Keys.usrp.rxport)), USRP_IPV4, USRP_IPV6))
return false; return false;
} }

@ -532,9 +532,9 @@ void CReflector::PutDHTConfig()
std::ostringstream ss; std::ostringstream ss;
ss << g_Version; ss << g_Version;
cfg.version.assign(ss.str()); cfg.version.assign(ss.str());
cfg.almod[toUType(EUrfdAlMod::nxdn)] = g_Configure.GetString(g_Keys.nxdn.autolinkmod).at(0); cfg.almod[toUType(EUrfdAlMod::nxdn)] = g_Configure.GetAutolinkModule(g_Keys.nxdn.autolinkmod);
cfg.almod[toUType(EUrfdAlMod::p25)] = g_Configure.GetString(g_Keys.p25.autolinkmod).at(0); cfg.almod[toUType(EUrfdAlMod::p25)] = g_Configure.GetAutolinkModule(g_Keys.p25.autolinkmod);
cfg.almod[toUType(EUrfdAlMod::ysf)] = g_Configure.GetString(g_Keys.ysf.autolinkmod).at(0); cfg.almod[toUType(EUrfdAlMod::ysf)] = g_Configure.GetAutolinkModule(g_Keys.ysf.autolinkmod);
cfg.ysffreq[toUType(EUrfdTxRx::rx)] = g_Configure.GetUnsigned(g_Keys.ysf.defaultrxfreq); cfg.ysffreq[toUType(EUrfdTxRx::rx)] = g_Configure.GetUnsigned(g_Keys.ysf.defaultrxfreq);
cfg.ysffreq[toUType(EUrfdTxRx::tx)] = g_Configure.GetUnsigned(g_Keys.ysf.defaulttxfreq); cfg.ysffreq[toUType(EUrfdTxRx::tx)] = g_Configure.GetUnsigned(g_Keys.ysf.defaulttxfreq);
cfg.refid[toUType(EUrfdRefId::nxdn)] = g_Configure.GetUnsigned(g_Keys.nxdn.reflectorid); cfg.refid[toUType(EUrfdRefId::nxdn)] = g_Configure.GetUnsigned(g_Keys.nxdn.reflectorid);

@ -164,7 +164,7 @@ void CYsfProtocol::Task(void)
auto newclient = std::make_shared<CYsfClient>(Callsign, Ip); auto newclient = std::make_shared<CYsfClient>(Callsign, Ip);
// aautolink, if enabled // aautolink, if enabled
if (m_AutolinkModule) if (' ' != m_AutolinkModule)
newclient->SetReflectorModule(m_AutolinkModule); newclient->SetReflectorModule(m_AutolinkModule);
// and append // and append

Loading…
Cancel
Save

Powered by TurnKey Linux.