+2000-04-13 Kevin L. Mitchell <klmitch@mit.edu>
+
+ * include/handlers.h: declare m_gline()
+
+ * ircd/parse.c: gline can be called by users, but it only lists
+ the glines.
+
+ * ircd/s_user.c (set_nick_name): resend gline if a remote server
+ introduces a glined client
+
+ * ircd/s_serv.c (server_estab): burst glines, too
+
+ * ircd/gline.c: fix up all the expire times to be offsets;
+ simplify gline_resend()
+
+ * ircd/m_gline.c: begin coding replacements for ms_gline(),
+ mo_gline(), and m_gline()
+
+ * ircd/gline.c (gline_add): allow *@#channel to work correctly;
+ also, prohibit local BADCHANs if LOCAL_BADCHAN not defined
+
2000-04-13 Greg Sikorski <gte@atomicrevs.demon.co.uk>
* tools/Bouncer/*: Add comments/documentation/tags.
#
# ChangeLog for ircu2.10.11
#
-# $Id: ChangeLog,v 1.77 2000-04-13 05:53:48 gte Exp $
+# $Id: ChangeLog,v 1.78 2000-04-13 15:58:22 kev Exp $
#
# Insert new changes at beginning of the change list.
#
extern int m_away(struct Client*, struct Client*, int, char*[]);
extern int m_cnotice(struct Client*, struct Client*, int, char*[]);
extern int m_cprivmsg(struct Client*, struct Client*, int, char*[]);
+extern int m_gline(struct Client*, struct Client*, int, char*[]);
extern int m_help(struct Client*, struct Client*, int, char*[]);
extern int m_ignore(struct Client*, struct Client*, int, char*[]);
extern int m_info(struct Client*, struct Client*, int, char*[]);
GlineIsActive(gline) ? '+' : '-', gline->gl_user,
GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
- gline->gl_expire, gline->gl_lastmod, gline->gl_reason);
+ gline->gl_expire - TStime(), gline->gl_lastmod,
+ gline->gl_reason);
} else {
if (gline->gl_lastmod)
sendto_serv_butone(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " "
GlineIsActive(gline) ? '+' : '-', gline->gl_user,
GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
- gline->gl_expire, gline->gl_lastmod,
+ gline->gl_expire - TStime(), gline->gl_lastmod,
gline->gl_reason);
else
sendto_serv_butone(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT
GlineIsActive(gline) ? '+' : '-', gline->gl_user,
GlineIsBadChan(gline) ? "" : "@",
GlineIsBadChan(gline) ? "" : gline->gl_host,
- gline->gl_expire, gline->gl_reason);
+ gline->gl_expire - TStime(), gline->gl_reason);
}
}
expire += TStime(); /* convert from lifetime to timestamp */
+ /* NO_OLD_GLINE allows *@#channel to work correctly */
#ifdef BADCHAN
- if (*userhost == '#' || *userhost == '&' || *userhost == '+')
+ if (*userhost == '#' || *userhost == '&' || *userhost == '+'
+# ifndef NO_OLD_GLINE
+ || userhost[2] == '#' || userhost[2] == '&' || userhost[2] == '+'
+# endif /* OLD_GLINE */
+ ) {
+# ifndef LOCAL_BADCHAN
+ if (flags & GLINE_LOCAL)
+ return 0;
+# endif
flags |= GLINE_BADCHAN;
-#endif
+ }
+#endif /* BADCHAN */
/* Inform ops... */
sendto_op_mask(SNO_GLINE, "%s adding %s %s for %s, expiring at "
else if (!GlineIsLocal(gline) && gline->gl_lastmod)
sendto_one(cptr, "%s " TOK_GLINE " * %c%s@%s " TIME_T_FMT " " TIME_T_FMT
" :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
- gline->gl_user, gline->gl_host, gline->gl_expire,
+ gline->gl_user, gline->gl_host, gline->gl_expire - TStime(),
gline->gl_lastmod, gline->gl_reason);
}
else if (!GlineIsLocal(gline) && gline->gl_lastmod)
sendto_one(cptr, "%s " TOK_GLINE " * %c%s " TIME_T_FMT " " TIME_T_FMT
" :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
- gline->gl_user, gline->gl_expire, gline->gl_lastmod,
- gline->gl_reason);
+ gline->gl_user, gline->gl_expire - TStime(),
+ gline->gl_lastmod, gline->gl_reason);
}
}
if (GlineIsLocal(gline) || !gline->gl_lastmod)
return 0;
- if (GlineIsBadChan(gline))
- sendto_one(cptr, "%s " TOK_GLINE " * %c%s " TIME_T_FMT " " TIME_T_FMT
- " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
- gline->gl_user, gline->gl_expire, gline->gl_lastmod,
- gline->gl_reason);
- else
- sendto_one(cptr, "%s " TOK_GLINE " * %c%s@%s " TIME_T_FMT " " TIME_T_FMT
- " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
- gline->gl_user, gline->gl_host, gline->gl_expire,
- gline->gl_lastmod, gline->gl_reason);
+ sendto_one(cptr, "%s " TOK_GLINE " * %c%s%s%s " TIME_T_FMT " " TIME_T_FMT
+ " :%s", NumServ(&me), GlineIsActive(gline) ? '+' : '-',
+ gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
+ GlineIsBadChan(gline) ? "" : gline->gl_host,
+ gline->gl_expire - TStime(), gline->gl_lastmod, gline->gl_reason);
return 0;
}
#include <stdlib.h>
#include <string.h>
+/*
+ * ms_gline - server message handler
+ *
+ * parv[0] = Sender prefix
+ * parv[1] = Target: server numeric
+ * parv[2] = (+|-)<G-line mask>
+ * parv[3] = G-line lifetime
+ *
+ * From Uworld:
+ *
+ * parv[4] = Comment
+ *
+ * From somewhere else:
+ *
+ * parv[4] = Last modification time
+ * parv[5] = Comment
+ *
+ */
+int
+ms_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+ struct Client *acptr = 0;
+ struct Gline *agline;
+ unsigned int flags = 0;
+ time_t expire_off, lastmod = 0;
+ char *mask = parv[2], *target = parv[1], *reason;
+
+ if (parc == 4) {
+ if (!find_conf_byhost(cptr->confs, sptr->name, CONF_UWORLD))
+ return need_more_params(sptr, "GLINE");
+
+ reason = parv[4];
+ flags |= GLINE_FORCE;
+ } else if (parc >= 5) {
+ lastmod = atoi(parv[4]);
+ reason = parv[5];
+ } else
+ return need_more_params(sptr, "GLINE");
+
+ if (!(target[0] == '*' && target[1] == '\0')) {
+ if (!(acptr = FindNServer(target)))
+ return 0; /* no such server */
+
+ if (!IsMe(acptr)) { /* manually propagate */
+ if (IsServer(sptr)) {
+ if (!lastmod)
+ sendto_one(acptr, "%s " TOK_GLINE " %s %s %s :%s", NumServ(sptr),
+ target, mask, parv[3], reason);
+ else
+ sendto_one(acptr, "%s " TOK_GLINE " %s %s %s %s :%s", NumServ(sptr),
+ target, mask, parv[3], parv[4], reason);
+ } else
+ sendto_one(acptr, "%s%s " TOK_GLINE " %s %s %s %s :%s", NumNick(sptr),
+ target, mask, parv[3], parv[4], reason);
+
+ return 0;
+ }
+
+ flags |= GLINE_LOCAL;
+ }
+
+ if (*server == '-')
+ server++;
+ else if (*server == '+') {
+ flags |= GLINE_ACTIVE;
+ server++;
+ } else
+ flags |= GLINE_ACTIVE;
+
+ expire_off = atoi(parv[3]);
+
+ agline = gline_find(mask, GLINE_ANY);
+
+ if (agline) {
+ if (GlineIsLocal(agline) && !(flags & GLINE_LOCAL)) /* global over local */
+ gline_free(agline);
+ else if (!lastmod || GlineLastMod(agline) < lastmod) { /* new mod */
+ if (flags & GLINE_ACTIVE)
+ return gline_activate(cptr, sptr, agline, lastmod);
+ else
+ return gline_deactivate(cptr, sptr, agline, lastmod);
+ } else if (GlineLastMod(agline) == lastmod)
+ return 0;
+ else
+ return gline_resend(cptr, agline); /* other server desynched WRT gline */
+ }
+
+ return gline_add(cptr, sptr, mask, reason, expire_off, lastmod, flags);
+}
+
+/*
+ * mo_gline - oper message handler
+ *
+ * parv[0] = Sender prefix
+ * parv[1] = [[+|-]<G-line mask>]
+ *
+ * Old style:
+ *
+ * parv[2] = [Expiration offset]
+ * parv[3] = [Comment]
+ *
+ * New style:
+ *
+ * parv[2] = [target]
+ * parv[3] = [Expiration offset]
+ * parv[4] = [Comment]
+ *
+ */
+int
+mo_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+ struct Client *acptr = 0;
+ struct Gline *agline;
+ unsigned int flags = 0;
+ time_t expire_off;
+ char *mask = parv[1], *target = 0, *reason;
+
+ if (parc < 2)
+ return gline_list(sptr, 0);
+
+ if (*mask == '+') {
+ flags |= GLINE_ACTIVE;
+ mask++;
+ } else if (*mask == '-')
+ mask++;
+ else
+ return gline_list(sptr, mask);
+
+#ifndef LOCOP_LGLINE
+ if (!IsOper(sptr)) {
+ send_error_to_client(sptr, ERR_NOPRIVILEGES);
+ return 0;
+ }
+#endif
+
+ if (parc == 3) {
+ expire_off = atoi(parv[2]);
+ reason = parv[3];
+ flags |= GLINE_LOCAL;
+ } else if (parc >= 4) {
+ target = parv[2];
+ expire_off = atoi(parv[3]);
+ reason = parv[4];
+ } else
+ return need_more_params(sptr, "GLINE");
+
+ if (target) {
+ if (!(target[0] == '*' && target[1] == '\0')) {
+ if (!(acptr = find_match_server(target))) {
+ send_error_to_client(sptr, ERR_NOSUCHSERVER, target);
+ return 0;
+ }
+
+ if (!IsMe(acptr)) { /* manually propagate, since we don't set it */
+ if (!IsOper(sptr)) {
+ send_error_to_client(sptr, ERR_NOPRIVILEGES);
+ return 0;
+ }
+
+ sendto_one(acptr, "%s%s " TOK_GLINE " %s %c%s %s " TIME_T_FMT " :%s",
+ NumNick(sptr), NumServ(acptr),
+ flags & GLINE_ACTIVE ? '?' : '-', mask, parv[3], TStime(),
+ reason);
+ return 0;
+ }
+
+ flags |= GLINE_LOCAL;
+ } else if (!IsOper(sptr)) {
+ send_error_to_client(sptr, ERR_NOPRIVILEGES);
+ return 0;
+ }
+ }
+
+ agline = gline_find(mask, GLINE_ANY);
+
+ if (agline) {
+ if (GlineIsLocal(agline) && !(flags & GLINE_LOCAL)) /* global over local */
+ gline_free(agline);
+ else {
+ if (flags & GLINE_ACTIVE)
+ return gline_activate(cptr, sptr, agline, TStime());
+ else
+ return gline_deactivate(cptr, sptr, agline, TStime());
+ }
+ }
+
+ return gline_add(cptr, sptr, mask, reason, expire_off, TStime(), flags);
+}
+
+/*
+ * m_gline - user message handler
+ *
+ * parv[0] = Sender prefix
+ * parv[1] = [<server name>]
+ *
+ */
+int
+m_gline(struct Client *cptr, struct Client *sptr, int parc, char *parv[])
+{
+ if (parc < 2)
+ return gline_list(sptr, 0);
+
+ return gline_list(sptr, parv[1]);
+}
+
+#if 0
/*
* ms_gline - server message handler
*
#endif /* 0 */
+#endif /* 0 */
TOK_GLINE,
0, MAXPARA, MFLG_SLOW, 0,
/* UNREG, CLIENT, SERVER, OPER, SERVICE */
- { m_unregistered, m_not_oper, ms_gline, mo_gline, m_ignore }
+ { m_unregistered, m_gline, ms_gline, mo_gline, m_ignore }
},
{
MSG_JUPE,
#include "channel.h"
#include "client.h"
#include "crule.h"
+#include "gline.h"
#include "hash.h"
#include "ircd.h"
#include "ircd_alloc.h"
send_channel_modes(cptr, chptr);
}
jupe_burst(cptr);
+ gline_burst(cptr);
sendto_one(cptr, "%s EB", NumServ(&me));
return 0;
}
#include "channel.h"
#include "class.h"
#include "client.h"
+#include "gline.h"
#include "hash.h"
#include "ircd.h"
#include "ircd_alloc.h"
if (IsServer(sptr)) {
int i;
const char* p;
+ struct Gline *gline;
/*
* A server introducing a new client, change source
ircd_strncpy(new_client->username, parv[4], USERLEN);
ircd_strncpy(new_client->user->host, parv[5], HOSTLEN);
ircd_strncpy(new_client->info, parv[parc - 1], REALLEN);
+ if ((gline = gline_lookup(new_client)) && GlineIsActive(gline))
+ gline_resend(cptr, gline);
return register_user(cptr, new_client, new_client->name, parv[4]);
}
else if (sptr->name[0]) {