+/*
+Copyright (C) 2010-2015 Rudolf Polzer (divVerent)
+Copyright (C) 2010-2020 Ashley Rose Hale (LadyHavoc)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+
#include "quakedef.h"
#include "crypto.h"
#include "common.h"
{
if(length_received >= 5 && Crypto_LittleLong((const char *) buffer) == FOURCC_D0ER)
{
- Con_Printf("Error response from keygen server: %.*s\n", (int)(length_received - 5), buffer + 5);
+ Con_Printf(CON_ERROR "Error response from keygen server: %.*s\n", (int)(length_received - 5), buffer + 5);
}
else
{
- Con_Printf("Invalid response from keygen server:\n");
+ Con_Printf(CON_ERROR "Invalid response from keygen server:\n");
Com_HexDumpToConsole(buffer, (int)length_received);
}
keygen_i = -1;
return CRYPTO_DISCARD;
}
-int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out, size_t *len_out, lhnetaddress_t *peeraddress)
+int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out, size_t *len_out, lhnetaddress_t *peeraddress, const char *peeraddressstring)
{
crypto_t *crypto = &cls.crypto;
const char *string = data_in;
// Must check the source IP here, if we want to prevent other servers' replies from falsely advancing the crypto state, preventing successful connect to the real server.
if (net_sourceaddresscheck.integer && LHNETADDRESS_Compare(peeraddress, &cls.connect_address))
- return Crypto_SoftClientError(data_out, len_out, "challenge message from wrong server");
+ {
+ char warn_msg[128];
+
+ dpsnprintf(warn_msg, sizeof(warn_msg), "ignoring challenge message from wrong server %s", peeraddressstring);
+ return Crypto_SoftClientError(data_out, len_out, warn_msg);
+ }
// if we have a stored host key for the server, assume serverid to already be selected!
// (the loop will refuse to overwrite this one then)
// Must check the source IP here, if we want to prevent other servers' replies from falsely advancing the crypto state, preventing successful connect to the real server.
if (net_sourceaddresscheck.integer && LHNETADDRESS_Compare(peeraddress, &cls.connect_address))
- return Crypto_SoftClientError(data_out, len_out, "d0pk\\ message from wrong server");
+ {
+ char warn_msg[128];
+
+ dpsnprintf(warn_msg, sizeof(warn_msg), "ignoring d0pk\\ message from wrong server %s", peeraddressstring);
+ return Crypto_SoftClientError(data_out, len_out, warn_msg);
+ }
cnt = InfoString_GetValue(string + 4, "id", infostringvalue, sizeof(infostringvalue));
id = (cnt ? atoi(cnt) : -1);