summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-11-01 21:08:56 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-11-01 21:08:56 +0000
commit8d6a1a7177ccbb822872fa5a758f5c5c948cec2e (patch)
treeccdc6f8902dd64d6da0e7441d0312a45697e420c /modules
parent5f1a24388ef9e957923bfd57711dd7448abb824b (diff)
- flesh out new *line database handling
- simplify temporary bans git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1628 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'modules')
-rw-r--r--modules/m_dline.c32
-rw-r--r--modules/m_gline.c9
-rw-r--r--modules/m_kline.c43
-rw-r--r--modules/m_resv.c14
-rw-r--r--modules/m_stats.c13
-rw-r--r--modules/m_testline.c8
-rw-r--r--modules/m_xline.c7
7 files changed, 45 insertions, 81 deletions
diff --git a/modules/m_dline.c b/modules/m_dline.c
index a4396e9..f66917c 100644
--- a/modules/m_dline.c
+++ b/modules/m_dline.c
@@ -57,7 +57,6 @@ apply_dline(struct Client *source_p, struct AccessItem *aconf,
if (tkline_time)
{
aconf->hold = CurrentTime + tkline_time;
- SetConfTemporary(aconf);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s added temporary %d min. D-Line for [%s] [%s]",
get_oper_name(source_p), tkline_time/60,
@@ -81,6 +80,7 @@ apply_dline(struct Client *source_p, struct AccessItem *aconf,
}
+ SetConfDatabase(aconf);
aconf->setat = CurrentTime;
add_conf_by_address(CONF_DLINE, aconf);
rehashed_klines = 1;
@@ -116,7 +116,7 @@ remove_dline_match(const char *host)
if ((aconf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
{
- if (!IsConfMain(aconf))
+ if (IsConfDatabase(aconf))
{
delete_one_address_conf(host, aconf);
return 1;
@@ -146,7 +146,6 @@ mo_dline(struct Client *client_p, struct Client *source_p,
const char *creason;
const struct Client *target_p = NULL;
struct irc_ssaddr daddr;
- struct ConfItem *conf=NULL;
struct AccessItem *aconf=NULL;
time_t tkline_time=0;
int bits, t;
@@ -259,24 +258,17 @@ mo_dline(struct Client *client_p, struct Client *source_p,
if (!valid_comment(source_p, reason, 1))
return;
- conf = make_conf_item(DLINE_TYPE);
- aconf = map_to_conf(conf);
+ aconf = map_to_conf(make_conf_item(DLINE_TYPE));
DupString(aconf->host, dlhost);
if (tkline_time != 0)
- {
snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
(int)(tkline_time/60), reason, current_date);
- DupString(aconf->reason, buffer);
- apply_dline(source_p, aconf, tkline_time);
- }
else
- {
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
- DupString(aconf->reason, buffer);
- apply_dline(source_p, aconf, 0);
- }
+ DupString(aconf->reason, buffer);
+ apply_dline(source_p, aconf, tkline_time);
rehashed_klines = 1;
}
@@ -289,7 +281,6 @@ ms_dline(struct Client *client_p, struct Client *source_p,
const char *creason;
const struct Client *target_p = NULL;
struct irc_ssaddr daddr;
- struct ConfItem *conf=NULL;
struct AccessItem *aconf=NULL;
time_t tkline_time=0;
int bits, t;
@@ -386,24 +377,17 @@ ms_dline(struct Client *client_p, struct Client *source_p,
if (!valid_comment(source_p, reason, 1))
return;
- conf = make_conf_item(DLINE_TYPE);
- aconf = map_to_conf(conf);
+ aconf = map_to_conf(make_conf_item(DLINE_TYPE));
DupString(aconf->host, dlhost);
if (tkline_time != 0)
- {
snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
(int)(tkline_time/60), reason, current_date);
- DupString(aconf->reason, buffer);
- apply_dline(source_p, aconf, tkline_time);
- }
else
- {
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
- DupString(aconf->reason, buffer);
- apply_dline(source_p, aconf, 0);
- }
+ DupString(aconf->reason, buffer);
+ apply_dline(source_p, aconf, tkline_time);
rehashed_klines = 1;
}
}
diff --git a/modules/m_gline.c b/modules/m_gline.c
index b748bec..6e6b894 100644
--- a/modules/m_gline.c
+++ b/modules/m_gline.c
@@ -71,7 +71,7 @@ set_local_gline(const struct Client *source_p, const char *user,
aconf->setat = CurrentTime;
aconf->hold = CurrentTime + ConfigFileEntry.gline_time;
- SetConfTemporary(aconf);
+ SetConfDatabase(aconf);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s added G-Line for [%s@%s] [%s]",
@@ -114,8 +114,11 @@ remove_gline_match(const char *user, const char *host)
if ((aconf = find_conf_by_address(host, piphost, CONF_GLINE, t, user, NULL, 0)))
{
- delete_one_address_conf(host, aconf);
- return 1;
+ if (IsConfDatabase(aconf))
+ {
+ delete_one_address_conf(host, aconf);
+ return 1;
+ }
}
return 0;
diff --git a/modules/m_kline.c b/modules/m_kline.c
index 78c790a..0964f93 100644
--- a/modules/m_kline.c
+++ b/modules/m_kline.c
@@ -70,7 +70,6 @@ mo_kline(struct Client *client_p, struct Client *source_p,
char *host = NULL;
const char *current_date;
char *target_server = NULL;
- struct ConfItem *conf;
struct AccessItem *aconf;
time_t tkline_time = 0;
time_t cur_time;
@@ -118,27 +117,19 @@ mo_kline(struct Client *client_p, struct Client *source_p,
cur_time = CurrentTime;
current_date = smalldate(cur_time);
- conf = make_conf_item(KLINE_TYPE);
- aconf = map_to_conf(conf);
+ aconf = map_to_conf(make_conf_item(KLINE_TYPE));
DupString(aconf->host, host);
DupString(aconf->user, user);
if (tkline_time != 0)
- {
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)",
(int)(tkline_time/60), reason, current_date);
- DupString(aconf->reason, buffer);
-
- m_kline_add_kline(source_p, aconf, tkline_time);
- }
else
- {
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
- DupString(aconf->reason, buffer);
- m_kline_add_kline(source_p, aconf, 0);
- }
+ DupString(aconf->reason, buffer);
+ m_kline_add_kline(source_p, aconf, tkline_time);
}
/* me_kline - handle remote kline. no propagation */
@@ -146,9 +137,8 @@ static void
me_kline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
- struct ConfItem *conf=NULL;
- struct AccessItem *aconf=NULL;
- int tkline_time;
+ struct AccessItem *aconf = NULL;
+ int tkline_time = 0;
const char* current_date;
time_t cur_time;
char *kuser, *khost, *kreason;
@@ -175,26 +165,18 @@ me_kline(struct Client *client_p, struct Client *source_p,
already_placed_kline(source_p, kuser, khost, 1))
return;
- conf = make_conf_item(KLINE_TYPE);
- aconf = map_to_conf(conf);
+ aconf = map_to_conf(make_conf_item(KLINE_TYPE));
DupString(aconf->host, khost);
DupString(aconf->user, kuser);
if (tkline_time != 0)
- {
snprintf(buffer, sizeof(buffer), "Temporary K-line %d min. - %s (%s)",
(int)(tkline_time/60), kreason, current_date);
- DupString(aconf->reason, buffer);
-
- m_kline_add_kline(source_p, aconf, tkline_time);
- }
else
- {
snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date);
- DupString(aconf->reason, buffer);
- m_kline_add_kline(source_p, aconf, 0);
- }
+ DupString(aconf->reason, buffer);
+ m_kline_add_kline(source_p, aconf, tkline_time);
}
}
@@ -224,13 +206,9 @@ static void
m_kline_add_kline(struct Client *source_p, struct AccessItem *aconf,
time_t tkline_time)
{
- aconf->setat = CurrentTime;
-
if (tkline_time)
{
aconf->hold = CurrentTime + tkline_time;
- SetConfTemporary(aconf);
-
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s added temporary %d min. K-Line for [%s@%s] [%s]",
get_oper_name(source_p), tkline_time/60,
@@ -256,6 +234,9 @@ m_kline_add_kline(struct Client *source_p, struct AccessItem *aconf,
source_p->name, aconf->user, aconf->host, aconf->reason);
}
+ aconf->setat = CurrentTime;
+ SetConfDatabase(aconf);
+
add_conf_by_address(CONF_KLINE, aconf);
rehashed_klines = 1;
}
@@ -468,7 +449,7 @@ remove_kline_match(const char *host, const char *user)
if ((aconf = find_conf_by_address(host, piphost, CONF_KLINE, t, user, NULL, 0)))
{
- if (!IsConfMain(aconf))
+ if (IsConfDatabase(aconf))
{
delete_one_address_conf(host, aconf);
return 1;
diff --git a/modules/m_resv.c b/modules/m_resv.c
index e2546b7..efe700e 100644
--- a/modules/m_resv.c
+++ b/modules/m_resv.c
@@ -233,6 +233,7 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
resv_p = map_to_conf(conf);
resv_p->setat = CurrentTime;
+ SetConfDatabase(resv_p);
if (tkline_time != 0)
{
@@ -251,7 +252,6 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
source_p->name, (int)tkline_time/60,
conf->name, resv_p->reason);
resv_p->hold = CurrentTime + tkline_time;
- add_temp_line(conf);
}
else
{
@@ -264,7 +264,6 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
get_oper_name(source_p),
(MyClient(source_p) ? "local" : "remote"),
resv_p->name, resv_p->reason);
- write_conf_line(source_p, conf, NULL /* not used */, 0 /* not used */);
}
}
else
@@ -295,6 +294,7 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
resv_p = map_to_conf(conf);
resv_p->setat = CurrentTime;
+ SetConfDatabase(resv_p);
if (tkline_time != 0)
{
@@ -314,7 +314,6 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
source_p->name, (int)tkline_time/60,
conf->name, resv_p->reason);
resv_p->hold = CurrentTime + tkline_time;
- add_temp_line(conf);
}
else
{
@@ -328,7 +327,6 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
get_oper_name(source_p),
(MyClient(source_p) ? "local" : "remote"),
conf->name, resv_p->reason);
- write_conf_line(source_p, conf, NULL /* not used */, 0 /* not used */);
}
}
}
@@ -351,7 +349,7 @@ remove_resv(struct Client *source_p, const char *name)
return;
}
- if (resv_p->conf)
+ if (!IsConfDatabase(resv_p))
{
sendto_one(source_p,
":%s NOTICE %s :The RESV for channel: %s is in ircd.conf and must be removed by hand.",
@@ -360,8 +358,6 @@ remove_resv(struct Client *source_p, const char *name)
}
delete_channel_resv(resv_p);
- remove_conf_line(CRESV_TYPE, source_p, name, NULL);
-
sendto_one(source_p,
":%s NOTICE %s :The RESV has been removed on channel: %s",
me.name, source_p->name, name);
@@ -382,7 +378,7 @@ remove_resv(struct Client *source_p, const char *name)
resv_p = map_to_conf(conf);
- if (resv_p->action)
+ if (IsConfDatabase(resv_p))
{
sendto_one(source_p,
":%s NOTICE %s :The RESV for nick: %s is in ircd.conf and must be removed by hand.",
@@ -391,8 +387,6 @@ remove_resv(struct Client *source_p, const char *name)
}
delete_conf_item(conf);
- remove_conf_line(NRESV_TYPE, source_p, name, NULL);
-
sendto_one(source_p, ":%s NOTICE %s :The RESV has been removed on nick: %s",
me.name, source_p->name, name);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
diff --git a/modules/m_stats.c b/modules/m_stats.c
index e995d4f..2fd31ba 100644
--- a/modules/m_stats.c
+++ b/modules/m_stats.c
@@ -410,7 +410,7 @@ stats_deny(struct Client *source_p, int parc, char *parv[])
aconf = arec->aconf;
/* dont report a tdline as a dline */
- if (aconf->flags & CONF_FLAGS_TEMPORARY)
+ if (aconf->hold)
continue;
conf = unmap_conf_item(aconf);
@@ -448,7 +448,7 @@ stats_tdeny(struct Client *source_p, int parc, char *parv[])
aconf = arec->aconf;
/* dont report a permanent dline as a tdline */
- if (!(aconf->flags & CONF_FLAGS_TEMPORARY))
+ if (!aconf->hold)
continue;
conf = unmap_conf_item(aconf);
@@ -803,8 +803,9 @@ report_Klines(struct Client *client_p, int tkline)
if (arec->type == CONF_KLINE)
{
- if ((tkline && !((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY)) ||
- (!tkline && ((aconf = arec->aconf)->flags & CONF_FLAGS_TEMPORARY)))
+ aconf = arec->aconf;
+
+ if (!tkline && aconf->hold)
continue;
if (HasUMode(client_p, UMODE_OPER))
@@ -847,7 +848,7 @@ stats_tklines(struct Client *source_p, int parc, char *parv[])
return;
/* dont report a permanent kline as a tkline */
- if (!(aconf->flags & CONF_FLAGS_TEMPORARY))
+ if (!aconf->hold)
return;
sendto_one(source_p, form_str(RPL_STATSKLINE), from,
@@ -887,7 +888,7 @@ stats_klines(struct Client *source_p, int parc, char *parv[])
return;
/* dont report a tkline as a kline */
- if (aconf->flags & CONF_FLAGS_TEMPORARY)
+ if (aconf->hold)
return;
sendto_one(source_p, form_str(RPL_STATSKLINE), from,
diff --git a/modules/m_testline.c b/modules/m_testline.c
index 2d26658..36c0cd3 100644
--- a/modules/m_testline.c
+++ b/modules/m_testline.c
@@ -122,8 +122,8 @@ mo_testline(struct Client *client_p, struct Client *source_p,
else
sendto_one(source_p, form_str(RPL_TESTLINE),
me.name, source_p->name,
- IsConfTemporary(aconf) ? 'd' : 'D',
- IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
+ aconf->hold ? 'd' : 'D',
+ aconf->hold ? ((aconf->hold - CurrentTime) / 60)
: 0L,
aconf->host, aconf->reason);
}
@@ -155,8 +155,8 @@ mo_testline(struct Client *client_p, struct Client *source_p,
{
sendto_one(source_p, form_str(RPL_TESTLINE),
me.name, source_p->name,
- IsConfTemporary(aconf) ? 'k' : 'K',
- IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
+ aconf->hold ? 'k' : 'K',
+ aconf->hold ? ((aconf->hold - CurrentTime) / 60)
: 0L,
userhost, aconf->reason? aconf->reason : "No reason");
++matches;
diff --git a/modules/m_xline.c b/modules/m_xline.c
index c97215d..9f1acc6 100644
--- a/modules/m_xline.c
+++ b/modules/m_xline.c
@@ -345,6 +345,8 @@ write_xline(struct Client *source_p, char *gecos, char *reason,
current_date = smalldate(cur_time);
xconf->setat = CurrentTime;
+ SetConfDatabase(xconf);
+
if (tkline_time != 0)
{
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
@@ -358,7 +360,6 @@ write_xline(struct Client *source_p, char *gecos, char *reason,
source_p->name, (int)tkline_time/60,
conf->name, xconf->reason);
xconf->hold = CurrentTime + tkline_time;
- SetConfTemporary(conf);
}
else
{
@@ -412,13 +413,13 @@ remove_xline_match(const char *gecos)
DLINK_FOREACH_SAFE(ptr, next_ptr, xconf_items.head)
{
conf = ptr->data;
+ struct MatchItem *xconf = map_to_conf(conf);
- if (IsConfMain(conf))
+ if (!IsConfDatabase(xconf))
continue;
if (!irccmp(gecos, conf->name))
{
- free_dlink_node(ptr);
delete_conf_item(conf);
return 1;
}