add separate config option for reporting peer pings to the log; add extra logging around an RPTL NAK condition;

pull/48/head
Bryan Biedenkapp 2 years ago
parent 64e3e91e2e
commit 0e20d4fec0

@ -46,6 +46,9 @@ master:
# Flag indicating whether or not verbose debug logging is enabled.
debug: false
# Flag indicating whether or not peer pinging will be reported.
reportPeerPing: true
# Flag indicating whether or not master endpoint networking is encrypted.
encrypted: false
# AES-256 32-byte Preshared Key

@ -373,6 +373,8 @@ bool HostFNE::createMasterNetwork()
bool verbose = masterConf["verbose"].as<bool>(false);
bool debug = masterConf["debug"].as<bool>(false);
bool reportPeerPing = masterConf["reportPeerPing"].as<bool>(false);
bool encrypted = masterConf["encrypted"].as<bool>(false);
std::string key = masterConf["presharedKey"].as<std::string>();
uint8_t presharedKey[AES_WRAPPED_PCKT_KEY_LEN];
@ -433,6 +435,8 @@ bool HostFNE::createMasterNetwork()
LogInfo(" Encrypted: %s", encrypted ? "yes" : "no");
LogInfo(" Report Peer Pings: %s", reportPeerPing ? "yes" : "no");
if (verbose) {
LogInfo(" Verbose: yes");
}
@ -442,7 +446,7 @@ bool HostFNE::createMasterNetwork()
}
// initialize networking
m_network = new FNENetwork(this, address, port, id, password, debug, verbose, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled,
m_network = new FNENetwork(this, address, port, id, password, debug, verbose, reportPeerPing, m_dmrEnabled, m_p25Enabled, m_nxdnEnabled,
parrotDelay, parrotGrantDemand, m_allowActivityTransfer, m_allowDiagnosticTransfer, m_pingTime, m_updateLookupTime);
m_network->setLookups(m_ridLookup, m_tidLookup);

@ -42,6 +42,7 @@ using namespace network::fne;
/// <param name="password">Network authentication password.</param>
/// <param name="debug">Flag indicating whether network debug is enabled.</param>
/// <param name="verbose">Flag indicating whether network verbose logging is enabled.</param>
/// <param name="reportPeerPing">Flag indicating whether peer pinging is reported.</param>
/// <param name="dmr">Flag indicating whether DMR is enabled.</param>
/// <param name="p25">Flag indicating whether P25 is enabled.</param>
/// <param name="nxdn">Flag indicating whether NXDN is enabled.</param>
@ -52,7 +53,7 @@ using namespace network::fne;
/// <param name="pingTime"></param>
/// <param name="updateLookupTime"></param>
FNENetwork::FNENetwork(HostFNE* host, const std::string& address, uint16_t port, uint32_t peerId, const std::string& password,
bool debug, bool verbose, bool dmr, bool p25, bool nxdn, uint32_t parrotDelay, bool parrotGrantDemand,
bool debug, bool verbose, bool reportPeerPing, bool dmr, bool p25, bool nxdn, uint32_t parrotDelay, bool parrotGrantDemand,
bool allowActivityTransfer, bool allowDiagnosticTransfer, uint32_t pingTime, uint32_t updateLookupTime) :
BaseNetwork(peerId, true, debug, true, true, allowActivityTransfer, allowDiagnosticTransfer),
m_tagDMR(nullptr),
@ -76,6 +77,7 @@ FNENetwork::FNENetwork(HostFNE* host, const std::string& address, uint16_t port,
m_updateLookupTimer(1000U, (updateLookupTime * 60U)),
m_forceListUpdate(false),
m_callInProgress(false),
m_reportPeerPing(reportPeerPing),
m_verbose(verbose)
{
assert(host != nullptr);
@ -320,12 +322,18 @@ void FNENetwork::clock(uint32_t ms)
// the login sequence
if (peerId > 0 && (m_peers.find(peerId) != m_peers.end())) {
FNEPeerConnection* connection = m_peers[peerId];
LogMessage(LOG_NET, "PEER %u was RPTL NAKed cleaning up peer connection", peerId);
if (connection != nullptr) {
if (connection->connectionState() != NET_STAT_RUNNING) {
if (erasePeer(peerId)) {
delete connection;
}
}
} else {
erasePeer(peerId);
if (m_verbose) {
LogWarning(LOG_NET, "PEER %u was RPTL NAKed while having no connection?", peerId);
}
}
}
}
@ -510,7 +518,7 @@ void FNENetwork::clock(uint32_t ms)
m_peers[peerId] = connection;
writePeerCommand(peerId, { NET_FUNC_PONG, NET_SUBFUNC_NOP });
if (m_verbose) {
if (m_reportPeerPing) {
LogInfoEx(LOG_NET, "PEER %u ping received and answered, pingsReceived = %u", peerId, connection->pingsReceived());
}
}

@ -141,7 +141,7 @@ namespace network
public:
/// <summary>Initializes a new instance of the FNENetwork class.</summary>
FNENetwork(HostFNE* host, const std::string& address, uint16_t port, uint32_t peerId, const std::string& password,
bool debug, bool verbose, bool dmr, bool p25, bool nxdn, uint32_t parrotDelay, bool parrotGrantDemand,
bool debug, bool verbose, bool reportPeerPing, bool dmr, bool p25, bool nxdn, uint32_t parrotDelay, bool parrotGrantDemand,
bool allowActivityTransfer, bool allowDiagnosticTransfer, uint32_t pingTime, uint32_t updateLookupTime);
/// <summary>Finalizes a instance of the FNENetwork class.</summary>
~FNENetwork() override;
@ -209,6 +209,7 @@ namespace network
bool m_forceListUpdate;
bool m_callInProgress;
bool m_reportPeerPing;
bool m_verbose;
/// <summary>Helper to erase the peer from the peers affiliations list.</summary>

Loading…
Cancel
Save

Powered by TurnKey Linux.