From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- tracker/AdminServer/cmdlist.cpp | 177 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 tracker/AdminServer/cmdlist.cpp (limited to 'tracker/AdminServer/cmdlist.cpp') diff --git a/tracker/AdminServer/cmdlist.cpp b/tracker/AdminServer/cmdlist.cpp new file mode 100644 index 0000000..b1d578c --- /dev/null +++ b/tracker/AdminServer/cmdlist.cpp @@ -0,0 +1,177 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: queries server for the command list, and then use QueryCommand() to see +// if the server supports this command. +// +// $NoKeywords: $ +//============================================================================= + +#include // isspace() define +#include + +#include "CMDList.h" +#include "Iresponse.h" + +#include "Socket.h" +#include "proto_oob.h" +#include "DialogGameInfo.h" +#include "inetapi.h" +#include "TokenLine.h" +#include "dialogkickplayer.h" + +extern void v_strncpy(char *dest, const char *src, int bufsize); + +typedef enum +{ + NONE = 0, + INFO_REQUESTED, + INFO_RECEIVED +} RCONSTATUS; + + +typedef enum +{ + FS, + PAK +} MAP_TYPES; + +CCMDList::CCMDList(IResponse *target,serveritem_t &server, const char *rconPassword) { + + memcpy(&m_Server, &server,sizeof(serveritem_t)); + + m_bGotCommands = false; + m_pResponseTarget=target; + + v_strncpy(m_szRconPassword,rconPassword,100); + + m_pRcon = new CRcon(this , server,rconPassword); + m_pRcon->SendRcon("cmdlist"); + m_CMDList.RemoveAll(); +} + +CCMDList::~CCMDList() { + delete m_pRcon; +} + + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CCMDList::RunFrame() +{ + if(m_pRcon) + { + m_pRcon->RunFrame(); + } +} + + +void CCMDList::ServerResponded() +{ + char store[2048]; + strcpy(store, m_pRcon->RconResponse()); + char *cur=store; + char *next=NULL; + char *cmd=NULL; + bool cmd_end=false; + +// response format: +//Command List +//-------------- +//_unloadmodule +// ... +// writeip +//-------------- +//125 Total Commands +//CmdList ? for syntax + + while(cur!=NULL) + { + if(next!=NULL) + { + cur++; + } + next=strchr(cur,'\n'); + if(next!=NULL) + { + *next='\0'; + } + if( strncmp(cur,"Command List",12) && strncmp(cur,"-------------",13) + && strncmp(cur,"Total Commands",14) && strncmp(cur,"CmdList ? for syntax",20) ) + { + char *removeWhiteSpace=cur; + while(!isspace(*removeWhiteSpace) && removeWhiteSpaceServerResponded(); + + } + +} + +void CCMDList::ServerFailedToRespond() +{ + //m_pResponseTarget->ServerFailedToRespond(); +} + + +serveritem_t &CCMDList::GetServer() +{ + return m_Server; +} + + +bool CCMDList::QueryCommand(char *cmd) +{ + if(!m_bGotCommands) + return false; + + + for(int i=0;iSetPassword(newPass); + m_bGotCommands = false; + m_CMDList.RemoveAll(); + + m_pRcon->SendRcon("cmdlist"); +} \ No newline at end of file -- cgit v1.2.3