* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
- *
- * $Id$
*/
#include "stdinc.h"
#include "parse.h"
#include "modules.h"
#include "bandbi.h"
+#include "operhash.h"
-static int mo_dline(struct Client *, struct Client *, int, const char **);
-static int me_dline(struct Client *, struct Client *, int, const char **);
-static int mo_undline(struct Client *, struct Client *, int, const char **);
-static int me_undline(struct Client *, struct Client *, int, const char **);
+static int mo_dline(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int me_dline(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int mo_undline(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int me_undline(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
struct Message dline_msgtab = {
- "DLINE", 0, 0, 0, MFLG_SLOW,
- {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_dline, 3}, {mo_dline, 2}}
+ "DLINE", 0, 0, 0, 0,
+ {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_dline, 4}, {mo_dline, 2}}
};
struct Message undline_msgtab = {
- "UNDLINE", 0, 0, 0, MFLG_SLOW,
- {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_undline, 1}, {mo_undline, 2}}
+ "UNDLINE", 0, 0, 0, 0,
+ {mg_unreg, mg_not_oper, mg_ignore, mg_ignore, {me_undline, 2}, {mo_undline, 2}}
};
mapi_clist_av1 dline_clist[] = { &dline_msgtab, &undline_msgtab, NULL };
-DECLARE_MODULE_AV1(dline, NULL, NULL, dline_clist, NULL, NULL, "$Revision$");
+DECLARE_MODULE_AV2(dline, NULL, NULL, dline_clist, NULL, NULL, NULL, NULL, NULL);
-static int valid_comment(char *comment);
static int remove_temp_dline(struct ConfItem *);
static int apply_dline(struct Client *, const char *, int, char *);
static int apply_undline(struct Client *, const char *);
/* mo_dline()
- *
+ *
* parv[1] - dline to add
* parv[2] - reason
*/
static int
-mo_dline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mo_dline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
char def[] = "No Reason";
const char *dlhost;
dlhost = parv[loc];
rb_strlcpy(cidr_form_host, dlhost, sizeof(cidr_form_host));
-
loc++;
+ /* would break the protocol */
+ if (*dlhost == ':')
+ {
+ sendto_one_notice(source_p, ":Invalid D-Line");
+ return 0;
+ }
+
if(parc >= loc + 2 && !irccmp(parv[loc], "ON"))
{
if(!IsOperRemoteBan(source_p))
* parv[1] = dline to remove
*/
static int
-mo_undline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+mo_undline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
const char *cidr;
const char *target_server = NULL;
}
static int
-me_dline(struct Client *client_p, struct Client *source_p, int parc, const char **parv)
+me_dline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
int tdline_time = atoi(parv[1]);
/* Since this is coming over a server link, assume that the originating
}
static int
-me_undline(struct Client *client_p, struct Client *source_p, int parc, const char **parv)
+me_undline(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char **parv)
{
if(!IsPerson(source_p))
return 0;
{
struct ConfItem *aconf;
char *oper_reason;
- char dlbuffer[IRCD_BUFSIZE];
- const char *current_date;
struct rb_sockaddr_storage daddr;
int t = AF_INET, ty, b;
const char *creason;
- ty = parse_netmask(dlhost, (struct sockaddr *) &daddr, &b);
+ ty = parse_netmask(dlhost, &daddr, &b);
if(ty == HM_HOST)
{
sendto_one(source_p, ":%s NOTICE %s :Invalid D-Line", me.name, source_p->name);
}
}
- if(!valid_comment(reason))
- {
- sendto_one(source_p,
- ":%s NOTICE %s :Invalid character '\"' in comment",
- me.name, source_p->name);
- return 0;
- }
-
if(ConfigFileEntry.non_redundant_klines)
{
if((aconf = find_dline((struct sockaddr *) &daddr, t)) != NULL)
}
rb_set_time();
- current_date = smalldate();
aconf = make_conf();
aconf->status = CONF_DLINE;
+ aconf->created = rb_current_time();
aconf->host = rb_strdup(dlhost);
+ aconf->passwd = rb_strdup(reason);
+ aconf->info.oper = operhash_add(get_oper_name(source_p));
+
+ if(strlen(reason) > BANREASONLEN)
+ reason[BANREASONLEN] = '\0';
/* Look for an oper reason */
if((oper_reason = strchr(reason, '|')) != NULL)
if(tdline_time > 0)
{
- rb_snprintf(dlbuffer, sizeof(dlbuffer),
- "Temporary D-line %d min. - %s (%s)",
- (int) (tdline_time / 60), reason, current_date);
- aconf->passwd = rb_strdup(dlbuffer);
aconf->hold = rb_current_time() + tdline_time;
add_temp_dline(aconf);
}
else
{
- rb_snprintf(dlbuffer, sizeof(dlbuffer), "%s (%s)", reason, current_date);
- aconf->passwd = rb_strdup(dlbuffer);
add_conf_by_address(aconf->host, CONF_DLINE, NULL, NULL, aconf);
bandb_add(BANDB_DLINE, source_p, aconf->host, NULL,
reason, EmptyString(aconf->spasswd) ? NULL : aconf->spasswd, 0);
+
+ if(EmptyString(oper_reason))
+ {
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "%s added D-Line for [%s] [%s]",
+ get_oper_name(source_p), aconf->host, reason);
+ ilog(L_KLINE, "D %s 0 %s %s",
+ get_oper_name(source_p), aconf->host, reason);
+ }
+ else
+ {
+ sendto_realops_snomask(SNO_GENERAL, L_ALL,
+ "%s added D-Line for [%s] [%s|%s]",
+ get_oper_name(source_p), aconf->host, reason, oper_reason);
+ ilog(L_KLINE, "D %s 0 %s %s|%s",
+ get_oper_name(source_p),
+ aconf->host, reason, oper_reason);
+ }
}
return 0;
return 0;
}
-/*
- * valid_comment
- * inputs - pointer to client
- * - pointer to comment
- * output - 0 if no valid comment, 1 if valid
- * side effects - NONE
- */
-static int
-valid_comment(char *comment)
-{
- if(strchr(comment, '"'))
- return 0;
-
- if(strlen(comment) > BANREASONLEN)
- comment[BANREASONLEN] = '\0';
-
- return 1;
-}
-
/* remove_temp_dline()
*
* inputs - confitem to undline