]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - crypto.c
client: improve server connection status messages
[xonotic/darkplaces.git] / crypto.c
index 72fcd2d317aabe1dfe4433304226c650ccbd2e2e..d910e4919f3033391a26205c63500abfeb631378 100644 (file)
--- a/crypto.c
+++ b/crypto.c
@@ -1,3 +1,24 @@
+/*
+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"
@@ -1120,11 +1141,11 @@ static void Crypto_KeyGen_Finished(int code, size_t length_received, unsigned ch
        {
                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;
@@ -2085,7 +2106,7 @@ static int Crypto_SoftClientError(char *data_out, size_t *len_out, const char *m
        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;
@@ -2193,7 +2214,12 @@ int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out,
 
                // 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)
@@ -2401,7 +2427,12 @@ int Crypto_ClientParsePacket(const char *data_in, size_t len_in, char *data_out,
 
                // 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);