/
CServerManager.h
77 lines (64 loc) · 1.48 KB
/
CServerManager.h
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
#pragma once
#include <stdint.h>
#include "str_obfuscator_no_template.hpp"
#define MAX_SERVERS 31
class CServerInstance
{
public:
class CServerInstanceEncrypted
{
public:
constexpr CServerInstanceEncrypted(const char* str, size_t len, int sum, int port, int isVoice) :
_buffer{}, _decrypted{ false }, _key{ static_cast<const char>(len % 255) }, _length{ len }, _sum{ sum }, _port{ port }, _isVoice{ isVoice }
{
detail::encryptor::encrypt(_buffer, str, _length, _key);
}
#ifdef _WIN32
__declspec(noinline)
#elif __GNUC__
__attribute__((noinline))
#endif
const char* decrypt() const {
if (_decrypted) {
return _buffer;
}
for (size_t i = 0; i < _length; i++) {
_buffer[i] ^= _key;
}
_decrypted = true;
return _buffer;
}
char getKey() const {
return _key;
}
const char* getBuffer() const {
return _buffer;
}
int getSum() const
{
return _sum;
}
int isVoice() const
{
return _isVoice;
}
int getPort() const
{
return _port;
}
private:
mutable char _buffer[31];
mutable bool _decrypted;
const char _key;
size_t _length;
int _sum;
int _isVoice;
int _port;
};
static constexpr auto create(const char* str, int sum, size_t len, int port, int isVoice) {
return CServerInstanceEncrypted(str, len, sum, port, isVoice);
}
};
#define NUM_TO_STR_IP(a1, a2, a3, a4) \
#a1 "." #a2 "." #a3 "." #a4, a1 + a2 + a3 + a4
extern const CServerInstance::CServerInstanceEncrypted g_sEncryptedAddresses[MAX_SERVERS];