[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tkline-patch
Hi,
the following patch adds the command /tkline (/quote tkline) to the server.
That command allows an oper to kline temporary a user, which means that the
kline does only figure in the memory and it will disappear on
rehash/restart.
Syntax is: /tkline u@h reason
or: /tkline u@h :reason [if reason has more than one word]
The reason will be displayed to the user when he tries to reconnect, but if
and only if the server supports the kline-comment feature. ;-)
IMHO, this patch should be the first step towards the abolition of global
(oper) KILLs.
I've tested it a bit locally - works fine so far. I hope i got it all
right...
Bye, Kasi
PS BSD coding style rules. =)
PPS If this mail should arrive twice - sorry.
--- cut here ---
diff -cr irc2.9.3b14.old/include/msg.h irc2.9.3b14/include/msg.h
*** irc2.9.3b14.old/include/msg.h Mon Apr 14 17:13:50 1997
--- irc2.9.3b14/include/msg.h Wed Apr 23 20:21:00 1997
***************
*** 35,40 ****
--- 35,41 ----
#define MSG_QUIT "QUIT" /* QUIT */
#define MSG_SQUIT "SQUIT" /* SQUI */
#define MSG_KILL "KILL" /* KILL */
+ #define MSG_TKLINE "TKLINE" /* TKLI */
#define MSG_INFO "INFO" /* INFO */
#define MSG_LINKS "LINKS" /* LINK */
#define MSG_SUMMON "SUMMON" /* SUMM */
***************
*** 81,87 ****
extern int m_private(), m_topic(), m_join(), m_part(), m_mode();
extern int m_ping(), m_pong(), m_wallops(), m_kick();
extern int m_nick(), m_error(), m_notice();
! extern int m_invite(), m_quit(), m_kill();
#ifndef CLIENT_COMPILE
extern int m_motd(), m_who(), m_whois(), m_user(), m_list(), m_umode();
extern int m_server(), m_info(), m_links(), m_summon(), m_stats();
--- 82,88 ----
extern int m_private(), m_topic(), m_join(), m_part(), m_mode();
extern int m_ping(), m_pong(), m_wallops(), m_kick();
extern int m_nick(), m_error(), m_notice();
! extern int m_invite(), m_quit(), m_kill(), m_tkline();
#ifndef CLIENT_COMPILE
extern int m_motd(), m_who(), m_whois(), m_user(), m_list(), m_umode();
extern int m_server(), m_info(), m_links(), m_summon(), m_stats();
***************
*** 127,132 ****
--- 128,134 ----
{ MSG_KILL, m_kill, 0, MAXPARA, MSG_LAG|MSG_REG|MSG_NOU, 0L},
#endif
#ifndef CLIENT_COMPILE
+ { MSG_TKLINE, m_tkline, 0, MAXPARA, MSG_LAG|MSG_REGU|MSG_OP, 0L},
{ MSG_USER, m_user, 0, MAXPARA, MSG_LAG|MSG_NOU, 0L},
{ MSG_AWAY, m_away, 0, MAXPARA, MSG_LAG|MSG_REGU, 0L},
{ MSG_UMODE, m_umode, 0, MAXPARA, MSG_LAG|MSG_REGU, 0L},
diff -cr irc2.9.3b14.old/ircd/s_serv.c irc2.9.3b14/ircd/s_serv.c
*** irc2.9.3b14.old/ircd/s_serv.c Mon Apr 21 02:24:06 1997
--- irc2.9.3b14/ircd/s_serv.c Thu Apr 24 18:47:02 1997
***************
*** 1865,1870 ****
--- 1865,1974 ----
return 2;
}
+ /*
+ ** m_tkline
+ ** parv[0] = sender prefix
+ ** parv[1] = u@h of the tkline victim
+ ** parv[2] = optional kline comment
+ **
+ ** If the comment is composed by more than one word, it has to be
+ ** preceded by a colon (':').
+ **
+ ** e.g. tklining foo@xxxxxxx with the comment 'excess cloning'
+ ** -> /tkline foo@xxxxxxx :excess cloning
+ */
+ int m_tkline(cptr, sptr, parc, parv)
+ aClient *cptr, *sptr;
+ int parc;
+ char *parv[];
+ {
+ aConfItem *aconf;
+ char *user, *host;
+ char *comment = ((parc > 2) && parv[2]) ? parv[2] : "";
+
+ /* these are used by the local connections check */
+ Reg aClient *acptr;
+ Reg int kflag = 0;
+ int i;
+
+ if ((parc < 2) || (*parv[1] == '\0'))
+ {
+ sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS, parv[0]), "TKLINE");
+ return 1;
+ }
+
+ if (!index(parv[1], '@')) /* Only allow u@h masks, to avoid mistakes. */
+ {
+ sendto_one(sptr, ":%s NOTICE %s :You have to tkline a u@h mask.",
+ ME, parv[0]);
+ return 1;
+ }
+
+ /* point host to the first char after '@' */
+ host = index(parv[1], '@');
+ host++;
+
+ /* set '@' to NULL (0) to have the user part alone */
+ user = index(parv[1], '@');
+ *user = 0;
+ user = parv[1];
+
+ if ((strcmp(user, "*") == 0) && (strcmp(host, "*") == 0))
+ {
+ sendto_one(sptr, ":%s NOTICE %s :You cannot tkline *@*!", ME, parv[0]);
+ return 1;
+ }
+
+ /* the following block has been taken from comstud's +CS version */
+ aconf = make_conf();
+ aconf->status = CONF_KILL;
+ DupString(aconf->host, host);
+ DupString(aconf->name, user);
+ DupString(aconf->passwd, comment);
+ aconf->port = 0;
+ Class(aconf) = find_class(0);
+ aconf->next = conf;
+ conf = aconf;
+ aconf = NULL;
+
+ /* announce that the tkline has been added */
+ sendto_flag(SCH_LOCAL, "%s has added a temporary kline for %s@%s",
+ parv[0], user, host);
+
+ sendto_one(sptr, ":%s NOTICE %s :Added temporary kline for %s@%s",
+ ME, parv[0], user, host);
+
+ /* check for each local connection if the tkline matches */
+ for (i = highest_fd; i >= 0; i--)
+ {
+ if (!(acptr = local[i]) || IsListening(acptr) || IsLog(acptr) ||
+ IsHeld(acptr))
+ continue;
+
+ if (IsPerson(acptr))
+ {
+ char *reason; /* not used here, but necessary */
+
+ kflag = find_kill(acptr, 1, &reason);
+ }
+ else
+ continue;
+
+ if (kflag)
+ {
+ sendto_flag(SCH_NOTICE, "Kill line active for %s",
+ get_client_name(acptr, FALSE));
+ acptr->exitc = EXITC_KLINE;
+ (void)exit_client(acptr, acptr, &me, "Kill line active");
+ }
+ else
+ continue;
+ }
+
+ return 0;
+
+ }
+
#if defined(OPER_REHASH) || defined(LOCOP_REHASH)
/*
** m_rehash
--
Kaspar Landsberg, <kl@xxxxxxxxxxxxxxx>