-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannel.hpp
More file actions
86 lines (61 loc) · 2.02 KB
/
channel.hpp
File metadata and controls
86 lines (61 loc) · 2.02 KB
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
//***************************************************************************
// File channel.hpp
// Date 23.07.17 - #1
// Copyright (c) 2017-2017 s710 (s710 (at) posteo (dot) de). All rights reserved.
// --------------------------------------------------------------------------
// Ark ClusterChat / RCON protocol implementation
//***************************************************************************
#ifndef __CHANNEL_HPP__
#define __CHANNEL_HPP__
#include "def.h"
#define RC_PID 42
#define RC_COMMAND 2
#define RC_AUTH_RESPONSE 2
#define RC_AUTHENTICATE 3
#define BUFFSIZE_DEF 10240
#define BUFFSIZE_MAX 1024*1024*10
//***************************************************************************
// struct RConPacket
//***************************************************************************
class RConPacket
{
public:
RConPacket();
~RConPacket();
int size;
int id;
int cmd;
char* data;
void clear();
int resize(int newSize);
char* getBuffer() { return data; }
int getSize() { return packetSize; }
protected:
int packetSize;
};
//***************************************************************************
// class RConChannel
//***************************************************************************
class RConChannel
{
public:
RConChannel();
~RConChannel();
int connect(const char* host, int port, const char* pass);
int disconnect();
int sendCommand(const char* command);
char* getBuffer() { return thePacket.getBuffer(); }
protected:
int rsock; /* rcon socket */
RConPacket thePacket;
protected:
// tcp/protocol functions
int send(int id, int cmd, const char* commandString);
int _send(char* buffer, int len);
int receive();
int _receive(char* buffer, int bufSize, int len= na);
int authenticate(const char *passwd);
int flushLine();
};
//***************************************************************************
#endif // __CHANNEL_HPP__