summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-11-01 13:16:37 +0000
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>2012-11-01 13:16:37 +0000
commit206aa6907524c1f834ba23160a033fa6a8e2bb0b (patch)
treeb28e4659a4697bf6ff133f06f6863fbdb20a9a2d /modules
parent66b1fc152776ef824c291307dd7be93c0e2a9ad6 (diff)
- klines, dlines, xlines, glines and resv now make use of the new database;
also, temporary *lines are now stored, so they're not lost after restarting the ircd. This also applies to G-lines. git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/trunk@1622 82007160-df01-0410-b94d-b575c5fd34c7
Diffstat (limited to 'modules')
-rw-r--r--modules/m_dline.c122
-rw-r--r--modules/m_gline.c21
-rw-r--r--modules/m_kline.c144
-rw-r--r--modules/m_resv.c2
-rw-r--r--modules/m_stats.c18
-rw-r--r--modules/m_testline.c12
-rw-r--r--modules/m_xline.c73
7 files changed, 153 insertions, 239 deletions
diff --git a/modules/m_dline.c b/modules/m_dline.c
index 8c4c33d..b17a6fc 100644
--- a/modules/m_dline.c
+++ b/modules/m_dline.c
@@ -39,9 +39,9 @@
#include "send.h"
#include "hash.h"
#include "s_serv.h"
-#include "s_gline.h"
#include "parse.h"
#include "modules.h"
+#include "conf_db.h"
/* apply_tdline()
@@ -51,28 +51,39 @@
* side effects - tkline as given is placed
*/
static void
-apply_tdline(struct Client *source_p, struct ConfItem *conf,
- const char *current_date, int tkline_time)
+apply_dline(struct Client *source_p, struct AccessItem *aconf,
+ time_t tkline_time)
{
- struct AccessItem *aconf;
-
- aconf = map_to_conf(conf);
- aconf->hold = CurrentTime + tkline_time;
- SetConfTemporary(aconf);
- add_conf_by_address(CONF_DLINE, 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,
- aconf->host, aconf->reason);
+ 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,
+ aconf->host, aconf->reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
+ MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
+ source_p->name, tkline_time/60, aconf->host);
+ ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
+ get_oper_name(source_p), tkline_time/60, aconf->host, aconf->reason);
+ }
+ else
+ {
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "%s added D-Line for [%s] [%s]",
+ get_oper_name(source_p), aconf->host, aconf->reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added D-Line [%s]",
+ MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
+ source_p->name, aconf->host);
+ ilog(LOG_TYPE_DLINE, "%s added D-Line for [%s] [%s]",
+ get_oper_name(source_p), aconf->host, aconf->reason);
- sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. D-Line [%s]",
- MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
- source_p->name, tkline_time/60, aconf->host);
- ilog(LOG_TYPE_DLINE, "%s added temporary %d min. D-Line for [%s] [%s]",
- source_p->name, tkline_time/60, aconf->host, aconf->reason);
+ }
+ aconf->setat = CurrentTime;
+ add_conf_by_address(CONF_DLINE, aconf);
+ save_dline_database();
rehashed_klines = 1;
}
@@ -82,7 +93,7 @@ apply_tdline(struct Client *source_p, struct ConfItem *conf,
* Side effects: Any matching tdlines are removed.
*/
static int
-remove_tdline_match(const char *host)
+remove_dline_match(const char *host)
{
struct irc_ssaddr iphost, *piphost;
struct AccessItem *aconf;
@@ -106,9 +117,10 @@ remove_tdline_match(const char *host)
if ((aconf = find_conf_by_address(host, piphost, CONF_DLINE, t, NULL, NULL, 0)))
{
- if (IsConfTemporary(aconf))
+ if (!IsConfMain(aconf))
{
delete_one_address_conf(host, aconf);
+ save_dline_database();
return 1;
}
}
@@ -131,7 +143,7 @@ mo_dline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
char def_reason[] = "<No reason specified>";
- char *dlhost = NULL, *oper_reason = NULL, *reason = NULL;
+ char *dlhost = NULL, *reason = NULL;
char *target_server = NULL;
const char *creason;
const struct Client *target_p = NULL;
@@ -246,10 +258,6 @@ mo_dline(struct Client *client_p, struct Client *source_p,
cur_time = CurrentTime;
current_date = smalldate(cur_time);
- /* Look for an oper reason */
- if ((oper_reason = strchr(reason, '|')) != NULL)
- *oper_reason++ = '\0';
-
if (!valid_comment(source_p, reason, 1))
return;
@@ -262,18 +270,13 @@ mo_dline(struct Client *client_p, struct Client *source_p,
snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
(int)(tkline_time/60), reason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- apply_tdline(source_p, conf, current_date, tkline_time);
+ apply_dline(source_p, aconf, tkline_time);
}
else
{
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- add_conf_by_address(CONF_DLINE, aconf);
- write_conf_line(source_p, conf, current_date, cur_time);
+ apply_dline(source_p, aconf, 0);
}
rehashed_klines = 1;
@@ -284,7 +287,7 @@ ms_dline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
char def_reason[] = "<No reason specified>";
- char *dlhost, *oper_reason, *reason;
+ char *dlhost, *reason;
const char *creason;
const struct Client *target_p = NULL;
struct irc_ssaddr daddr;
@@ -382,10 +385,6 @@ ms_dline(struct Client *client_p, struct Client *source_p,
cur_time = CurrentTime;
current_date = smalldate(cur_time);
- /* Look for an oper reason */
- if ((oper_reason = strchr(reason, '|')) != NULL)
- *oper_reason++ = '\0';
-
if (!valid_comment(source_p, reason, 1))
return;
@@ -398,18 +397,13 @@ ms_dline(struct Client *client_p, struct Client *source_p,
snprintf(buffer, sizeof(buffer), "Temporary D-line %d min. - %s (%s)",
(int)(tkline_time/60), reason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- apply_tdline(source_p, conf, current_date, tkline_time);
+ apply_dline(source_p, aconf, tkline_time);
}
else
{
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- add_conf_by_address(CONF_DLINE, aconf);
- write_conf_line(source_p, conf, current_date, cur_time);
+ apply_dline(source_p, aconf, 0);
}
rehashed_klines = 1;
@@ -463,26 +457,14 @@ mo_undline(struct Client *client_p, struct Client *source_p,
cluster_a_line(source_p, "UNDLINE", CAP_UNDLN, SHARED_UNDLINE,
"%s", addr);
- if (remove_tdline_match(addr))
+ if (remove_dline_match(addr))
{
sendto_one(source_p,
- ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
+ ":%s NOTICE %s :D-Line for [%s] is removed",
me.name, source_p->name, addr);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s has removed the temporary D-Line for: [%s]",
+ "%s has removed the D-Line for: [%s]",
get_oper_name(source_p), addr);
- ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
- source_p->name, addr);
- return;
- }
-
- if (remove_conf_line(DLINE_TYPE, source_p, addr, NULL) > 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
- me.name, source_p->name, addr);
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s has removed the D-Line for: [%s]",
- get_oper_name(source_p), addr);
ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
get_oper_name(source_p), addr);
}
@@ -510,27 +492,15 @@ me_undline(struct Client *client_p, struct Client *source_p,
source_p->username, source_p->host,
SHARED_UNDLINE))
{
- if (remove_tdline_match(addr))
+ if (remove_dline_match(addr))
{
sendto_one(source_p,
- ":%s NOTICE %s :Un-Dlined [%s] from temporary D-Lines",
- me.name, source_p->name, addr);
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s has removed the temporary D-Line for: [%s]",
- get_oper_name(source_p), addr);
- ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
- source_p->name, addr);
- return;
- }
-
- if (remove_conf_line(DLINE_TYPE, source_p, addr, NULL) > 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :D-Line for [%s] is removed",
+ ":%s NOTICE %s :D-Line for [%s] is removed",
me.name, source_p->name, addr);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s has removed the D-Line for: [%s]",
get_oper_name(source_p), addr);
- ilog(LOG_TYPE_DLINE, "%s removed D-Line for [%s]",
+ ilog(LOG_TYPE_DLINE, "%s removed temporary D-Line for [%s]",
get_oper_name(source_p), addr);
}
else
diff --git a/modules/m_gline.c b/modules/m_gline.c
index a1acdfd..8f8835b 100644
--- a/modules/m_gline.c
+++ b/modules/m_gline.c
@@ -43,6 +43,7 @@
#include "parse.h"
#include "modules.h"
#include "log.h"
+#include "conf_db.h"
#define GLINE_NOT_PLACED 0
#define GLINE_ALREADY_VOTED -1
@@ -61,21 +62,16 @@ set_local_gline(const struct Client *source_p, const char *user,
const char *host, const char *reason)
{
char buffer[IRCD_BUFSIZE];
- struct ConfItem *conf;
- struct AccessItem *aconf;
-
-
- conf = make_conf_item(GLINE_TYPE);
- aconf = map_to_conf(conf);
+ struct AccessItem *aconf = map_to_conf(make_conf_item(GLINE_TYPE));
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, smalldate(CurrentTime));
DupString(aconf->reason, buffer);
DupString(aconf->user, user);
DupString(aconf->host, host);
+ aconf->setat = CurrentTime;
aconf->hold = CurrentTime + ConfigFileEntry.gline_time;
SetConfTemporary(aconf);
- add_conf_by_address(CONF_GLINE, aconf);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s added G-Line for [%s@%s] [%s]",
@@ -84,7 +80,8 @@ set_local_gline(const struct Client *source_p, const char *user,
ilog(LOG_TYPE_GLINE, "%s added G-Line for [%s@%s] [%s]",
get_oper_name(source_p), aconf->user, aconf->host, aconf->reason);
- /* Now, activate gline against current online clients */
+ add_conf_by_address(CONF_GLINE, aconf);
+ save_gline_database();
rehashed_klines = 1;
}
@@ -118,11 +115,9 @@ remove_gline_match(const char *user, const char *host)
if ((aconf = find_conf_by_address(host, piphost, CONF_GLINE, t, user, NULL, 0)))
{
- if (IsConfTemporary(aconf))
- {
- delete_one_address_conf(host, aconf);
- return 1;
- }
+ delete_one_address_conf(host, aconf);
+ save_gline_database();
+ return 1;
}
return 0;
diff --git a/modules/m_kline.c b/modules/m_kline.c
index 9270d0f..315c5e8 100644
--- a/modules/m_kline.c
+++ b/modules/m_kline.c
@@ -42,14 +42,14 @@
#include "s_gline.h"
#include "parse.h"
#include "modules.h"
+#include "conf_db.h"
static int already_placed_kline(struct Client *, const char *, const char *, int);
-static void apply_kline(struct Client *, struct ConfItem *, const char *, time_t);
-static void apply_tkline(struct Client *, struct ConfItem *, int);
+static void m_kline_add_kline(struct Client *, struct AccessItem *, time_t);
static char buffer[IRCD_BUFSIZE];
-static int remove_tkline_match(const char *, const char *);
+static int remove_kline_match(const char *, const char *);
/* mo_kline()
@@ -66,7 +66,6 @@ mo_kline(struct Client *client_p, struct Client *source_p,
int parc, char *parv[])
{
char *reason = NULL;
- char *oper_reason;
char *user = NULL;
char *host = NULL;
const char *current_date;
@@ -117,10 +116,6 @@ mo_kline(struct Client *client_p, struct Client *source_p,
if (already_placed_kline(source_p, user, host, 1))
return;
- /* Look for an oper reason */
- if ((oper_reason = strchr(reason, '|')) != NULL)
- *oper_reason++ = '\0';
-
cur_time = CurrentTime;
current_date = smalldate(cur_time);
conf = make_conf_item(KLINE_TYPE);
@@ -135,18 +130,14 @@ mo_kline(struct Client *client_p, struct Client *source_p,
(int)(tkline_time/60), reason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- apply_tkline(source_p, conf, tkline_time);
+ m_kline_add_kline(source_p, aconf, tkline_time);
}
else
{
snprintf(buffer, sizeof(buffer), "%s (%s)", reason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- apply_kline(source_p, conf, current_date, cur_time);
+ m_kline_add_kline(source_p, aconf, 0);
}
}
@@ -160,7 +151,7 @@ me_kline(struct Client *client_p, struct Client *source_p,
int tkline_time;
const char* current_date;
time_t cur_time;
- char *kuser, *khost, *kreason, *oper_reason;
+ char *kuser, *khost, *kreason;
if (parc != 6 || EmptyString(parv[5]))
return;
@@ -173,9 +164,6 @@ me_kline(struct Client *client_p, struct Client *source_p,
khost = parv[4];
kreason = parv[5];
- if ((oper_reason = strchr(kreason, '|')) != NULL)
- *oper_reason++ = '\0';
-
cur_time = CurrentTime;
current_date = smalldate(cur_time);
@@ -198,18 +186,14 @@ me_kline(struct Client *client_p, struct Client *source_p,
(int)(tkline_time/60), kreason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- apply_tkline(source_p, conf, tkline_time);
+ m_kline_add_kline(source_p, aconf, tkline_time);
}
else
{
snprintf(buffer, sizeof(buffer), "%s (%s)", kreason, current_date);
DupString(aconf->reason, buffer);
- if (oper_reason != NULL)
- DupString(aconf->oper_reason, oper_reason);
- apply_kline(source_p, conf, current_date, cur_time);
+ m_kline_add_kline(source_p, aconf, 0);
}
}
}
@@ -230,25 +214,6 @@ ms_kline(struct Client *client_p, struct Client *source_p,
me_kline(client_p, source_p, parc, parv);
}
-/* apply_kline()
- *
- * inputs -
- * output - NONE
- * side effects - kline as given, is added to the hashtable
- * and conf file
- */
-static void
-apply_kline(struct Client *source_p, struct ConfItem *conf,
- const char *current_date, time_t cur_time)
-{
- struct AccessItem *aconf = map_to_conf(conf);
-
- add_conf_by_address(CONF_KLINE, aconf);
- write_conf_line(source_p, conf, current_date, cur_time);
- /* Now, activate kline against current online clients */
- rehashed_klines = 1;
-}
-
/* apply_tkline()
*
* inputs -
@@ -256,28 +221,43 @@ apply_kline(struct Client *source_p, struct ConfItem *conf,
* side effects - tkline as given is placed
*/
static void
-apply_tkline(struct Client *source_p, struct ConfItem *conf,
- int tkline_time)
+m_kline_add_kline(struct Client *source_p, struct AccessItem *aconf,
+ time_t tkline_time)
{
- struct AccessItem *aconf;
+ aconf->setat = CurrentTime;
- aconf = (struct AccessItem *)map_to_conf(conf);
- aconf->hold = CurrentTime + tkline_time;
- SetConfTemporary(aconf);
- add_conf_by_address(CONF_KLINE, 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. K-Line for [%s@%s] [%s]",
- get_oper_name(source_p), tkline_time/60,
- aconf->user, aconf->host,
- aconf->reason);
- sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
- MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
- source_p->name, tkline_time/60, aconf->user, aconf->host);
- ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
- source_p->name, tkline_time/60,
- aconf->user, aconf->host, aconf->reason);
+ 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,
+ aconf->user, aconf->host,
+ aconf->reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. K-Line [%s@%s]",
+ MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
+ source_p->name, tkline_time/60, aconf->user, aconf->host);
+ ilog(LOG_TYPE_KLINE, "%s added temporary %d min. K-Line for [%s@%s] [%s]",
+ source_p->name, tkline_time/60,
+ aconf->user, aconf->host, aconf->reason);
+ }
+ else
+ {
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "%s added K-Line for [%s@%s] [%s]",
+ get_oper_name(source_p),
+ aconf->user, aconf->host, aconf->reason);
+ sendto_one(source_p, ":%s NOTICE %s :Added K-Line [%s@%s]",
+ MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
+ source_p->name, aconf->user, aconf->host);
+ ilog(LOG_TYPE_KLINE, "%s added K-Line for [%s@%s] [%s]",
+ source_p->name, aconf->user, aconf->host, aconf->reason);
+ }
+ add_conf_by_address(CONF_KLINE, aconf);
+ save_kline_database();
rehashed_klines = 1;
}
@@ -356,7 +336,7 @@ mo_unkline(struct Client *client_p,struct Client *source_p,
return;
}
- if (parc < 2 || EmptyString(parv[1]))
+ if (EmptyString(parv[1]))
{
sendto_one(source_p, form_str(ERR_NEEDMOREPARAMS),
me.name, source_p->name, "UNKLINE");
@@ -381,24 +361,12 @@ mo_unkline(struct Client *client_p,struct Client *source_p,
cluster_a_line(source_p, "UNKLINE", CAP_UNKLN, SHARED_UNKLINE,
"%s %s", user, host);
- if (remove_tkline_match(host, user))
+ if (remove_kline_match(host, user))
{
sendto_one(source_p,
- ":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines",
+ ":%s NOTICE %s :K-Line for [%s@%s] is removed",
me.name, source_p->name, user, host);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s has removed the temporary K-Line for: [%s@%s]",
- get_oper_name(source_p), user, host);
- ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]",
- source_p->name, user, host);
- return;
- }
-
- if (remove_conf_line(KLINE_TYPE, source_p, user, host) > 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
- me.name, source_p->name, user,host);
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s has removed the K-Line for: [%s@%s]",
get_oper_name(source_p), user, host);
ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
@@ -439,27 +407,14 @@ me_unkline(struct Client *client_p, struct Client *source_p,
source_p->username, source_p->host,
SHARED_UNKLINE))
{
- if (remove_tkline_match(khost, kuser))
+ if (remove_kline_match(khost, kuser))
{
sendto_one(source_p,
- ":%s NOTICE %s :Un-klined [%s@%s] from temporary K-Lines",
- me.name, source_p->name, kuser, khost);
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s has removed the temporary K-Line for: [%s@%s]",
- get_oper_name(source_p), kuser, khost);
- ilog(LOG_TYPE_KLINE, "%s removed temporary K-Line for [%s@%s]",
- source_p->name, kuser, khost);
- return;
- }
-
- if (remove_conf_line(KLINE_TYPE, source_p, kuser, khost) > 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :K-Line for [%s@%s] is removed",
+ ":%s NOTICE %s :K-Line for [%s@%s] is removed",
me.name, source_p->name, kuser, khost);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s has removed the K-Line for: [%s@%s]",
- get_oper_name(source_p), kuser, khost);
-
+ get_oper_name(source_p), kuser, khost);
ilog(LOG_TYPE_KLINE, "%s removed K-Line for [%s@%s]",
source_p->name, kuser, khost);
}
@@ -490,7 +445,7 @@ ms_unkline(struct Client *client_p, struct Client *source_p,
* Side effects: Any matching tklines are removed.
*/
static int
-remove_tkline_match(const char *host, const char *user)
+remove_kline_match(const char *host, const char *user)
{
struct irc_ssaddr iphost, *piphost;
struct AccessItem *aconf;
@@ -514,9 +469,10 @@ remove_tkline_match(const char *host, const char *user)
if ((aconf = find_conf_by_address(host, piphost, CONF_KLINE, t, user, NULL, 0)))
{
- if (IsConfTemporary(aconf))
+ if (!IsConfMain(aconf))
{
delete_one_address_conf(host, aconf);
+ save_kline_database();
return 1;
}
}
diff --git a/modules/m_resv.c b/modules/m_resv.c
index e57a67e..e2546b7 100644
--- a/modules/m_resv.c
+++ b/modules/m_resv.c
@@ -232,6 +232,7 @@ parse_resv(struct Client *source_p, char *name, int tkline_time, char *reason)
}
resv_p = map_to_conf(conf);
+ resv_p->setat = CurrentTime;
if (tkline_time != 0)
{
@@ -293,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;
if (tkline_time != 0)
{
diff --git a/modules/m_stats.c b/modules/m_stats.c
index 938b068..e995d4f 100644
--- a/modules/m_stats.c
+++ b/modules/m_stats.c
@@ -416,8 +416,7 @@ stats_deny(struct Client *source_p, int parc, char *parv[])
conf = unmap_conf_item(aconf);
sendto_one(source_p, form_str(RPL_STATSDLINE),
- from, to, 'D', aconf->host, aconf->reason,
- aconf->oper_reason ? aconf->oper_reason : "");
+ from, to, 'D', aconf->host, aconf->reason);
}
}
}
@@ -455,8 +454,7 @@ stats_tdeny(struct Client *source_p, int parc, char *parv[])
conf = unmap_conf_item(aconf);
sendto_one(source_p, form_str(RPL_STATSDLINE),
- from, to, 'd', aconf->host, aconf->reason,
- aconf->oper_reason ? aconf->oper_reason : "");
+ from, to, 'd', aconf->host, aconf->reason);
}
}
}
@@ -498,7 +496,7 @@ stats_exempt(struct Client *source_p, int parc, char *parv[])
sendto_one(source_p, form_str(RPL_STATSDLINE),
from, to, 'e', aconf->host,
- aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
+ aconf->reason);
}
}
}
@@ -632,7 +630,7 @@ stats_glines(struct Client *source_p, int parc, char *parv[])
from, to, "G",
aconf->host ? aconf->host : "*",
aconf->user ? aconf->user : "*",
- aconf->reason ? aconf->reason : "No reason", "" );
+ aconf->reason ? aconf->reason : "No reason");
}
}
}
@@ -812,11 +810,11 @@ report_Klines(struct Client *client_p, int tkline)
if (HasUMode(client_p, UMODE_OPER))
sendto_one(client_p, form_str(RPL_STATSKLINE), me.name,
client_p->name, p, aconf->host, aconf->user,
- aconf->reason, aconf->oper_reason ? aconf->oper_reason : "");
+ aconf->reason);
else
sendto_one(client_p, form_str(RPL_STATSKLINE), me.name,
client_p->name, p, aconf->host, aconf->user,
- aconf->reason, "");
+ aconf->reason);
}
}
}
@@ -853,7 +851,7 @@ stats_tklines(struct Client *source_p, int parc, char *parv[])
return;
sendto_one(source_p, form_str(RPL_STATSKLINE), from,
- to, "k", aconf->host, aconf->user, aconf->reason, "");
+ to, "k", aconf->host, aconf->user, aconf->reason);
}
/* Theyre opered, or allowed to see all klines */
else {
@@ -893,7 +891,7 @@ stats_klines(struct Client *source_p, int parc, char *parv[])
return;
sendto_one(source_p, form_str(RPL_STATSKLINE), from,
- to, "K", aconf->host, aconf->user, aconf->reason, "");
+ to, "K", aconf->host, aconf->user, aconf->reason);
}
/* Theyre opered, or allowed to see all klines */
else {
diff --git a/modules/m_testline.c b/modules/m_testline.c
index f9a8e67..2d26658 100644
--- a/modules/m_testline.c
+++ b/modules/m_testline.c
@@ -125,8 +125,7 @@ mo_testline(struct Client *client_p, struct Client *source_p,
IsConfTemporary(aconf) ? 'd' : 'D',
IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
: 0L,
- aconf->host, aconf->reason,
- aconf->oper_reason ? aconf->oper_reason : "");
+ aconf->host, aconf->reason);
}
}
@@ -159,8 +158,7 @@ mo_testline(struct Client *client_p, struct Client *source_p,
IsConfTemporary(aconf) ? 'k' : 'K',
IsConfTemporary(aconf) ? ((aconf->hold - CurrentTime) / 60)
: 0L,
- userhost, aconf->reason? aconf->reason : "No reason",
- aconf->oper_reason ? aconf->oper_reason : "");
+ userhost, aconf->reason? aconf->reason : "No reason");
++matches;
}
}
@@ -174,8 +172,7 @@ mo_testline(struct Client *client_p, struct Client *source_p,
sendto_one(source_p, form_str(RPL_TESTLINE),
me.name, source_p->name, 'Q', 0L,
conf->name,
- mconf->reason ? mconf->reason : "No reason",
- mconf->oper_reason ? mconf->oper_reason : "");
+ mconf->reason ? mconf->reason : "No reason");;
++matches;
}
@@ -215,8 +212,7 @@ mo_testgecos(struct Client *client_p, struct Client *source_p,
const struct MatchItem *xconf = map_to_conf(conf);
sendto_one(source_p, form_str(RPL_TESTLINE),
me.name, source_p->name, 'X', 0L,
- conf->name, xconf->reason ? xconf->reason : "X-lined",
- xconf->oper_reason ? xconf->oper_reason : "");
+ conf->name, xconf->reason ? xconf->reason : "X-lined");
}
else
sendto_one(source_p, form_str(RPL_NOTESTLINE),
diff --git a/modules/m_xline.c b/modules/m_xline.c
index 1020e09..c0413a7 100644
--- a/modules/m_xline.c
+++ b/modules/m_xline.c
@@ -42,12 +42,13 @@
#include "parse.h"
#include "modules.h"
#include "resv.h"
+#include "conf_db.h"
static int valid_xline(struct Client *, char *, char *, int);
static void write_xline(struct Client *, char *, char *, time_t);
static void remove_xline(struct Client *, char *);
-static int remove_txline_match(const char *);
+static int remove_xline_match(const char *);
static void relay_xline(struct Client *, char *[]);
@@ -307,13 +308,6 @@ valid_xline(struct Client *source_p, char *gecos, char *reason, int warn)
return 0;
}
- if (strchr(gecos, '"'))
- {
- sendto_one(source_p, ":%s NOTICE %s :Invalid character '\"'",
- me.name, source_p->name);
- return 0;
- }
-
if (!valid_wild_card_simple(gecos))
{
if (warn)
@@ -337,66 +331,68 @@ write_xline(struct Client *source_p, char *gecos, char *reason,
time_t tkline_time)
{
struct ConfItem *conf;
- struct MatchItem *match_item;
+ struct MatchItem *xconf;
const char *current_date;
time_t cur_time;
conf = make_conf_item(XLINE_TYPE);
- match_item = map_to_conf(conf);
+ xconf = map_to_conf(conf);
collapse(gecos);
DupString(conf->name, gecos);
- DupString(match_item->reason, reason);
- DupString(match_item->oper_reason, ""); /* XXX */
+ DupString(xconf->reason, reason);
cur_time = CurrentTime;
current_date = smalldate(cur_time);
+ xconf->setat = CurrentTime;
if (tkline_time != 0)
{
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s added temporary %d min. X-Line for [%s] [%s]",
get_oper_name(source_p), (int)tkline_time/60,
- conf->name, match_item->reason);
+ conf->name, xconf->reason);
sendto_one(source_p, ":%s NOTICE %s :Added temporary %d min. X-Line [%s]",
MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
source_p->name, (int)tkline_time/60, conf->name);
ilog(LOG_TYPE_KLINE, "%s added temporary %d min. X-Line for [%s] [%s]",
source_p->name, (int)tkline_time/60,
- conf->name, match_item->reason);
- match_item->hold = CurrentTime + tkline_time;
- add_temp_line(conf);
+ conf->name, xconf->reason);
+ xconf->hold = CurrentTime + tkline_time;
+ SetConfTemporary(conf);
}
else
- write_conf_line(source_p, conf, current_date, cur_time);
+ {
+ sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
+ "%s added X-Line for [%s] [%s]",
+ get_oper_name(source_p), conf->name,
+ xconf->reason);
+ sendto_one(source_p,
+ ":%s NOTICE %s :Added X-Line [%s] [%d] [%s]",
+ MyConnect(source_p) ? me.name : ID_or_name(&me, source_p->from),
+ source_p->name, conf->name,
+ xconf->action, xconf->reason);
+ ilog(LOG_TYPE_IRCD, "%s added X-Line for [%s] [%s]",
+ get_oper_name(source_p), conf->name, xconf->reason);
+ }
+
+ save_xline_database();
rehashed_klines = 1;
}
static void
remove_xline(struct Client *source_p, char *gecos)
{
- /* XXX use common temporary un function later */
- if (remove_txline_match(gecos))
+ if (remove_xline_match(gecos))
{
sendto_one(source_p,
- ":%s NOTICE %s :Un-xlined [%s] from temporary X-Lines",
- me.name, source_p->name, gecos);
- sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
- "%s has removed the temporary X-Line for: [%s]",
- get_oper_name(source_p), gecos);
- ilog(LOG_TYPE_KLINE, "%s removed temporary X-Line for [%s]",
- source_p->name, gecos);
- return;
- }
-
- if (remove_conf_line(XLINE_TYPE, source_p, gecos, NULL) > 0)
- {
- sendto_one(source_p, ":%s NOTICE %s :X-Line for [%s] is removed",
+ ":%s NOTICE %s :X-Line for [%s] is removed",
me.name, source_p->name, gecos);
sendto_realops_flags(UMODE_ALL, L_ALL, SEND_NOTICE,
"%s has removed the X-Line for: [%s]",
get_oper_name(source_p), gecos);
ilog(LOG_TYPE_KLINE, "%s removed X-Line for [%s]",
- get_oper_name(source_p), gecos);
+ source_p->name, gecos);
+ save_xline_database();
}
else
sendto_one(source_p, ":%s NOTICE %s :No X-Line for %s",
@@ -410,21 +406,22 @@ remove_xline(struct Client *source_p, char *gecos)
* Side effects: Any matching tklines are removed.
*/
static int
-remove_txline_match(const char *gecos)
+remove_xline_match(const char *gecos)
{
dlink_node *ptr = NULL, *next_ptr = NULL;
struct ConfItem *conf = NULL;
- DLINK_FOREACH_SAFE(ptr, next_ptr, temporary_xlines.head)
+ DLINK_FOREACH_SAFE(ptr, next_ptr, xconf_items.head)
{
conf = ptr->data;
- if (irccmp(gecos, conf->name) == 0)
+ if (IsConfMain(conf))
+ continue;
+
+ if (!irccmp(gecos, conf->name))
{
- dlinkDelete(ptr, &temporary_xlines);
free_dlink_node(ptr);
delete_conf_item(conf);
-
return 1;
}
}