comparison src/syslogconfig.h @ 58:b45dddebe8fc

Add exponential increase in penalty for repeat offenders
author Carl Byington <carl@five-ten-sg.com>
date Tue, 10 Jun 2014 08:48:53 -0700
parents 206448c00b55
children 60f59936fabb
comparison
equal deleted inserted replaced
57:c95acc20f7ed 58:b45dddebe8fc
38 } 38 }
39 }; 39 };
40 40
41 struct bucket { 41 struct bucket {
42 int count; 42 int count;
43 bool latch; // true iff ever count>threshold 43 bool blocked; // true iff ever count>threshold
44 }; 44 };
45 45
46 typedef map<int, bucket, ltint> ip_buckets; 46 typedef map<int, bucket, ltint> ip_buckets;
47 47
48 class IPR { 48 class IPR {
49 int reference_count; // number of contexts using this recorder 49 int reference_count; // number of contexts using this recorder
50 int daily_timer; // track daily cycle to reduce repeat offenders penalties
50 ip_buckets violations; 51 ip_buckets violations;
52 ip_buckets repeat_offenders;
51 public: 53 public:
52 IPR(); 54 IPR();
53 int reference(int delta) {reference_count += delta; return reference_count;}; 55 int reference(int delta) {reference_count += delta; return reference_count;};
54 void add(int ip, int amount, CONTEXT &con, const char *file_name, int pattern_index, const char *message); 56 void add(int ip, int amount, CONTEXT &con, const char *file_name, int pattern_index, const char *message);
55 void leak(int amount, CONTEXT &con); 57 void leak(int amount, CONTEXT &con);
56 void free_all(CONTEXT &con); 58 void free_all(CONTEXT &con);
57 void update(int ip, bool added, const char *file_name, int pattern_index, const char *message); 59 void update(int ip, bool added, int scale, const char *file_name, int pattern_index, const char *message);
58 void changed(CONTEXT &con, int ip, bool added); 60 void changed(CONTEXT &con, int ip, bool added);
59 static IPR* find(const char* name); 61 static IPR* find(const char* name);
60 static void release(const char* name); 62 static void release(const char* name);
61 }; 63 };
62 64