| 1 |
/* chanfix - channel fixing service |
| 2 |
* Copyright (c) 2010 Atheme Development Group |
| 3 |
*/ |
| 4 |
|
| 5 |
#ifndef __CHANFIX_H__ |
| 6 |
#define __CHANFIX_H__ |
| 7 |
|
| 8 |
#define CHANFIX_OP_THRESHHOLD 3 |
| 9 |
#define CHANFIX_ACCOUNT_WEIGHT 1.5 |
| 10 |
#define CHANFIX_MIN_FIX_SCORE 12 |
| 11 |
|
| 12 |
#define CHANFIX_INITIAL_STEP 0.70f |
| 13 |
#define CHANFIX_FINAL_STEP 0.30f |
| 14 |
|
| 15 |
#define CHANFIX_RETENTION_TIME (86400 * 28) |
| 16 |
#define CHANFIX_FIX_TIME (60 * 60) |
| 17 |
#define CHANFIX_GATHER_INTERVAL 300 |
| 18 |
#define CHANFIX_EXPIRE_INTERVAL 3600 |
| 19 |
|
| 20 |
/* This value has been chosen such that the maximum score is about 8064, |
| 21 |
* which is the number of CHANFIX_GATHER_INTERVALs in CHANFIX_RETENTION_TIME. |
| 22 |
* Higher scores would decay more than they can gain (12 per hour). |
| 23 |
*/ |
| 24 |
#define CHANFIX_EXPIRE_DIVISOR 672 |
| 25 |
|
| 26 |
typedef struct chanfix_channel { |
| 27 |
object_t parent; |
| 28 |
|
| 29 |
char *name; |
| 30 |
|
| 31 |
mowgli_list_t oprecords; |
| 32 |
time_t ts; |
| 33 |
time_t lastupdate; |
| 34 |
|
| 35 |
channel_t *chan; |
| 36 |
|
| 37 |
time_t fix_started; |
| 38 |
bool fix_requested; |
| 39 |
} chanfix_channel_t; |
| 40 |
|
| 41 |
typedef struct chanfix_oprecord { |
| 42 |
mowgli_node_t node; |
| 43 |
|
| 44 |
chanfix_channel_t *chan; |
| 45 |
|
| 46 |
myentity_t *entity; |
| 47 |
|
| 48 |
char user[USERLEN]; |
| 49 |
char host[HOSTLEN]; |
| 50 |
|
| 51 |
time_t firstseen; |
| 52 |
time_t lastevent; |
| 53 |
unsigned int age; |
| 54 |
} chanfix_oprecord_t; |
| 55 |
|
| 56 |
typedef struct chanfix_persist { |
| 57 |
int version; |
| 58 |
|
| 59 |
mowgli_heap_t *chanfix_channel_heap; |
| 60 |
mowgli_heap_t *chanfix_oprecord_heap; |
| 61 |
|
| 62 |
mowgli_patricia_t *chanfix_channels; |
| 63 |
} chanfix_persist_record_t; |
| 64 |
|
| 65 |
E service_t *chanfix; |
| 66 |
E mowgli_patricia_t *chanfix_channels; |
| 67 |
|
| 68 |
E void chanfix_gather_init(chanfix_persist_record_t *); |
| 69 |
E void chanfix_gather_deinit(module_unload_intent_t, chanfix_persist_record_t *); |
| 70 |
|
| 71 |
E void chanfix_oprecord_update(chanfix_channel_t *chan, user_t *u); |
| 72 |
E void chanfix_oprecord_delete(chanfix_oprecord_t *orec); |
| 73 |
E chanfix_oprecord_t *chanfix_oprecord_create(chanfix_channel_t *chan, user_t *u); |
| 74 |
E chanfix_oprecord_t *chanfix_oprecord_find(chanfix_channel_t *chan, user_t *u); |
| 75 |
E chanfix_channel_t *chanfix_channel_create(const char *name, channel_t *chan); |
| 76 |
E chanfix_channel_t *chanfix_channel_find(const char *name); |
| 77 |
E chanfix_channel_t *chanfix_channel_get(channel_t *chan); |
| 78 |
E void chanfix_gather(void *unused); |
| 79 |
E void chanfix_expire(void *unused); |
| 80 |
|
| 81 |
E bool chanfix_do_autofix; |
| 82 |
E void chanfix_autofix_ev(void *unused); |
| 83 |
E void chanfix_can_register(hook_channel_register_check_t *req); |
| 84 |
|
| 85 |
E command_t cmd_chanfix; |
| 86 |
E command_t cmd_scores; |
| 87 |
E command_t cmd_info; |
| 88 |
E command_t cmd_help; |
| 89 |
E command_t cmd_mark; |
| 90 |
|
| 91 |
#endif |