-
Notifications
You must be signed in to change notification settings - Fork 3
/
banMgr.h
executable file
·48 lines (38 loc) · 915 Bytes
/
banMgr.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
//
// Created by origin on 31.07.16.
//
#ifndef NGINX_INSTABAN_BANMGR_H
#define NGINX_INSTABAN_BANMGR_H
#include "stdio.h"
#include "cstring"
#include <cstdio>
#include <iostream>
#include <queue>
#include <ctime>
#include <thread>
#include <mutex>
#include <unistd.h>
#include "strFuncs.h"
#include <string>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "CheckIpHashTable.h"
using namespace std;
class ConfigReader;
typedef pair<time_t, string> unbanRecord;
class BanMgr {
ConfigReader* owner;
mutex queueProtector;
void banCmdWrapper(const char* logStringIpPtr);
void unbanCmdWrapper(string& ip);
void UnbanThrFunc();
void StartUnbanThr();
public:
queue<unbanRecord> unbanQueue;
BanMgr(ConfigReader* _owner) : owner(_owner) {
StartUnbanThr();
}
void BanIp(const char* logStringIpPtr);
};
#endif //NGINX_INSTABAN_BANMGR_H