show reason for closing a connection within a debug message. Closes #1061

This commit is contained in:
oy 2013-02-20 16:49:21 +01:00
parent 07c97822bb
commit 118d2ac837

View file

@ -214,27 +214,25 @@ int CNetConnection::Feed(CNetPacketConstruct *pPacket, NETADDR *pAddr)
m_State = NET_CONNSTATE_ERROR; m_State = NET_CONNSTATE_ERROR;
m_RemoteClosed = 1; m_RemoteClosed = 1;
if(!m_BlockCloseMsg) char Str[128] = {0};
{ if(pPacket->m_DataSize > 1)
if(pPacket->m_DataSize)
{ {
// make sure to sanitize the error string form the other party // make sure to sanitize the error string form the other party
char Str[128];
if(pPacket->m_DataSize < 128) if(pPacket->m_DataSize < 128)
str_copy(Str, (char *)pPacket->m_aChunkData, pPacket->m_DataSize); str_copy(Str, (char *)&pPacket->m_aChunkData[1], pPacket->m_DataSize);
else else
str_copy(Str, (char *)pPacket->m_aChunkData, sizeof(Str)); str_copy(Str, (char *)&pPacket->m_aChunkData[1], sizeof(Str));
str_sanitize_strong(Str); str_sanitize_strong(Str);
}
if(!m_BlockCloseMsg)
{
// set the error string // set the error string
SetError(Str); SetError(Str);
} }
else
SetError("No reason given");
}
if(g_Config.m_Debug) if(g_Config.m_Debug)
dbg_msg("conn", "closed reason='%s'", ErrorString()); dbg_msg("conn", "closed reason='%s'", Str);
} }
return 0; return 0;
} }