-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathServerThread.h
executable file
·70 lines (50 loc) · 1.33 KB
/
ServerThread.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
//
//---------------------------------------------------------------------------
#ifndef ServerThreadH
#define ServerThreadH
//---------------------------------------------------------------------------
class ServerThread {
private:
struct AntiConFlood {
uint8_t ui128IpHash[16];
uint64_t Time;
AntiConFlood *prev, *next;
int16_t hits;
};
#ifdef _WIN32
SOCKET server;
unsigned int threadId;
uint32_t iSuspendTime;
HANDLE threadHandle;
CRITICAL_SECTION csServerThread;
#else
int server;
unsigned int iSuspendTime;
pthread_t threadId;
pthread_mutex_t mtxServerThread;
#endif
AntiConFlood *AntiFloodList;
int iAdressFamily;
bool bTerminated;
public:
ServerThread *prev, *next;
uint16_t ui16Port;
bool bActive, bSuspended;
ServerThread(const int &iAddrFamily, const uint16_t &ui16PortNumber);
~ServerThread();
void Resume();
void Run();
void Close();
void WaitFor();
bool Listen(bool bSilent = false);
#ifdef _WIN32
bool isFlooder(const SOCKET &s, const sockaddr_storage &addr);
#else
bool isFlooder(const int &s, const sockaddr_storage &addr);
#endif
void RemoveConFlood(AntiConFlood * cur);
void ResumeSck();
void SuspendSck(const uint32_t &iTime);
};
//---------------------------------------------------------------------------
#endif