blob: 9e9fe6ee1a07d90acfb0dcc64e2374c338db1158 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: defines a RCon class used to send rcon commands to remote servers
//
// $NoKeywords: $
//=============================================================================
#ifndef RCON_H
#define RCON_H
#ifdef _WIN32
#pragma once
#endif
#include "server.h"
#include "netadr.h"
class CSocket;
class IResponse;
typedef struct
{
char queued[1024];
} queue_requests_t;
class CRcon
{
public:
CRcon(IResponse *target,serveritem_t &server, const char *password);
~CRcon();
// resets the state of the object, will cause it to get the challenge id again
void Reset();
// send an rcon command to a server
void SendRcon(const char *cmd);
// does nothing
void Refresh();
bool IsRefreshing();
serveritem_t &GetServer();
void RunFrame();
// return the response from the server
const char *RconResponse();
// called when the message handler gets a packet back
void UpdateServer(netadr_t *adr, int challenge,const char *resp);
// returns the challenge id
bool Challenge();
// returns if a new rcon result is waiting
bool NewRcon();
// returns if the password failed
bool PasswordFail();
// called when a bad password is used
void BadPassword(const char *info);
// returns whether this rcon is disabled (due to bad passwords)
bool Disabled();
//set the password to use in the rcon request
void SetPassword(const char *newPass);
private:
// sends the actual request
void RconRequest(const char *command, int challenge);
// requests a challenge value from the server
void GetChallenge();
serveritem_t m_Server;
CSocket *m_pQuery; // Game server query socket
IResponse *m_pResponseTarget;
bool m_bIsRefreshing; // whether we are currently performing an rcon command
bool m_bChallenge; // whether we are currently GETTING a challenge id
bool m_bNewRcon; // whether an rcon response is waiting to be picked up
bool m_bPasswordFail; // whether the password failed
bool m_bDisable; // whether rcon is disabled due to password failures
bool m_bGotChallenge; // whether we have a valid challenge id stored away
CUtlVector<queue_requests_t> requests;
char m_sPassword[100];
char m_sCmd[1024];
char m_sRconResponse[2048];
int m_iChallenge;
float m_fQuerySendTime;
};
#endif // RCON_H
|