From 853058531aa2387ce1e8ab77ec9b416e70c6bffa Mon Sep 17 00:00:00 2001 From: JD Horelick Date: Mon, 15 Mar 2010 15:35:32 -0400 Subject: [PATCH] Added m_cycle and added it to all the appropriate locations. --- NEWS | 3 ++ TODO-SHADOW | 1 - doc/example.conf | 1 + doc/reference.conf | 2 + extensions/Makefile.in | 1 + extensions/README | 3 ++ extensions/m_cycle.c | 98 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 extensions/m_cycle.c diff --git a/NEWS b/NEWS index 6404962..b60320a 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ new configuration options - general::no_part_messages - If this option is set to no, the ircd will not display PART messages/reasons from users. +new commands +- /CYCLE - server-side /CYCLE, also called /HOP in some clients/servers. + -- shadowircd-6.0.0 new modes diff --git a/TODO-SHADOW b/TODO-SHADOW index 7314bed..b5b06fd 100644 --- a/TODO-SHADOW +++ b/TODO-SHADOW @@ -7,7 +7,6 @@ Todo list for ShadowIRCd 6.1 * clean disable/removal of modes on rehash, if possible without being ugly * Allow disabling of commands in auth {} blocks. * Add default_operhost to /set -* /cycle Todo list for ShadowIRCd 6.2 ---------------------------- diff --git a/doc/example.conf b/doc/example.conf index 825bff8..c70151c 100755 --- a/doc/example.conf +++ b/doc/example.conf @@ -32,6 +32,7 @@ loadmodule "extensions/m_identify.so"; loadmodule "extensions/m_mkpasswd.so"; loadmodule "extensions/m_webirc.so"; #loadmodule "extensions/m_adminwall.so"; +#loadmodule "extensions/m_cycle.so"; #loadmodule "extensions/m_oaccept.so"; #loadmodule "extensions/m_opme.so"; #loadmodule "extensions/m_ojoin.so"; diff --git a/doc/reference.conf b/doc/reference.conf index 56d1894..c121af9 100755 --- a/doc/reference.conf +++ b/doc/reference.conf @@ -67,6 +67,7 @@ * /mkpassword support -- m_mkpasswd.so * WEBIRC support -- m_webirc.so * Send message to all admins network-wide -- m_adminwall.so + * Server-side /CYCLE -- m_cycle.so * /oaccept - add to target's accept list, oper only -- m_oaccept.so * /opme - op self in opless channels, admin only -- m_opme.so * /ojoin - join despite restrictions, admin only -- m_ojoin.so @@ -102,6 +103,7 @@ loadmodule "extensions/m_identify.so"; loadmodule "extensions/m_mkpasswd.so"; loadmodule "extensions/m_webirc.so"; #loadmodule "extensions/m_adminwall.so"; +#loadmodule "extensions/m_cycle.so"; #loadmodule "extensions/m_oaccept.so"; #loadmodule "extensions/m_opme.so"; #loadmodule "extensions/m_ojoin.so"; diff --git a/extensions/Makefile.in b/extensions/Makefile.in index 7a52949..d11e41c 100644 --- a/extensions/Makefile.in +++ b/extensions/Makefile.in @@ -52,6 +52,7 @@ SRCS = \ sno_whois.c \ m_42.c \ m_adminwall.c \ + m_cycle.c \ m_findforwards.c \ m_force.c \ m_identify.c \ diff --git a/extensions/README b/extensions/README index 6cc086c..9ba97b1 100644 --- a/extensions/README +++ b/extensions/README @@ -19,6 +19,9 @@ m_42.c - The Answer to Life, the Universe, and Everything. m_adminwall.c - Sends a message to all admins network-wide (umode +a) Syntax: ADMINWALL : +m_cycle - Server-side /CYCLE (also called /HOP in some clients/servers). + Syntax: CYCLE <#channel> + m_findforwards.c - Find channels that forward (+f) to a given channel. Syntax: FINDFORWARDS diff --git a/extensions/m_cycle.c b/extensions/m_cycle.c new file mode 100644 index 0000000..a0e8933 --- /dev/null +++ b/extensions/m_cycle.c @@ -0,0 +1,98 @@ +/* + * m_cycle.c: server-side CYCLE + * + * Copyright (c) 2010 The ShadowIRCd team + */ +#include "stdinc.h" +#include "common.h" +#include "channel.h" +#include "client.h" +#include "hash.h" +#include "match.h" +#include "ircd.h" +#include "numeric.h" +#include "send.h" +#include "s_conf.h" +#include "s_serv.h" +#include "msg.h" +#include "parse.h" +#include "modules.h" +#include "packet.h" +#include "hook.h" + +extern struct module **modlist; + +static int m_cycle(struct Client *, struct Client *, int, const char **); + +struct Message cycle_msgtab = { + "CYCLE", 0, 0, 0, MFLG_SLOW, + {mg_unreg, {m_cycle, 2}, {m_cycle, 2}, mg_ignore, mg_ignore, {m_cycle, 2}} +}; +mapi_clist_av1 cycle_clist[] = { &cycle_msgtab, NULL }; + +DECLARE_MODULE_AV1(cycle, NULL, NULL, cycle_clist, NULL, NULL, "$Revision$"); + +static int +m_cycle(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) +{ + char *p, *name; + char *s = LOCAL_COPY(parv[1]); + struct Channel *chptr; + struct membership *msptr; + + name = rb_strtok_r(s, ",", &p); + + /* Finish the flood grace period... */ + if(MyClient(source_p) && !IsFloodDone(source_p)) + flood_endgrace(source_p); + + while(name) + { + if((chptr = find_channel(name)) == NULL) + { + sendto_one_numeric(source_p, ERR_NOSUCHCHANNEL, form_str(ERR_NOSUCHCHANNEL), name); + return 0; + } + + msptr = find_channel_membership(chptr, source_p); + if(msptr == NULL) + { + sendto_one_numeric(source_p, ERR_NOTONCHANNEL, form_str(ERR_NOTONCHANNEL), name); + return 0; + } + + if(MyConnect(source_p) && !IsOper(source_p) && !IsExemptSpambot(source_p)) + check_spambot_warning(source_p, NULL); + + if((is_any_op(msptr) || !MyConnect(source_p) || + ((can_send(chptr, source_p, msptr) > 0 && + (source_p->localClient->firsttime + + ConfigFileEntry.anti_spam_exit_message_time) < rb_current_time())))) + { + sendto_server(client_p, chptr, CAP_TS6, NOCAPS, + ":%s PART %s :Cycling", use_id(source_p), chptr->chname); + sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s :Cycling", + source_p->name, source_p->username, + source_p->host, chptr->chname); + } + else + { + sendto_server(client_p, chptr, CAP_TS6, NOCAPS, + ":%s PART %s", use_id(source_p), chptr->chname); + sendto_channel_local(ALL_MEMBERS, chptr, ":%s!%s@%s PART %s", + source_p->name, source_p->username, + source_p->host, chptr->chname); + } + + remove_user_from_channel(msptr); + + chptr = NULL; + msptr = NULL; + + name = rb_strtok_r(NULL, ",", &p); + } + + user_join(client_p, source_p, parv[1], parc > 2 ? parv[2] : NULL); + + return 0; +}