2
0
mirror of https://github.com/rehlds/rehlds.git synced 2024-12-29 08:05:50 +03:00

Replaced Con_Printf to Con_DPrintf for net messages that can be used for flood (related to #247)

Added player name and print to client for some net messages (not for all, need finish this in future)
echo -> svc_print
This commit is contained in:
WPMGPRoSToTeMa 2016-10-19 20:32:05 +03:00
parent 2da7695800
commit e2be6491ba
6 changed files with 38 additions and 17 deletions

View File

@ -404,4 +404,10 @@ typedef struct netchan_s
flow_t flow[MAX_FLOWS];
} netchan_t;
#ifdef REHLDS_FIXES
#define Con_NetPrintf Con_DPrintf
#else // REHLDS_FIXES
#define Con_NetPrintf Con_Printf
#endif // REHLDS_FIXES
#endif // GS_NET_H

View File

@ -1522,7 +1522,14 @@ qboolean Netchan_CopyNormalFragments(netchan_t *chan)
#ifdef REHLDS_FIXES
if (overflowed)
{
Con_Printf("Netchan_CopyNormalFragments: Overflowed\n");
if (chan->player_slot == 0)
{
Con_Printf("Netchan_CopyNormalFragments: Incoming overflowed\n");
}
else
{
Con_Printf("Netchan_CopyNormalFragments: Incoming overflowed from %s\n", g_psvs.clients[chan->player_slot - 1].name);
}
SZ_Clear(&net_message);
@ -1589,6 +1596,9 @@ qboolean Netchan_CopyFileFragments(netchan_t *chan)
uncompressedSize = (unsigned int)MSG_ReadLong();
#ifdef REHLDS_FIXES
// TODO: this condition is invalid for server->client
// TODO: add console message for client
// TODO: add client name to message
if (uncompressedSize > 1024 * 64) {
Con_Printf("Received too large file (size=%u)\nFlushing input queue\n", uncompressedSize);
Netchan_FlushIncoming(chan, 1);

View File

@ -881,7 +881,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (packetNumber >= NET_WS_MAX_FRAGMENTS || packetCount > NET_WS_MAX_FRAGMENTS)
{
Con_Printf("Malformed packet number (%i/%i)\n", packetNumber + 1, packetCount);
Con_NetPrintf("Malformed packet number (%i/%i)\n", packetNumber + 1, packetCount);
return FALSE;
}
if (gNetSplit.currentSequence == -1 || sequenceNumber != gNetSplit.currentSequence)
@ -904,7 +904,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
unsigned int packetPayloadSize = size - sizeof(SPLITPACKET);
if (gNetSplitFlags[packetNumber] == sequenceNumber)
{
Con_Printf( "NET_GetLong: Ignoring duplicated split packet %i of %i ( %i bytes )\n",
Con_NetPrintf( "NET_GetLong: Ignoring duplicated split packet %i of %i ( %i bytes )\n",
packetNumber + 1, packetCount, packetPayloadSize
);
}
@ -925,7 +925,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
if (SPLIT_SIZE * packetNumber + packetPayloadSize > MAX_UDP_PACKET)
{
Con_Printf("Malformed packet size (%i, %i)\n", SPLIT_SIZE * packetNumber, packetPayloadSize);
Con_NetPrintf("Malformed packet size (%i, %i)\n", SPLIT_SIZE * packetNumber, packetPayloadSize);
#ifdef REHLDS_FIXES
gNetSplit.currentSequence = -1;
#endif
@ -944,7 +944,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
{
if (gNetSplitFlags[i] != gNetSplit.currentSequence)
{
Con_Printf(
Con_NetPrintf(
"Split packet without all %i parts, part %i had wrong sequence %i/%i\n",
packetCount,
i + 1,
@ -970,7 +970,7 @@ qboolean NET_GetLong(unsigned char *pData, int size, int *outSize)
#ifdef REHLDS_FIXES
*outSize = 0;
#endif
Con_Printf("Split packet too large! %d bytes\n", gNetSplit.totalSize);
Con_NetPrintf("Split packet too large! %d bytes\n", gNetSplit.totalSize);
return FALSE;
}
}
@ -1044,7 +1044,7 @@ qboolean NET_QueuePacket(netsrc_t sock)
if (ret != MAX_UDP_PACKET)
break;
Con_Printf("NET_QueuePacket: Oversize packet from %s\n", NET_AdrToString(in_from));
Con_NetPrintf("NET_QueuePacket: Oversize packet from %s\n", NET_AdrToString(in_from));
}
if (ret == -1 || ret == MAX_UDP_PACKET) {
@ -1060,11 +1060,7 @@ qboolean NET_QueuePacket(netsrc_t sock)
}
else
{
#ifdef REHLDS_FIXES
Con_DPrintf("Invalid split packet length %i\n", in_message.cursize);
#else
Con_Printf("Invalid split packet length %i\n", in_message.cursize);
#endif
Con_NetPrintf("Invalid split packet length %i\n", in_message.cursize);
return FALSE;
}
}

View File

@ -207,7 +207,11 @@ void EXT_FUNC PF_sprint(char *s, int entnum)
client_t* client = &g_psvs.clients[entnum - 1];
if (!client->fakeclient)
{
#ifdef REHLDS_FIXES
MSG_WriteByte(&client->netchan.message, svc_print);
#else // REHLDS_FIXES
MSG_WriteChar(&client->netchan.message, svc_print);
#endif // REHLDS_FIXES
MSG_WriteString(&client->netchan.message, s);
}
}

View File

@ -1624,8 +1624,12 @@ void SV_New_f(void)
if (!gEntityInterface.pfnClientConnect(ent, szName, szAddress, szRejectReason))
{
// Reject the connection and drop the client.
#ifdef REHLDS_FIXES
SV_ClientPrintf("%s\n", szRejectReason);
#else // REHLDS_FIXES
MSG_WriteByte(&host_client->netchan.message, svc_stufftext);
MSG_WriteString(&host_client->netchan.message, va("echo %s\n", szRejectReason));
#endif // REHLDS_FIXES
SV_DropClient(host_client, FALSE, "Server refused connection because: %s", szRejectReason);
return;
}
@ -3492,11 +3496,7 @@ void SV_ConnectionlessPacket(void)
}
else if (c[0] == A2A_ACK && (c[1] == 0 || c[1] == '\n'))
{
#ifdef REHLDS_FIXES
Con_DPrintf("A2A_ACK from %s\n", NET_AdrToString(net_from));
#else // REHLDS_FIXES
Con_Printf("A2A_ACK from %s\n", NET_AdrToString(net_from));
#endif // REHLDS_FIXES
Con_NetPrintf("A2A_ACK from %s\n", NET_AdrToString(net_from));
}
else if (c[0] == A2A_GETCHALLENGE || c[0] == A2S_INFO || c[0] == A2S_PLAYER || c[0] == A2S_RULES ||
c[0] == S2A_LOGSTRING || c[0] == M2S_REQUESTRESTART || c[0] == M2A_CHALLENGE)

View File

@ -1778,7 +1778,12 @@ void SV_ExecuteClientMessage(client_t *cl)
{
if (msg_badread)
{
#ifdef REHLDS_FIXES
Con_Printf("SV_ReadClientMessage: badread on %s\n", host_client->name);
SV_ClientPrintf("Badread\n");
#else // REHLDS_FIXES
Con_Printf("SV_ReadClientMessage: badread\n");
#endif // REHLDS_FIXES
return;
}