From ec1272dd1482e22cfbb57b40392f83ab790aed5e Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sun, 4 Aug 2019 11:26:26 +0200 Subject: [PATCH 1/8] remove join passwords --- src/command.c | 3 +- src/command.h | 3 +- src/d_clisrv.c | 284 ++++--------------------------------------------- src/d_clisrv.h | 27 +---- src/d_main.c | 7 +- src/d_net.c | 5 +- src/d_netcmd.c | 128 ---------------------- src/d_netcmd.h | 8 -- src/m_menu.c | 49 +-------- src/m_menu.h | 1 - 10 files changed, 36 insertions(+), 479 deletions(-) diff --git a/src/command.c b/src/command.c index 6d9c86d3e..5116b31cd 100644 --- a/src/command.c +++ b/src/command.c @@ -1307,8 +1307,7 @@ found: var->string = var->zstring = Z_StrDup(valstr); - if (var->flags & CV_PASSWORD); // Don't change value for password field - else if (override) + if (override) var->value = overrideval; else if (var->flags & CV_FLOAT) { diff --git a/src/command.h b/src/command.h index 6b5d513ef..559f2f14b 100644 --- a/src/command.h +++ b/src/command.h @@ -98,8 +98,7 @@ typedef enum CV_HIDEN = 1024, // variable is not part of the cvar list so cannot be accessed by the console // can only be set when we have the pointer to it // used on menus - CV_CHEAT = 2048, // Don't let this be used in multiplayer unless cheats are on. - CV_PASSWORD = 4096 // Password field + CV_CHEAT = 2048 // Don't let this be used in multiplayer unless cheats are on. } cvflags_t; typedef struct CV_PossibleValue_s diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 213f5dde0..565589324 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -23,7 +23,6 @@ #include "d_net.h" #include "d_netfil.h" // fileneedednum #include "d_main.h" -#include "d_event.h" #include "g_game.h" #include "hu_stuff.h" #include "keys.h" @@ -1101,23 +1100,14 @@ typedef enum #endif CL_CONNECTED, CL_ABORTED, - CL_ASKFULLFILELIST, - CL_ASKDOWNLOADFILES, - CL_WAITDOWNLOADFILESRESPONSE, - CL_CHALLENGE + CL_ASKFULLFILELIST // used when the server has more files than usual } cl_mode_t; static void GetPackets(void); static cl_mode_t cl_mode = CL_SEARCHING; -static boolean cl_needsdownload = false; -static UINT16 cl_lastcheckedfilecount = 0; -static UINT8 cl_challengenum = 0; -static UINT8 cl_challengequestion[MD5_LEN+1]; -static char cl_challengepassword[65]; -static UINT8 cl_challengeanswer[MD5_LEN+1]; -static UINT8 cl_challengeattempted = 0; +static UINT16 cl_lastcheckedfilecount = 0; // used for full file list // Player name send/load @@ -1154,7 +1144,6 @@ static void CV_LoadPlayerNames(UINT8 **p) } #ifdef CLIENT_LOADINGSCREEN -static UINT32 SL_SearchServer(INT32 node); // // CL_DrawConnectionStatus @@ -1179,42 +1168,11 @@ static inline void CL_DrawConnectionStatus(void) // 15 pal entries total. const char *cltext; - if (cl_mode != CL_CHALLENGE) - for (i = 0; i < 16; ++i) - V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15)); + for (i = 0; i < 16; ++i) + V_DrawFill((BASEVIDWIDTH/2-128) + (i * 16), BASEVIDHEIGHT-24, 16, 8, palstart + ((animtime - i) & 15)); switch (cl_mode) { - case CL_CHALLENGE: - { - char asterisks[33]; - size_t sl = min(32, strlen(cl_challengepassword)); - UINT32 serverid; - - memset(asterisks, '*', sl); - memset(asterisks+sl, 0, 33-sl); - - V_DrawString(BASEVIDWIDTH/2-128, BASEVIDHEIGHT-24, V_MONOSPACE|V_ALLOWLOWERCASE, asterisks); - V_DrawFixedPatch((BASEVIDWIDTH/2) << FRACBITS, (BASEVIDHEIGHT/2) << FRACBITS, FRACUNIT, 0, W_CachePatchName("BSRVLOCK", PU_CACHE), NULL); - - serverid = SL_SearchServer(servernode); - - if (serverid == UINT32_MAX) - { - M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT/2-8, 32, 1); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, V_REDMAP, M_GetText("This server is password protected.")); - } - else - { - M_DrawTextBox(BASEVIDWIDTH/2-128-8, BASEVIDHEIGHT/2-8, 32, 3); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2, V_REDMAP, M_GetText("This server,")); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2+8, V_ALLOWLOWERCASE, serverlist[serverid].info.servername); - V_DrawCenteredString(BASEVIDWIDTH/2, BASEVIDHEIGHT/2+16, V_REDMAP, M_GetText("is password protected.")); - } - - cltext = M_GetText(cl_challengeattempted ? "Incorrect password. Please try again." : "Please enter the server password."); - } - break; #ifdef JOININGAME case CL_DOWNLOADSAVEGAME: if (lastfilenum != -1) @@ -1237,9 +1195,6 @@ static inline void CL_DrawConnectionStatus(void) case CL_WAITJOINRESPONSE: cltext = M_GetText("Requesting to join..."); break; - case CL_ASKDOWNLOADFILES: - case CL_WAITDOWNLOADFILESRESPONSE: - cltext = M_GetText("Waiting to download files..."); default: cltext = M_GetText("Connecting to server..."); break; @@ -1325,9 +1280,6 @@ static boolean CL_SendJoin(void) netbuffer->u.clientcfg.localplayers = localplayers; netbuffer->u.clientcfg.version = VERSION; netbuffer->u.clientcfg.subversion = SUBVERSION; - netbuffer->u.clientcfg.needsdownload = cl_needsdownload; - netbuffer->u.clientcfg.challengenum = cl_challengenum; - memcpy(netbuffer->u.clientcfg.challengeanswer, cl_challengeanswer, MD5_LEN); return HSendPacket(servernode, true, 0, sizeof (clientconfig_pak)); } @@ -1351,10 +1303,10 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) netbuffer->u.serverinfo.kartvars = (UINT8) ( (cv_kartspeed.value & SV_SPEEDMASK) | - (dedicated ? SV_DEDICATED : 0) | - (D_IsJoinPasswordOn() ? SV_PASSWORD : 0) + (dedicated ? SV_DEDICATED : 0) ); + strncpy(netbuffer->u.serverinfo.servername, cv_servername.string, MAXSERVERNAME); strncpy(netbuffer->u.serverinfo.mapname, G_BuildMapName(gamemap), 7); @@ -1950,7 +1902,7 @@ static boolean CL_FinishedFileList(void) return false; } - cl_mode = CL_ASKDOWNLOADFILES; + cl_mode = CL_DOWNLOADFILES; } return true; } @@ -2090,7 +2042,6 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic /* FALLTHRU */ case CL_ASKJOIN: - cl_needsdownload = false; CL_LoadServerFiles(); #ifdef JOININGAME // prepare structures to save the file @@ -2099,23 +2050,9 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic CL_PrepareDownloadSaveGame(tmpsave); #endif if (CL_SendJoin()) - { - *asksent = I_GetTime(); cl_mode = CL_WAITJOINRESPONSE; - } break; - case CL_ASKDOWNLOADFILES: - cl_needsdownload = true; - - if (CL_SendJoin()) - { - *asksent = I_GetTime(); - cl_mode = CL_WAITDOWNLOADFILESRESPONSE; - } - break; - - #ifdef JOININGAME case CL_DOWNLOADSAVEGAME: // At this state, the first (and only) needed file is the gamestate @@ -2129,19 +2066,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic break; #endif - case CL_CHALLENGE: - (*asksent) = I_GetTime() - NEWTICRATE; // Send password immediately upon entering - break; - case CL_WAITJOINRESPONSE: - case CL_WAITDOWNLOADFILESRESPONSE: - if (*asksent + NEWTICRATE < I_GetTime() && CL_SendJoin()) - { - *asksent = I_GetTime(); - } - - break; - case CL_CONNECTED: default: break; @@ -2159,15 +2084,21 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic // Call it only once by tic if (*oldtic != I_GetTime()) { - I_OsPolling(); - D_ProcessEvents(); - if (gamestate != GS_WAITINGPLAYERS) - return false; - // why are these here? this is for servers, we're a client - //if (key == 's' && server) - // doomcom->numnodes = (INT16)pnumnodes; - //SV_FileSendTicker(); + INT32 key; + + I_OsPolling(); + key = I_GetKey(); + // Only ESC and non-keyboard keys abort connection + if (key == KEY_ESCAPE || key >= KEY_MOUSE1) + { + CONS_Printf(M_GetText("Network game synchronization aborted.\n")); + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + + return false; + } *oldtic = I_GetTime(); #ifdef CLIENT_LOADINGSCREEN @@ -2191,71 +2122,6 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic return true; } -boolean CL_Responder(event_t *ev) -{ - size_t len; - INT32 ch; - - if (!(client && cl_mode != CL_CONNECTED && cl_mode != CL_ABORTED)) - return false; // Don't do anything outside of the connection screen - - if (ev->type != ev_keydown) - return false; - - ch = (INT32)ev->data1; - - // Only ESC and non-keyboard keys abort connection - if (ch == KEY_ESCAPE || ch >= KEY_MOUSE1) - { - CONS_Printf(M_GetText("Network game synchronization aborted.\n")); - //M_StartMessage(M_GetText("Network game synchronization aborted.\n\nPress ESC\n"), NULL, MM_NOTHING); - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - return true; - } - - if (cl_mode != CL_CHALLENGE) - return false; - - if ((ch >= HU_FONTSTART && ch <= HU_FONTEND && hu_font[ch-HU_FONTSTART]) - || ch == ' ') // Allow spaces, of course - { - len = strlen(cl_challengepassword); - if (len < 64) - { - cl_challengepassword[len+1] = 0; - cl_challengepassword[len] = CON_ShiftChar(ch); - } - - cl_challengeattempted = 0; - } - else if (ch == KEY_BACKSPACE) - { - len = strlen(cl_challengepassword); - - if (len > 0) - cl_challengepassword[len-1] = 0; - - cl_challengeattempted = 0; - } - else if (ch == KEY_ENTER) - { - netgame = true; - multiplayer = true; - -#ifndef NONET - SL_ClearServerList(servernode); -#endif - cl_mode = CL_SEARCHING; - - D_ComputeChallengeAnswer(cl_challengequestion, cl_challengepassword, cl_challengeanswer); - cl_challengeattempted = 1; - } - - return true; -} - /** Use adaptive send using net_bandwidth and stat.sendbytes * * \param viams ??? @@ -2276,7 +2142,6 @@ static void CL_ConnectToServer(boolean viams) #endif cl_mode = CL_SEARCHING; - cl_challengenum = 0; #ifdef CLIENT_LOADINGSCREEN lastfilenum = -1; @@ -2331,8 +2196,6 @@ static void CL_ConnectToServer(boolean viams) SL_ClearServerList(servernode); #endif - cl_challengeattempted = 0; - do { // If the connection was aborted for some reason, leave @@ -3271,9 +3134,6 @@ void D_ClientServerInit(void) gametic = 0; localgametic = 0; - memset(cl_challengequestion, 0x00, MD5_LEN+1); - memset(cl_challengeanswer, 0x00, MD5_LEN+1); - // do not send anything before the real begin SV_StopServer(); SV_ResetServer(); @@ -3749,33 +3609,6 @@ static void HandleConnect(SINT8 node) boolean newnode = false; #endif - if (node != servernode && !nodeingame[node] && D_IsJoinPasswordOn()) - { - // Ensure node sent the correct password challenge - boolean passed = false; - - if (netbuffer->u.clientcfg.challengenum && D_VerifyJoinPasswordChallenge(netbuffer->u.clientcfg.challengenum, netbuffer->u.clientcfg.challengeanswer)) - passed = true; - - if (!passed) - { - D_MakeJoinPasswordChallenge(&netbuffer->u.joinchallenge.challengenum, netbuffer->u.joinchallenge.question); - - netbuffer->packettype = PT_JOINCHALLENGE; - HSendPacket(node, true, 0, sizeof(joinchallenge_pak)); - Net_CloseConnection(node); - - return; - } - } - - if (netbuffer->u.clientcfg.needsdownload) - { - netbuffer->packettype = PT_DOWNLOADFILESOKAY; - HSendPacket(node, true, 0, 0); - return; - } - // client authorised to join nodewaiting[node] = (UINT8)(netbuffer->u.clientcfg.localplayers - playerpernode[node]); if (!nodeingame[node]) @@ -3973,43 +3806,6 @@ static void HandlePacketFromAwayNode(SINT8 node) Net_CloseConnection(node); break; - case PT_JOINCHALLENGE: - if (server && serverrunning) - { // But wait I thought I'm the server? - Net_CloseConnection(node); - break; - } - SERVERONLY - if (cl_mode == CL_WAITJOINRESPONSE || cl_mode == CL_WAITDOWNLOADFILESRESPONSE) - { - cl_challengenum = netbuffer->u.joinchallenge.challengenum; - memcpy(cl_challengequestion, netbuffer->u.joinchallenge.question, 16); - - Net_CloseConnection(node|FORCECLOSE); // Don't need to stay connected while challenging - - cl_mode = CL_CHALLENGE; - - switch (cl_challengeattempted) - { - case 2: - // We already sent a correct password, so throw it back up again. - D_ComputeChallengeAnswer(cl_challengequestion, cl_challengepassword, cl_challengeanswer); - cl_mode = CL_ASKJOIN; - break; - - case 1: - // We entered the wrong password! - S_StartSound(NULL, sfx_s26d); - break; - - default: - // First entry to the password screen. - S_StartSound(NULL, sfx_s224); - break; - } - } - break; - case PT_SERVERREFUSE: // Negative response of client join request if (server && serverrunning) { // But wait I thought I'm the server? @@ -4038,41 +3834,6 @@ static void HandlePacketFromAwayNode(SINT8 node) } break; - case PT_DOWNLOADFILESOKAY: - if (server && serverrunning) - { // But wait I thought I'm the server? - Net_CloseConnection(node); - break; - } - - SERVERONLY - - // This should've already been checked, but just to be safe... - if (!CL_CheckDownloadable()) - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You cannot connect to this server\n" - "because you cannot download the files\n" - "that you are missing from the server.\n\n" - "See the console or log file for\n" - "more details.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - break; - } - - if (cl_challengeattempted == 1) // Successful password noise. - S_StartSound(NULL, sfx_s221); - - cl_challengeattempted = 2; - CONS_Printf("trying to download\n"); - if (CL_SendRequestFile()) - cl_mode = CL_DOWNLOADFILES; - break; - case PT_SERVERCFG: // Positive response of client join request { INT32 j; @@ -4088,9 +3849,6 @@ static void HandlePacketFromAwayNode(SINT8 node) if (cl_mode != CL_WAITJOINRESPONSE) break; - if (cl_challengeattempted == 1) // Successful password noise. - S_StartSound(NULL, sfx_s221); - if (client) { maketic = gametic = neededtic = (tic_t)LONG(netbuffer->u.servercfg.gametic); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index e961c38f7..6cbf93cac 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -13,14 +13,11 @@ #ifndef __D_CLISRV__ #define __D_CLISRV__ -#include "d_event.h" #include "d_ticcmd.h" #include "d_netcmd.h" #include "tables.h" #include "d_player.h" -#include "md5.h" - // Network play related stuff. // There is a data struct that stores network // communication related stuff, and another @@ -78,9 +75,6 @@ typedef enum PT_CLIENT4MIS, PT_BASICKEEPALIVE,// Keep the network alive during wipes, as tics aren't advanced and NetUpdate isn't called - PT_JOINCHALLENGE, // You must give a password to joinnnnn - PT_DOWNLOADFILESOKAY, // You can download files from the server.... - PT_CANFAIL, // This is kind of a priority. Anything bigger than CANFAIL // allows HSendPacket(*, true, *, *) to return false. // In addition, this packet can't occupy all the available slots. @@ -348,22 +342,13 @@ typedef struct { UINT8 version; // Different versions don't work UINT8 subversion; // Contains build version - UINT8 localplayers; - UINT8 needsdownload; - UINT8 challengenum; // Non-zero if trying to join with a password attempt - UINT8 challengeanswer[MD5_LEN]; // Join challenge + UINT8 localplayers; // number of splitscreen players + UINT8 mode; } ATTRPACK clientconfig_pak; -typedef struct -{ - UINT8 challengenum; // Number to send back in join attempt - UINT8 question[MD5_LEN]; // Challenge data to be manipulated and answered with -} ATTRPACK joinchallenge_pak; - -#define SV_SPEEDMASK 0x03 -#define SV_LOTSOFADDONS 0x20 -#define SV_DEDICATED 0x40 -#define SV_PASSWORD 0x80 +#define SV_SPEEDMASK 0x03 // used to send kartspeed +#define SV_DEDICATED 0x40 // server is dedicated +#define SV_LOTSOFADDONS 0x20 // flag used to ask for full file list in d_netfil #define MAXSERVERNAME 32 #define MAXFILENEEDED 915 @@ -465,7 +450,6 @@ typedef struct UINT8 textcmd[MAXTEXTCMD+1]; // 66049 bytes (wut??? 64k??? More like 257 bytes...) filetx_pak filetxpak; // 139 bytes clientconfig_pak clientcfg; // 153 bytes - joinchallenge_pak joinchallenge; // 17 bytes serverinfo_pak serverinfo; // 1024 bytes serverrefuse_pak serverrefuse; // 65025 bytes (somehow I feel like those values are garbage...) askinfo_pak askinfo; // 61 bytes @@ -571,7 +555,6 @@ void CL_Reset(void); void CL_ClearPlayer(INT32 playernum); void CL_RemovePlayer(INT32 playernum, INT32 reason); void CL_UpdateServerList(boolean internetsearch, INT32 room); -boolean CL_Responder(event_t *ev); // Is there a game running boolean Playing(void); diff --git a/src/d_main.c b/src/d_main.c index 467976c17..864e6ff05 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -233,9 +233,6 @@ void D_ProcessEvents(void) if (M_ScreenshotResponder(ev)) continue; // ate the event - if (CL_Responder(ev)) - continue; - if (gameaction == ga_nothing && gamestate == GS_TITLESCREEN) { if (cht_Responder(ev)) @@ -447,7 +444,7 @@ static void D_Display(void) { if (i > 0) // Splitscreen-specific { - switch (i) + switch (i) { case 1: if (splitscreen > 1) @@ -475,7 +472,7 @@ static void D_Display(void) break; } - + topleft = screens[0] + viewwindowy*vid.width + viewwindowx; } diff --git a/src/d_net.c b/src/d_net.c index 94b11d518..abb63e646 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -805,9 +805,6 @@ static const char *packettypename[NUMPACKETTYPE] = "CLIENT4MIS", "BASICKEEPALIVE", - "JOINCHALLENGE", - "DOWNLOADFILESOKAY", - "FILEFRAGMENT", "TEXTCMD", "TEXTCMD2", @@ -833,7 +830,7 @@ static void DebugPrintpacket(const char *header) break; case PT_CLIENTJOIN: fprintf(debugfile, " number %d mode %d\n", netbuffer->u.clientcfg.localplayers, - netbuffer->u.clientcfg.needsdownload); + netbuffer->u.clientcfg.mode); break; case PT_SERVERTICS: { diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 7dff12317..171a59e26 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -172,7 +172,6 @@ static void Got_Verification(UINT8 **cp, INT32 playernum); static void Got_Removal(UINT8 **cp, INT32 playernum); static void Command_Verify_f(void); static void Command_RemoveAdmin_f(void); -static void Command_ChangeJoinPassword_f(void); static void Command_MotD_f(void); static void Got_MotD_f(UINT8 **cp, INT32 playernum); @@ -554,8 +553,6 @@ void D_RegisterServerCommands(void) RegisterNetXCmd(XD_PICKVOTE, Got_PickVotecmd); // Remote Administration - CV_RegisterVar(&cv_dummyjoinpassword); - COM_AddCommand("joinpassword", Command_ChangeJoinPassword_f); COM_AddCommand("password", Command_Changepassword_f); RegisterNetXCmd(XD_LOGIN, Got_Login); COM_AddCommand("login", Command_Login_f); // useful in dedicated to kick off remote admin @@ -3956,131 +3953,6 @@ static void Got_Removal(UINT8 **cp, INT32 playernum) CONS_Printf(M_GetText("You are no longer a server administrator.\n")); } -// Join password stuff -consvar_t cv_dummyjoinpassword = {"dummyjoinpassword", "", CV_HIDEN|CV_NOSHOWHELP|CV_PASSWORD, NULL, NULL, 0, NULL, NULL, 0, 0, NULL}; - -#define NUMJOINCHALLENGES 32 -static UINT8 joinpassmd5[MD5_LEN+1]; -boolean joinpasswordset = false; -static UINT8 joinpasschallenges[NUMJOINCHALLENGES][MD5_LEN]; -static tic_t joinpasschallengeson[NUMJOINCHALLENGES]; - -boolean D_IsJoinPasswordOn(void) -{ - return joinpasswordset; -} - -static inline void GetChallengeAnswer(UINT8 *question, UINT8 *passwordmd5, UINT8 *answer) -{ - D_MD5PasswordPass(question, MD5_LEN, (char *) passwordmd5, answer); -} - -void D_ComputeChallengeAnswer(UINT8 *question, const char *pw, UINT8 *answer) -{ - static UINT8 passwordmd5[MD5_LEN+1]; - - memset(passwordmd5, 0x00, MD5_LEN+1); - D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &passwordmd5); - GetChallengeAnswer(question, passwordmd5, answer); -} - -void D_SetJoinPassword(const char *pw) -{ - memset(joinpassmd5, 0x00, MD5_LEN+1); - D_MD5PasswordPass((const UINT8 *)pw, strlen(pw), BASESALT, &joinpassmd5); - joinpasswordset = true; -} - -boolean D_VerifyJoinPasswordChallenge(UINT8 num, UINT8 *answer) -{ - boolean passed = false; - - num %= NUMJOINCHALLENGES; - - //@TODO use a constant-time memcmp.... - if (joinpasschallengeson[num] > 0 && memcmp(answer, joinpasschallenges[num], MD5_LEN) == 0) - passed = true; - - // Wipe and reset the challenge so that it can't be tried against again, as a small measure against brute-force attacks. - memset(joinpasschallenges[num], 0x00, MD5_LEN); - joinpasschallengeson[num] = 0; - - return passed; -} - -void D_MakeJoinPasswordChallenge(UINT8 *num, UINT8 *question) -{ - size_t i; - - for (i = 0; i < NUMJOINCHALLENGES; i++) - { - (*num) = M_RandomKey(NUMJOINCHALLENGES); - - if (joinpasschallengeson[(*num)] == 0) - break; - } - - if (joinpasschallengeson[(*num)] > 0) - { - // Ugh, all challenges are (probably) taken. Let's find the oldest one and overwrite it. - tic_t oldesttic = INT32_MAX; - - for (i = 0; i < NUMJOINCHALLENGES; i++) - { - if (joinpasschallengeson[i] < oldesttic) - { - (*num) = i; - oldesttic = joinpasschallengeson[i]; - } - } - } - - joinpasschallengeson[(*num)] = I_GetTime(); - - memset(question, 0x00, MD5_LEN); - for (i = 0; i < MD5_LEN; i++) - question[i] = M_RandomByte(); - - // Store the answer in memory. What was the question again? - GetChallengeAnswer(question, joinpassmd5, joinpasschallenges[(*num)]); - - // This ensures that num is always non-zero and will be valid when used for the answer - if ((*num) == 0) - (*num) = NUMJOINCHALLENGES; -} - -// Remote Administration -static void Command_ChangeJoinPassword_f(void) -{ -#ifdef NOMD5 - // If we have no MD5 support then completely disable XD_LOGIN responses for security. - CONS_Alert(CONS_NOTICE, "Remote administration commands are not supported in this build.\n"); -#else - if (client) // cannot change remotely - { - CONS_Printf(M_GetText("Only the server can use this.\n")); - return; - } - - if (COM_Argc() != 2) - { - CONS_Printf(M_GetText("joinpassword : set a password to join the server\nUse -remove to disable the password.\n")); - return; - } - - if (strcmp(COM_Argv(1), "-remove") == 0) - { - joinpasswordset = false; - CONS_Printf(M_GetText("Join password removed.\n")); - } - else - { - D_SetJoinPassword(COM_Argv(1)); - CONS_Printf(M_GetText("Join password set.\n")); - } -#endif -} - static void Command_MotD_f(void) { size_t i, j; diff --git a/src/d_netcmd.h b/src/d_netcmd.h index e6c327abf..2d8e5705a 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -246,14 +246,6 @@ void RemoveAdminPlayer(INT32 playernum); void ItemFinder_OnChange(void); void D_SetPassword(const char *pw); -extern consvar_t cv_dummyjoinpassword; -extern boolean joinpasswordset; -boolean D_IsJoinPasswordOn(void); -void D_ComputeChallengeAnswer(UINT8 *question, const char *pw, UINT8 *answer); -void D_SetJoinPassword(const char *pw); -boolean D_VerifyJoinPasswordChallenge(UINT8 num, UINT8 *answer); -void D_MakeJoinPasswordChallenge(UINT8 *num, UINT8 *question); - // used for the player setup menu UINT8 CanChangeSkin(INT32 playernum); diff --git a/src/m_menu.c b/src/m_menu.c index 97b1ce9b5..aff304759 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -984,10 +984,9 @@ static menuitem_t MP_MainMenu[] = static menuitem_t MP_ServerMenu[] = { - {IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 0}, - {IT_STRING|IT_CALL, NULL, "Room...", M_RoomMenu, 10}, - {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 20}, - {IT_STRING|IT_CVAR|IT_CV_PASSWORD, NULL, "Password", &cv_dummyjoinpassword, 44}, + {IT_STRING|IT_CVAR, NULL, "Max. Player Count", &cv_maxplayers, 10}, + {IT_STRING|IT_CALL, NULL, "Room...", M_RoomMenu, 20}, + {IT_STRING|IT_CVAR|IT_CV_STRING, NULL, "Server Name", &cv_servername, 30}, {IT_STRING|IT_CVAR, NULL, "Game Type", &cv_newgametype, 68}, {IT_STRING|IT_CVAR, NULL, "Level", &cv_nextmap, 78}, @@ -2464,9 +2463,6 @@ static void M_NextOpt(void) { INT16 oldItemOn = itemOn; // prevent infinite loop - if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD) - ((consvar_t *)currentMenu->menuitems[itemOn].itemaction)->value = 0; - do { if (itemOn + 1 > currentMenu->numitems - 1) @@ -2480,9 +2476,6 @@ static void M_PrevOpt(void) { INT16 oldItemOn = itemOn; // prevent infinite loop - if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD) - ((consvar_t *)currentMenu->menuitems[itemOn].itemaction)->value = 0; - do { if (!itemOn) @@ -2767,10 +2760,8 @@ boolean M_Responder(event_t *ev) // BP: one of the more big hack i have never made if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_CVAR) { - if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING || (currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD) + if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING) { - if (ch == KEY_TAB && (currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_PASSWORD) - ((consvar_t *)currentMenu->menuitems[itemOn].itemaction)->value ^= 1; if (shiftdown && ch >= 32 && ch <= 127) ch = shiftxform[ch]; @@ -3722,8 +3713,6 @@ static void M_DrawGenericMenu(void) case IT_CVAR: { consvar_t *cv = (consvar_t *)currentMenu->menuitems[i].itemaction; - char asterisks[MAXSTRINGLENGTH+1]; - size_t sl; switch (currentMenu->menuitems[i].status & IT_CVARTYPE) { case IT_CV_SLIDER: @@ -3731,27 +3720,6 @@ static void M_DrawGenericMenu(void) case IT_CV_NOPRINT: // color use this case IT_CV_INVISSLIDER: // monitor toggles use this break; - case IT_CV_PASSWORD: - if (i == itemOn) - { - V_DrawRightAlignedThinString(x + MAXSTRINGLENGTH*8 + 10, y, V_ALLOWLOWERCASE, va(M_GetText("Tab: %s password"), cv->value ? "hide" : "show")); - } - - if (!cv->value || i != itemOn) - { - sl = strlen(cv->string); - memset(asterisks, '*', sl); - memset(asterisks + sl, 0, MAXSTRINGLENGTH+1-sl); - - M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1); - V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, asterisks); - if (skullAnimCounter < 4 && i == itemOn) - V_DrawCharacter(x + 8 + V_StringWidth(asterisks, 0), y + 12, - '_' | 0x80, false); - y += 16; - break; - } - /* fallthru */ case IT_CV_STRING: M_DrawTextBox(x, y + 4, MAXSTRINGLENGTH, 1); V_DrawString(x + 8, y + 12, V_ALLOWLOWERCASE, cv->string); @@ -8312,6 +8280,7 @@ static void M_DrawConnectMenu(void) V_DrawSmallString(currentMenu->x+112, S_LINEY(i)+8, globalflags, gt); + // display game speed for race gametypes if (serverlist[slindex].info.gametype == GT_RACE) { spd = kartspeed_cons_t[serverlist[slindex].info.kartvars & SV_SPEEDMASK].strvalue; @@ -8319,9 +8288,6 @@ static void M_DrawConnectMenu(void) V_DrawSmallString(currentMenu->x+132, S_LINEY(i)+8, globalflags, va("(%s Speed)", spd)); } - if (serverlist[slindex].info.kartvars & SV_PASSWORD) - V_DrawFixedPatch((currentMenu->x - 9) << FRACBITS, (S_LINEY(i)) << FRACBITS, FRACUNIT, globalflags & (~V_ALLOWLOWERCASE), W_CachePatchName("SERVLOCK", PU_CACHE), NULL); - MP_ConnectMenu[i+FIRSTSERVERLINE].status = IT_STRING | IT_CALL; } @@ -8572,11 +8538,6 @@ static void M_StartServer(INT32 choice) // Still need to reset devmode cv_debug = 0; - if (strlen(cv_dummyjoinpassword.string) > 0) - D_SetJoinPassword(cv_dummyjoinpassword.string); - else - joinpasswordset = false; - if (demo.playback) G_StopDemo(); if (metalrecording) diff --git a/src/m_menu.h b/src/m_menu.h index 62c852e4d..d83a4e26f 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -107,7 +107,6 @@ boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt); #define IT_CV_NOPRINT 1536 #define IT_CV_NOMOD 2048 #define IT_CV_INVISSLIDER 2560 -#define IT_CV_PASSWORD 3072 //call/submenu specific // There used to be a lot more here but ... From e1e179d73b2f337e77565d7c04374de278a04e50 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Mon, 9 Sep 2019 22:26:09 +0200 Subject: [PATCH 2/8] I'm an idiot and forgot to let you download files --- src/d_clisrv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 565589324..ed49ce297 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1902,7 +1902,8 @@ static boolean CL_FinishedFileList(void) return false; } - cl_mode = CL_DOWNLOADFILES; + if (CL_SendRequestFile()) + cl_mode = CL_DOWNLOADFILES; } return true; } From 82b3649ad6bf3ef011d5e36ea636f5890a17bb3b Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Apr 2020 01:11:25 -0700 Subject: [PATCH 3/8] Revert "Request a download after completing the join challenge" This reverts commit 98478d6712b06746ca95277720b5c18876ea41d9. --- src/d_clisrv.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index ccbd21e1d..6d657dd99 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -4126,10 +4126,7 @@ static void HandlePacketFromAwayNode(SINT8 node) if (I_NetMakeNodewPort) servernode = I_NetMakeNode(cl_challengeaddress); #endif - if (cl_needsdownload) - cl_mode = CL_ASKDOWNLOADFILES; - else - cl_mode = CL_ASKJOIN; + cl_mode = CL_ASKJOIN; break; case 1: From de9a1568843daebe093c53212cadec2a9217a02a Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Apr 2020 01:12:39 -0700 Subject: [PATCH 4/8] Revert "Don't send httpsource in SERVERINFO if join password is set" This reverts commit ffd120f5974a644cb07b9c118401aa7c53a7d6ec. --- src/d_clisrv.c | 87 ++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 6d657dd99..440d029aa 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -1479,18 +1479,15 @@ static void SV_SendServerInfo(INT32 node, tic_t servertime) netbuffer->u.serverinfo.actnum = 0; //mapheaderinfo[gamemap-1]->actnum #ifdef HAVE_CURL - if (! D_IsJoinPasswordOn()) - { - mirror_length = strlen(httpurl); - if (mirror_length > MAX_MIRROR_LENGTH) - mirror_length = MAX_MIRROR_LENGTH; + mirror_length = strlen(httpurl); + if (mirror_length > MAX_MIRROR_LENGTH) + mirror_length = MAX_MIRROR_LENGTH; - if (snprintf(netbuffer->u.serverinfo.httpsource, mirror_length+1, "%s", httpurl) < 0) - // If there's an encoding error, send nothing, we accept that the above may be truncated - strncpy(netbuffer->u.serverinfo.httpsource, "", mirror_length); + if (snprintf(netbuffer->u.serverinfo.httpsource, mirror_length+1, "%s", httpurl) < 0) + // If there's an encoding error, send nothing, we accept that the above may be truncated + strncpy(netbuffer->u.serverinfo.httpsource, "", mirror_length); - netbuffer->u.serverinfo.httpsource[MAX_MIRROR_LENGTH-1] = '\0'; - } + netbuffer->u.serverinfo.httpsource[MAX_MIRROR_LENGTH-1] = '\0'; #endif p = PutFileNeeded(0); @@ -2062,6 +2059,16 @@ static boolean CL_ServerConnectionSearchTicker(boolean viams, tic_t *asksent) if (client) { +#ifdef HAVE_CURL + if (serverlist[i].info.httpsource[0]) + strncpy(http_source, serverlist[i].info.httpsource, MAX_MIRROR_LENGTH); + else + http_source[0] = '\0'; +#else + if (serverlist[i].info.httpsource[0]) + CONS_Printf("We received a http url from the server, however it will not be used as this build lacks curl support (%s)\n", serverlist[i].info.httpsource); +#endif + D_ParseFileneeded(serverlist[i].info.fileneedednum, serverlist[i].info.fileneeded, 0); if (serverlist[i].info.kartvars & SV_LOTSOFADDONS) { @@ -4179,52 +4186,40 @@ static void HandlePacketFromAwayNode(SINT8 node) SERVERONLY - if (netbuffer->u.filecfg.http_source[0] != '\0') - { - netbuffer->u.filecfg.http_source[MAX_MIRROR_LENGTH-1] = '\0'; - #ifdef HAVE_CURL - if (! curl_failedwebdownload) - { - strncpy(http_source, netbuffer->u.filecfg.http_source, - sizeof http_source); + if (! curl_failedwebdownload && + netbuffer->u.filecfg.http_source[0] != '\0' + ){ + strlcpy(http_source, netbuffer->u.filecfg.http_source, + MAX_MIRROR_LENGTH); - cl_mode = CL_PREPAREHTTPFILES; - } -#else - CONS_Printf("We received a http url from the server, however it will not be used as this build lacks curl support (%s)\n", netbuffer->u.filecfg.http_source); -#endif + cl_mode = CL_PREPAREHTTPFILES; } - - if (cl_mode == CL_WAITDOWNLOADFILESRESPONSE) + else +#endif + if (!CL_CheckDownloadable()) { - if (CL_CheckDownloadable()) - { - CONS_Printf("trying to download\n"); - if (CL_SendRequestFile()) - cl_mode = CL_DOWNLOADFILES; - } - else - { - D_QuitNetGame(); - CL_Reset(); - D_StartTitle(); - M_StartMessage(M_GetText( - "You cannot connect to this server\n" - "because you cannot download the files\n" - "that you are missing from the server.\n\n" - "See the console or log file for\n" - "more details.\n\n" - "Press ESC\n" - ), NULL, MM_NOTHING); - break; - } + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You cannot connect to this server\n" + "because you cannot download the files\n" + "that you are missing from the server.\n\n" + "See the console or log file for\n" + "more details.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + break; } if (cl_challengeattempted == 1) // Successful password noise. S_StartSound(NULL, sfx_s221); cl_challengeattempted = 2; + CONS_Printf("trying to download\n"); + if (cl_mode == CL_WAITDOWNLOADFILESRESPONSE && CL_SendRequestFile()) + cl_mode = CL_DOWNLOADFILES; break; case PT_SERVERCFG: // Positive response of client join request From 720e08c14db8b5c005a3259b7a59397b73234038 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Apr 2020 01:12:40 -0700 Subject: [PATCH 5/8] Revert "Reorder join process so password is authenticated before attempting to download" This reverts commit 7176aaf36ff032cb83d8c8863456b9ffeed333a7. --- src/d_clisrv.c | 58 ++++++++++++++++++++++++++++++++++---------------- src/d_clisrv.h | 6 ------ 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 440d029aa..4573174b4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2012,7 +2012,40 @@ static boolean CL_FinishedFileList(void) else if (i == 1) cl_mode = CL_ASKJOIN; else - cl_mode = CL_ASKDOWNLOADFILES; + { + // must download something + // can we, though? +#ifdef HAVE_CURL + if (http_source[0] == '\0' || curl_failedwebdownload) +#endif + { + if (!CL_CheckDownloadable()) // nope! + { + D_QuitNetGame(); + CL_Reset(); + D_StartTitle(); + M_StartMessage(M_GetText( + "You cannot connect to this server\n" + "because you cannot download the files\n" + "that you are missing from the server.\n\n" + "See the console or log file for\n" + "more details.\n\n" + "Press ESC\n" + ), NULL, MM_NOTHING); + return false; + } + + cl_mode = CL_ASKDOWNLOADFILES; + return true; + } +#ifdef HAVE_CURL + else + { + cl_mode = CL_PREPAREHTTPFILES; + return true; + } +#endif + } return true; } @@ -2147,9 +2180,10 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic #ifdef HAVE_CURL case CL_PREPAREHTTPFILES: + if (http_source[0]) { for (i = 0; i < fileneedednum; i++) - if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) + if (fileneeded[i].status == FS_NOTFOUND) curl_transfers++; cl_mode = CL_DOWNLOADHTTPFILES; @@ -2159,7 +2193,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic case CL_DOWNLOADHTTPFILES: waitmore = false; for (i = 0; i < fileneedednum; i++) - if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) + if (fileneeded[i].status == FS_NOTFOUND) { if (!curl_running) CURLPrepareFile(http_source, i); @@ -3901,9 +3935,7 @@ static void HandleConnect(SINT8 node) if (netbuffer->u.clientcfg.needsdownload) { netbuffer->packettype = PT_DOWNLOADFILESOKAY; - strncpy(netbuffer->u.filecfg.http_source, cv_httpsource.string, - MAX_MIRROR_LENGTH); - HSendPacket(node, true, 0, sizeof netbuffer->u.filecfg); + HSendPacket(node, true, 0, 0); return; } @@ -4186,17 +4218,7 @@ static void HandlePacketFromAwayNode(SINT8 node) SERVERONLY -#ifdef HAVE_CURL - if (! curl_failedwebdownload && - netbuffer->u.filecfg.http_source[0] != '\0' - ){ - strlcpy(http_source, netbuffer->u.filecfg.http_source, - MAX_MIRROR_LENGTH); - - cl_mode = CL_PREPAREHTTPFILES; - } - else -#endif + // This should've already been checked, but just to be safe... if (!CL_CheckDownloadable()) { D_QuitNetGame(); @@ -4218,7 +4240,7 @@ static void HandlePacketFromAwayNode(SINT8 node) cl_challengeattempted = 2; CONS_Printf("trying to download\n"); - if (cl_mode == CL_WAITDOWNLOADFILESRESPONSE && CL_SendRequestFile()) + if (CL_SendRequestFile()) cl_mode = CL_DOWNLOADFILES; break; diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 0f4ca3792..7fc36d25a 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -462,11 +462,6 @@ typedef struct UINT8 files[MAXFILENEEDED]; // is filled with writexxx (byteptr.h) } ATTRPACK filesneededconfig_pak; -typedef struct -{ - char http_source[MAX_MIRROR_LENGTH];/* first byte 0? no die! */ -} ATTRPACK fileconfig; - // // Network packet data // @@ -501,7 +496,6 @@ typedef struct plrconfig playerconfig[MAXPLAYERS]; // (up to) 528 bytes(?) INT32 filesneedednum; // 4 bytes filesneededconfig_pak filesneededcfg; // ??? bytes - fileconfig filecfg; UINT32 pingtable[MAXPLAYERS+1]; // 68 bytes } u; // This is needed to pack diff packet types data together } ATTRPACK doomdata_t; From f35bdf3bb79a6e5492ce6696c62df00fd08bb1c3 Mon Sep 17 00:00:00 2001 From: Wolfy Date: Mon, 13 Apr 2020 13:41:21 -0500 Subject: [PATCH 6/8] Revert basically every attempted join passwords fix --- src/d_clisrv.c | 37 ++------------------- src/d_net.c | 90 ++++++++++++-------------------------------------- src/i_tcp.c | 15 +-------- 3 files changed, 24 insertions(+), 118 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index cee7827ad..b0b23fc08 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -674,7 +674,7 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) static void resynch_read_player(resynch_pak *rsp) { INT32 i = rsp->playernum, j; - //mobj_t *savedmo = players[i].mo; + mobj_t *savedmo = players[i].mo; // Do not send anything visual related. // Only send data that we need to know for physics. @@ -767,17 +767,11 @@ static void resynch_read_player(resynch_pak *rsp) return; //...but keep old mo even if it is corrupt or null! - //players[i].mo = savedmo; + players[i].mo = savedmo; //Transfer important mo information if they have a valid mo. if (!rsp->hasmo) - { - // Get rid of their object if they aren't supposed to have one.....?? - if (players[i].mo) - P_RemoveMobj(players[i].mo); - return; - } //server thinks player has a body. //Give them a new body that can be then manipulated by the server's info. @@ -1030,7 +1024,6 @@ static void SV_SendResynch(INT32 node) return; } - resynch_inprogress[node] = false; // Let's see if there's REALLY anyone left to sync..... netbuffer->packettype = PT_RESYNCHING; for (i = 0, j = 0; i < MAXPLAYERS; ++i) { @@ -1038,24 +1031,10 @@ static void SV_SendResynch(INT32 node) if (!(resynch_status[node] & 1< TICRATE) - { - CONS_Alert(CONS_ERROR, "Node %d (%s) somehow had a stupidly-long resync delay?! (%d tics to resync player %d)\n", - node, player_names[nodetoplayer[node]], resynch_sent[node][i], i - ); - resynch_sent[node][i] = TICRATE; - } - continue; } @@ -1069,15 +1048,6 @@ static void SV_SendResynch(INT32 node) break; } - if (!resynch_inprogress[node]) - { - CONS_Alert(CONS_ERROR, "Node %d (%s) somehow had resync status for nonexistent players?! (%08x)\n", - node, player_names[nodetoplayer[node]], resynch_status[node] = 0x00 - ); - resynch_status[node] = 0x00; - resynch_inprogress[node] = true; // So they get the PT_RESYNCHEND... - } - if (resynch_score[node] > (unsigned)cv_resynchattempts.value*250) { XBOXSTATIC UINT8 buf[2]; @@ -2311,8 +2281,6 @@ static void CL_ConnectToServer(boolean viams) if (gamestate == GS_VOTING) Y_EndVote(); - resynch_local_inprogress = false; // Just in case this was never cleared... - DEBFILE(va("waiting %d nodes\n", doomcom->numnodes)); G_SetGamestate(GS_WAITINGPLAYERS); wipegamestate = GS_WAITINGPLAYERS; @@ -3411,7 +3379,6 @@ void D_QuitNetGame(void) HSendPacket(servernode, true, 0, 0); } - resynch_local_inprogress = false; // No more resyncing! D_CloseConnection(); ClearAdminPlayers(); diff --git a/src/d_net.c b/src/d_net.c index 6991fde12..3b1bad870 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -339,7 +339,6 @@ static boolean Processackpak(void) { UINT8 ack = netbuffer->ack; getackpacket++; - if (cmpack(ack, node->firstacktosend) <= 0) { DEBFILE(va("Discard(1) ack %d (duplicated)\n", ack)); @@ -362,7 +361,6 @@ static boolean Processackpak(void) // Is a good packet so increment the acknowledge number, // Then search for a "hole" in the queue UINT8 nextfirstack = (UINT8)(node->firstacktosend + 1); - if (!nextfirstack) nextfirstack = 1; @@ -781,8 +779,6 @@ static const char *packettypename[NUMPACKETTYPE] = { "NOTHING", "SERVERCFG", - - "CLIENTCMD", "CLIENTMIS", "CLIENT2CMD", @@ -803,9 +799,6 @@ static const char *packettypename[NUMPACKETTYPE] = "RESYNCHEND", "RESYNCHGET", - - - "CLIENT3CMD", "CLIENT3MIS", "CLIENT4CMD", @@ -813,20 +806,13 @@ static const char *packettypename[NUMPACKETTYPE] = "BASICKEEPALIVE", "FILEFRAGMENT", - "TEXTCMD", "TEXTCMD2", "TEXTCMD3", "TEXTCMD4", - "CLIENTJOIN", "NODETIMEOUT", "RESYNCHING", - - - "TELLFILESNEEDED", - "MOREFILESNEEDED", - "PING" }; @@ -1081,10 +1067,6 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen netbuffer->checksum = NetbufferChecksum(); sendbytes += packetheaderlength + doomcom->datalength; // For stat - // Joinpasswords close nodes, this may try to send to a waiting-to-close node, so cancel closing? - if (netbuffer->packettype == PT_CLIENTJOIN) - nodes[node].flags &= ~NF_CLOSE; - #ifdef PACKETDROP // Simulate internet :) //if (rand() >= (INT32)(RAND_MAX * (PACKETLOSSRATE / 100.f))) @@ -1121,7 +1103,7 @@ boolean HSendPacket(INT32 node, boolean reliable, UINT8 acknum, size_t packetlen // boolean HGetPacket(void) { - boolean nodejustjoined; + //boolean nodejustjoined; // Get a packet from self if (rebound_tail != rebound_head) @@ -1148,56 +1130,11 @@ boolean HGetPacket(void) while(true) { - nodejustjoined = I_NetGet(); - //I_NetGet(); + //nodejustjoined = I_NetGet(); + I_NetGet(); if (doomcom->remotenode == -1) // No packet received - { - if (nodejustjoined) // _This_ means we did receive a packet, but either from a node we couldn't allocate or a gone player ackreting... - continue; - else - return false; - } - - if (nodejustjoined) - { - // If a new node sends an unexpected packet, just ignore it - if (server - && !(netbuffer->packettype == PT_ASKINFO - || netbuffer->packettype == PT_SERVERINFO - || netbuffer->packettype == PT_PLAYERINFO - || netbuffer->packettype == PT_REQUESTFILE - || netbuffer->packettype == PT_ASKINFOVIAMS - || netbuffer->packettype == PT_CLIENTJOIN - || netbuffer->packettype == PT_TELLFILESNEEDED - || netbuffer->packettype == PT_CLIENTCMD)) - { - DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype])); - CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]); - Net_CloseConnection(doomcom->remotenode | FORCECLOSE); - continue; - } - - // UGLY PROBABLY-BAD HACK: If we get PT_CLIENTJOIN, assume this is an in-order packet? - if (netbuffer->packettype == PT_CLIENTJOIN) - nodes[doomcom->remotenode].firstacktosend = (UINT8)((netbuffer->ack-1+MAXACKTOSEND) % MAXACKTOSEND); - - if (netbuffer->ack > 1 && !(server && netbuffer->packettype == PT_CLIENTJOIN)) - { - DEBFILE("New node sent a packet with an out-of-sequence ack. Ghost connection? Ignoring...\n"); - CONS_Alert(CONS_NOTICE, "New node sent a packet with an out-of-sequence ack. Ghost connection? Ignoring...\n"); - Net_CloseConnection(doomcom->remotenode | FORCECLOSE); - continue; - } - - // Reinitialize vars for the new node just in case there's anything left over from other players..... - InitNode(&nodes[doomcom->remotenode]); - SV_AbortSendFiles(doomcom->remotenode); - } - - // Joinpasswords close nodes, this may receive from a waiting-to-close node, so cancel closing? - if (netbuffer->packettype == PT_CLIENTJOIN) - nodes[doomcom->remotenode].flags &= ~NF_CLOSE; + return false; getbytes += packetheaderlength + doomcom->datalength; // For stat @@ -1212,8 +1149,8 @@ boolean HGetPacket(void) if (netbuffer->checksum != NetbufferChecksum()) { DEBFILE("Bad packet checksum\n"); - Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode); - //Net_CloseConnection(doomcom->remotenode); + //Net_CloseConnection(nodejustjoined ? (doomcom->remotenode | FORCECLOSE) : doomcom->remotenode); + Net_CloseConnection(doomcom->remotenode); continue; } @@ -1222,6 +1159,21 @@ boolean HGetPacket(void) DebugPrintpacket("GET"); #endif + /*// If a new node sends an unexpected packet, just ignore it + if (nodejustjoined && server + && !(netbuffer->packettype == PT_ASKINFO + || netbuffer->packettype == PT_SERVERINFO + || netbuffer->packettype == PT_PLAYERINFO + || netbuffer->packettype == PT_REQUESTFILE + || netbuffer->packettype == PT_ASKINFOVIAMS + || netbuffer->packettype == PT_CLIENTJOIN)) + { + DEBFILE(va("New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype])); + //CONS_Alert(CONS_NOTICE, "New node sent an unexpected %s packet\n", packettypename[netbuffer->packettype]); + Net_CloseConnection(doomcom->remotenode | FORCECLOSE); + continue; + }*/ + // Proceed the ack and ackreturn field if (!Processackpak()) continue; // discarded (duplicated) diff --git a/src/i_tcp.c b/src/i_tcp.c index 7de94573d..f58aa22bc 100644 --- a/src/i_tcp.c +++ b/src/i_tcp.c @@ -508,8 +508,6 @@ static boolean SOCK_cmpaddr(mysockaddr_t *a, mysockaddr_t *b, UINT8 mask) return false; } -static void SOCK_FreeNodenum(INT32 numnode); - // This is a hack. For some reason, nodes aren't being freed properly. // This goes through and cleans up what nodes were supposed to be freed. /** \warning This function causes the file downloading to stop if someone joins. @@ -526,7 +524,7 @@ static void cleanupnodes(void) // Why can't I start at zero? for (j = 1; j < MAXNETNODES; j++) if (!(nodeingame[j] || SV_SendingFile(j))) - SOCK_FreeNodenum(j); // At least free this PROPERLY + nodeconnected[j] = false; } static SINT8 getfreenode(void) @@ -626,13 +624,6 @@ static boolean SOCK_Get(void) } // not found - if (netbuffer->packettype == PT_NOTHING) - { - DEBFILE(va("Ackret received from disconnected address:%s, ignoring...\n", SOCK_AddrToStr(&fromaddress))); - doomcom->remotenode = -1; // no packet - return true; - } - // find a free slot j = getfreenode(); if (j > 0) @@ -659,11 +650,7 @@ static boolean SOCK_Get(void) return true; } else - { DEBFILE("New node detected: No more free slots\n"); - doomcom->remotenode = -1; // no packet - return true; - } } } From 9640cb1635b4efc570bddc2a0cfb275126813121 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Apr 2020 01:28:01 -0700 Subject: [PATCH 7/8] Fallback you doofus! --- src/d_clisrv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index b0b23fc08..85443905c 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2132,8 +2132,11 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (curl_failedwebdownload && !curl_transfers) { CONS_Printf("One or more files failed to download, falling back to internal downloader\n"); - cl_mode = CL_ASKDOWNLOADFILES; - break; + if (CL_SendRequestFile()) + { + cl_mode = CL_DOWNLOADFILES; + break; + } } if (!curl_transfers) From 908013f02ea45377144a10300cfa46ad38cf80e0 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 26 Apr 2020 01:29:40 -0700 Subject: [PATCH 8/8] Download mismatched md5sum with http This is from 7176aaf3 --- src/d_clisrv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 85443905c..39432d1a7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2105,7 +2105,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic if (http_source[0]) { for (i = 0; i < fileneedednum; i++) - if (fileneeded[i].status == FS_NOTFOUND) + if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) curl_transfers++; cl_mode = CL_DOWNLOADHTTPFILES; @@ -2115,7 +2115,7 @@ static boolean CL_ServerConnectionTicker(boolean viams, const char *tmpsave, tic case CL_DOWNLOADHTTPFILES: waitmore = false; for (i = 0; i < fileneedednum; i++) - if (fileneeded[i].status == FS_NOTFOUND) + if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD) { if (!curl_running) CURLPrepareFile(http_source, i);