diff options
Diffstat (limited to 'modules/m_kline.c')
-rw-r--r-- | modules/m_kline.c | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/modules/m_kline.c b/modules/m_kline.c index 28ce68b..56c2de3 100644 --- a/modules/m_kline.c +++ b/modules/m_kline.c @@ -47,6 +47,41 @@ #include "memory.h" +static void +check_kline(struct AddressRec *arec) +{ + dlink_node *ptr = NULL, *ptr_next = NULL; + + DLINK_FOREACH_SAFE(ptr, ptr_next, local_client_list.head) + { + struct Client *client_p = ptr->data; + + if (IsDead(client_p)) + continue; + + if (match(arec->username, client_p->username)) + continue; + + switch (arec->masktype) + { + case HM_IPV4: + if (client_p->localClient->aftype == AF_INET) + if (match_ipv4(&client_p->localClient->ip, &arec->Mask.ipa.addr, arec->Mask.ipa.bits)) + conf_try_ban(client_p, arec->conf); + break; + case HM_IPV6: + if (client_p->localClient->aftype == AF_INET6) + if (match_ipv6(&client_p->localClient->ip, &arec->Mask.ipa.addr, arec->Mask.ipa.bits)) + conf_try_ban(client_p, arec->conf); + break; + default: /* HM_HOST */ + if (!match(arec->Mask.hostname, client_p->host)) + conf_try_ban(client_p, arec->conf); + break; + } + } +} + /* apply_tkline() * * inputs - @@ -88,8 +123,7 @@ m_kline_add_kline(struct Client *source_p, struct MaskItem *conf, conf->setat = CurrentTime; SetConfDatabase(conf); - add_conf_by_address(CONF_KLINE, conf); - rehashed_klines = 1; + check_kline(add_conf_by_address(CONF_KLINE, conf)); } /* static int remove_tkline_match(const char *host, const char *user) |