Add --connection-debug for verbose packet logging
This commit is contained in:
parent
e674f2d091
commit
843ecfcbc0
@ -607,6 +607,7 @@ void cmdLineHelp()
|
||||
" --ranked Server will submit ranking to stk addons server.\n"
|
||||
" You require permission for that.\n"
|
||||
" --owner-less Race will auto start and no one can kick players in server.\n"
|
||||
" --connection-debug Print verbose info for sending or receiving packets.\n"
|
||||
" --no-console-log Does not write messages in the console but to\n"
|
||||
" stdout.log.\n"
|
||||
" -h, --help Show this help.\n"
|
||||
@ -1105,6 +1106,10 @@ int handleCmdLine()
|
||||
{
|
||||
NetworkConfig::get()->setOwnerLess(true);
|
||||
}
|
||||
if (CommandLine::has("--connection-debug"))
|
||||
{
|
||||
Network::m_connection_debug = true;
|
||||
}
|
||||
if (CommandLine::has("--server-id-file", &s))
|
||||
{
|
||||
NetworkConfig::get()->setServerIdFile(
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
Synchronised<FILE*>Network::m_log_file = NULL;
|
||||
bool Network::m_connection_debug = false;
|
||||
|
||||
// ============================================================================
|
||||
/** Constructor that just initialises this object (esp. opening the packet
|
||||
@ -111,8 +112,11 @@ void Network::sendRawPacket(const BareNetworkString &buffer,
|
||||
|
||||
sendto(m_host->socket, buffer.getData(), buffer.size(), 0,
|
||||
(sockaddr*)&to, to_len);
|
||||
Log::verbose("Network", "Raw packet sent to %s",
|
||||
dst.toString().c_str());
|
||||
if (m_connection_debug)
|
||||
{
|
||||
Log::verbose("Network", "Raw packet sent to %s",
|
||||
dst.toString().c_str());
|
||||
}
|
||||
Network::logPacket(buffer, false);
|
||||
} // sendRawPacket
|
||||
|
||||
@ -162,10 +166,10 @@ int Network::receiveRawPacket(char *buffer, int buf_len,
|
||||
Network::logPacket(BareNetworkString(buffer, len), true);
|
||||
sender->setIP(ntohl((uint32_t)(addr.sin_addr.s_addr)) );
|
||||
sender->setPort( ntohs(addr.sin_port) );
|
||||
if (addr.sin_family == AF_INET)
|
||||
if (addr.sin_family == AF_INET && m_connection_debug)
|
||||
{
|
||||
Log::info("Network", "IPv4 Address of the sender was %s",
|
||||
sender->toString().c_str());
|
||||
Log::verbose("Network", "IPv4 Address of the sender was %s",
|
||||
sender->toString().c_str());
|
||||
}
|
||||
return len;
|
||||
} // receiveRawPacket
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
static Synchronised<FILE*> m_log_file;
|
||||
|
||||
public:
|
||||
static bool m_connection_debug;
|
||||
Network(int peer_count, int channel_limit,
|
||||
uint32_t max_incoming_bandwidth,
|
||||
uint32_t max_outgoing_bandwidth,
|
||||
|
@ -115,8 +115,12 @@ void STKPeer::sendPacket(NetworkString *data, bool reliable, bool encrypted)
|
||||
|
||||
if (packet)
|
||||
{
|
||||
Log::verbose("STKPeer", "sending packet of size %d to %s at %f",
|
||||
packet->dataLength, a.toString().c_str(), StkTime::getRealTime());
|
||||
if (Network::m_connection_debug)
|
||||
{
|
||||
Log::verbose("STKPeer", "sending packet of size %d to %s at %f",
|
||||
packet->dataLength, a.toString().c_str(),
|
||||
StkTime::getRealTime());
|
||||
}
|
||||
m_host->addEnetCommand(m_enet_peer, packet,
|
||||
encrypted ? EVENT_CHANNEL_NORMAL : EVENT_CHANNEL_UNENCRYPTED,
|
||||
ECT_SEND_PACKET);
|
||||
|
Loading…
Reference in New Issue
Block a user