0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-26 15:33:54 +01:00

reject functions from ratbox3

This commit is contained in:
Valery Yatsko 2008-04-02 14:41:37 +04:00
parent c11029da8a
commit 7ee5e8a5fe
3 changed files with 16 additions and 26 deletions

View file

@ -31,6 +31,9 @@
extern rb_dlink_list delay_exit;
struct ConfItem *find_dline(struct sockaddr *addr);
struct ConfItem *find_dline_exact(struct sockaddr *addr, unsigned int bitlen);
void init_reject(void);
int check_reject(struct Client *);
void add_reject(struct Client *, const char *mask1, const char *mask2);

View file

@ -416,21 +416,6 @@ find_address_conf(const char *host, const char *sockhost, const char *user,
return iconf;
}
/* struct ConfItem* find_dline(struct rb_sockaddr_storage*, int)
* Input: An address, an address family.
* Output: The best matching D-line or exempt line.
* Side effects: None.
*/
struct ConfItem *
find_dline(struct sockaddr *addr, int aftype)
{
struct ConfItem *eline;
eline = find_conf_by_address(NULL, NULL, NULL, addr, CONF_EXEMPTDLINE | 1, aftype, NULL);
if(eline)
return eline;
return find_conf_by_address(NULL, NULL, NULL, addr, CONF_DLINE | 1, aftype, NULL);
}
/* void find_exact_conf_by_address(const char*, int, const char *)
* Input:
* Output: ConfItem if found

View file

@ -28,6 +28,8 @@
#include "patricia.h"
#include "client.h"
#include "s_conf.h"
#include "event.h"
#include "rb_tools.h"
#include "reject.h"
#include "s_stats.h"
#include "msg.h"
@ -98,11 +100,11 @@ reject_expires(void *unused)
pnode = ptr->data;
rdata = pnode->data;
if(rdata->time + ConfigFileEntry.reject_duration > rb_current_time())
if(rdata->time + ConfigFileEntry.reject_duration > CurrentTime)
continue;
rb_dlinkDelete(ptr, &reject_list);
rb_free(rdata);
MyFree(rdata);
patricia_remove(reject_tree, pnode);
}
}
@ -112,8 +114,8 @@ init_reject(void)
{
reject_tree = New_Patricia(PATRICIA_BITS);
unknown_tree = New_Patricia(PATRICIA_BITS);
rb_event_add("reject_exit", reject_exit, NULL, DELAYED_EXIT_TIME);
rb_event_add("reject_expires", reject_expires, NULL, 60);
eventAdd("reject_exit", reject_exit, NULL, DELAYED_EXIT_TIME);
eventAdd("reject_expires", reject_expires, NULL, 60);
}
@ -137,7 +139,7 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2)
if((pnode = match_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip)) != NULL)
{
rdata = pnode->data;
rdata->time = rb_current_time();
rdata->time = CurrentTime;
rdata->count++;
}
else
@ -148,9 +150,9 @@ add_reject(struct Client *client_p, const char *mask1, const char *mask2)
bitlen = 128;
#endif
pnode = make_and_lookup_ip(reject_tree, (struct sockaddr *)&client_p->localClient->ip, bitlen);
pnode->data = rdata = rb_malloc(sizeof(struct reject_data));
pnode->data = rdata = MyMalloc(sizeof(struct reject_data));
rb_dlinkAddTail(pnode, &rdata->rnode, &reject_list);
rdata->time = rb_current_time();
rdata->time = CurrentTime;
rdata->count = 1;
}
rdata->mask_hashv = hashv;
@ -172,7 +174,7 @@ check_reject(struct Client *client_p)
{
rdata = pnode->data;
rdata->time = rb_current_time();
rdata->time = CurrentTime;
if(rdata->count > ConfigFileEntry.reject_after_count)
{
ServerStats->is_rej++;
@ -199,7 +201,7 @@ flush_reject(void)
pnode = ptr->data;
rdata = pnode->data;
rb_dlinkDelete(ptr, &reject_list);
rb_free(rdata);
MyFree(rdata);
patricia_remove(reject_tree, pnode);
}
}
@ -218,7 +220,7 @@ remove_reject_ip(const char *ip)
{
struct reject_data *rdata = pnode->data;
rb_dlinkDelete(&rdata->rnode, &reject_list);
rb_free(rdata);
MyFree(rdata);
patricia_remove(reject_tree, pnode);
return 1;
}
@ -246,7 +248,7 @@ remove_reject_mask(const char *mask1, const char *mask2)
if (rdata->mask_hashv == hashv)
{
rb_dlinkDelete(ptr, &reject_list);
rb_free(rdata);
MyFree(rdata);
patricia_remove(reject_tree, pnode);
n++;
}