[IRC-Dev CVS] SF.net SVN: irc-dev:[221] ircd/trunk
Brought to you by:
zolty
From: <zo...@us...> - 2008-10-25 20:36:50
|
Revision: 221 http://irc-dev.svn.sourceforge.net/irc-dev/?rev=221&view=rev Author: zolty Date: 2008-10-25 20:36:42 +0000 (Sat, 25 Oct 2008) Log Message: ----------- Nuevos comandos administrativos, bajo compilacion condicional Modified Paths: -------------- ircd/trunk/include/handlers.h ircd/trunk/include/msg.h ircd/trunk/ircd/Makefile.am ircd/trunk/ircd/Makefile.in ircd/trunk/ircd/parse.c Added Paths: ----------- ircd/trunk/ircd/m_svsjoin.c ircd/trunk/ircd/m_svsmode.c ircd/trunk/ircd/m_svspart.c Modified: ircd/trunk/include/handlers.h =================================================================== --- ircd/trunk/include/handlers.h 2008-10-25 15:33:58 UTC (rev 220) +++ ircd/trunk/include/handlers.h 2008-10-25 20:36:42 UTC (rev 221) @@ -241,6 +241,9 @@ extern int ms_squit(struct Client*, struct Client*, int, char*[]); extern int ms_stats(struct Client*, struct Client*, int, char*[]); extern int ms_svsnick(struct Client*, struct Client*, int, char*[]); +extern int ms_svsmode(struct Client*, struct Client*, int, char*[]); +extern int ms_svsjoin(struct Client*, struct Client*, int, char*[]); +extern int ms_svspart(struct Client*, struct Client*, int, char*[]); extern int ms_topic(struct Client*, struct Client*, int, char*[]); extern int ms_trace(struct Client*, struct Client*, int, char*[]); extern int ms_uping(struct Client*, struct Client*, int, char*[]); Modified: ircd/trunk/include/msg.h =================================================================== --- ircd/trunk/include/msg.h 2008-10-25 15:33:58 UTC (rev 220) +++ ircd/trunk/include/msg.h 2008-10-25 20:36:42 UTC (rev 221) @@ -389,15 +389,27 @@ #define MSG_SVSNICK "SVSNICK" /* SVSN */ #define TOK_SVSNICK "SN" #define CMD_SVSNICK MSG_SVSNICK, TOK_SVSNICK + #if 1 /* TRANSICION IRC-HISPANO */ #define MSG_RENAME "RENAME" /* SVSN */ #define TOK_RENAME "RENAME" #define CMD_RENAME MSG_RENAME, TOK_RENAME - #endif +#define MSG_SVSMODE "SVSMODE" +#define TOK_SVSMODE "SM" +#define CMD_SVSMODE MSG_SVSMODE, TOK_SVSMODE +#define MSG_SVSJOIN "SVSJOIN" +#define TOK_SVSJOIN "SJ" +#define CMD_SVSJOIN MSG_SVSJOIN, TOK_SVSJOIN +#define MSG_SVSPART "SVSPART" +#define TOK_SVSPART "SL" +#define CMD_SVSPART MSG_SVSPART, TOK_SVSPART + + + /* * Constants */ Modified: ircd/trunk/ircd/Makefile.am =================================================================== --- ircd/trunk/ircd/Makefile.am 2008-10-25 15:33:58 UTC (rev 220) +++ ircd/trunk/ircd/Makefile.am 2008-10-25 20:36:42 UTC (rev 221) @@ -195,12 +195,18 @@ m_db.c \ m_dbq.c \ m_ghost.c \ - m_svsnick.c + m_svsnick.c \ + m_svsmode.c \ + m_svsjoin.c \ + m_svspart.c endif #if ENVIRONMENT_SERVICES #ircd_SOURCES += \ -# m_svsnick.c +# m_svsnick.c \ +# m_svsmode.c \ +# m_svsjoin.c \ +# m_svspart.c #endif Modified: ircd/trunk/ircd/Makefile.in =================================================================== --- ircd/trunk/ircd/Makefile.in 2008-10-25 15:33:58 UTC (rev 220) +++ ircd/trunk/ircd/Makefile.in 2008-10-25 20:36:42 UTC (rev 221) @@ -48,12 +48,18 @@ @ENVIRONMENT_DDB_TRUE@ m_db.c \ @ENVIRONMENT_DDB_TRUE@ m_dbq.c \ @ENVIRONMENT_DDB_TRUE@ m_ghost.c \ -@ENVIRONMENT_DDB_TRUE@ m_svsnick.c +@ENVIRONMENT_DDB_TRUE@ m_svsnick.c \ +@ENVIRONMENT_DDB_TRUE@ m_svsmode.c \ +@ENVIRONMENT_DDB_TRUE@ m_svsjoin.c \ +@ENVIRONMENT_DDB_TRUE@ m_svspart.c #if ENVIRONMENT_SERVICES #ircd_SOURCES += \ -# m_svsnick.c +# m_svsnick.c \ +# m_svsmode.c \ +# m_svsjoin.c \ +# m_svspart.c #endif @ENGINE_POLL_TRUE@am__append_2 = engine_poll.c @ENGINE_POLL_FALSE@am__append_3 = engine_select.c @@ -102,14 +108,16 @@ s_debug.c s_err.c s_misc.c s_numeric.c s_serv.c s_stats.c \ s_user.c send.c ssl.c uping.c userload.c watch.c whowas.c \ ddb.c ddb_db_native.c ddb_events.c ircd_tea.c m_bmode.c m_db.c \ - m_dbq.c m_ghost.c m_svsnick.c engine_poll.c engine_select.c \ - engine_devpoll.c engine_epoll.c engine_kqueue.c + m_dbq.c m_ghost.c m_svsnick.c m_svsmode.c m_svsjoin.c \ + m_svspart.c engine_poll.c engine_select.c engine_devpoll.c \ + engine_epoll.c engine_kqueue.c @ENVIRONMENT_DDB_TRUE@am__objects_1 = ddb.$(OBJEXT) \ @ENVIRONMENT_DDB_TRUE@ ddb_db_native.$(OBJEXT) \ @ENVIRONMENT_DDB_TRUE@ ddb_events.$(OBJEXT) ircd_tea.$(OBJEXT) \ @ENVIRONMENT_DDB_TRUE@ m_bmode.$(OBJEXT) m_db.$(OBJEXT) \ @ENVIRONMENT_DDB_TRUE@ m_dbq.$(OBJEXT) m_ghost.$(OBJEXT) \ -@ENVIRONMENT_DDB_TRUE@ m_svsnick.$(OBJEXT) +@ENVIRONMENT_DDB_TRUE@ m_svsnick.$(OBJEXT) m_svsmode.$(OBJEXT) \ +@ENVIRONMENT_DDB_TRUE@ m_svsjoin.$(OBJEXT) m_svspart.$(OBJEXT) @ENGINE_POLL_TRUE@am__objects_2 = engine_poll.$(OBJEXT) @ENGINE_POLL_FALSE@am__objects_3 = engine_select.$(OBJEXT) @ENGINE_DEVPOLL_TRUE@am__objects_4 = engine_devpoll.$(OBJEXT) @@ -535,7 +543,10 @@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_silence.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_squit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_stats.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_svsjoin.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_svsmode.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_svsnick.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_svspart.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_time.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_topic.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/m_trace.Po@am__quote@ Added: ircd/trunk/ircd/m_svsjoin.c =================================================================== --- ircd/trunk/ircd/m_svsjoin.c (rev 0) +++ ircd/trunk/ircd/m_svsjoin.c 2008-10-25 20:36:42 UTC (rev 221) @@ -0,0 +1,174 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/m_svsjoin.c + * + * Copyright (C) 2002-2008 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2008 Toni Garcia (zoltan) <zo...@ir...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/** @file + * @brief Handlers for SVSJOIN command. + * @version $Id: m_svsnick.c,v 1.6 2007-04-22 13:56:21 zolty Exp $ + */ +#include "config.h" + +#include "channel.h" +#include "client.h" +#include "ddb.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_features.h" +#include "ircd_log.h" +#include "ircd_string.h" +#include "msg.h" +#include "numeric.h" +#include "numnicks.h" +#include "s_user.h" +#include "send.h" + +/* #include <assert.h> -- Now using assert in ircd_log.h */ +#include <stdio.h> +#include <string.h> + + +/** Handle a SVSJOIN command from a server. + * See @ref m_functions for general discussion of parameters. + * + * \a parv has the following elements when \a sptr is a server: + * \li parv[1] is a nick + * \li \a parv[2] is a comma-separated list of channel names + * + * @param[in] cptr Client that sent us the message. + * @param[in] sptr Original source of message. + * @param[in] parc Number of arguments. + * @param[in] parv Argument vector. + */ +int ms_svsjoin(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + struct Channel *chptr; + struct JoinBuf join; + struct JoinBuf create; + struct Client *acptr; + char *p = 0; + char *chanlist; + char *name; + + assert(0 != IsServer(cptr)); + + if (parc < 3) + return 0; + + if (!cli_uworld(sptr)) + { + sendcmdto_serv(&me, CMD_DESYNCH, 0, + ":HACK(2): Fail SVSJOIN for %s. From %C", parv[1], sptr); + sendto_opmask(0, SNO_HACK2, + "Fail SVSJOIN for %s. From %C", parv[1], sptr); + return 0; + } + + sendcmdto_serv(sptr, CMD_SVSJOIN, cptr, "%s :%s", parv[1], parv[2]); + + acptr = findNUser(parv[1]); + + if (!acptr || !MyUser(acptr)) + return 0; + + sendto_opmask(0, SNO_HACK4, + "SVSJOIN for %C, channels %s. From %C", acptr, parv[2], sptr); + + joinbuf_init(&join, acptr, acptr, JOINBUF_TYPE_JOIN, 0, 0); + joinbuf_init(&create, acptr, acptr, JOINBUF_TYPE_CREATE, 0, TStime()); + +#if 0 + chanlist = last0(acptr, acptr, parv[2]); /* find last "JOIN 0" */ + + for (name = ircd_strtok(&p, chanlist, ","); name; + name = ircd_strtok(&p, 0, ",")) { +#endif + for (name = ircd_strtok(&p, parv[2], ","); name; + name = ircd_strtok(&p, 0, ",")) { + + if (!IsChannelName(name) || !strIsIrcCh(name)) + { + /* bad channel name */ + continue; + } + + if (!(chptr = FindChannel(name))) { + if (((name[0] == '&') && !feature_bool(FEAT_LOCAL_CHANNELS)) + || strlen(name) >= IRCD_MIN(CHANNELLEN, feature_uint(FEAT_CHANNELLEN))) { + continue; + } + + if (!(chptr = get_channel(sptr, name, CGT_CREATE))) + continue; + +#if defined(UNDERNET) + joinbuf_join(&create, chptr, CHFL_CHANOP | CHFL_CHANNEL_MANAGER); +#else + joinbuf_join(&create, chptr, CHFL_CHANOP); +#endif + + } else if (find_member_link(chptr, sptr)) { + continue; /* already on channel */ + } else { + int flags = 0; +#if defined(DDB) + struct Ddb *ddb = ddb_find_key(DDB_CHANDB, chptr->chname); + + if (ddb && !ircd_strcmp(ddb_content(ddb), cli_name(sptr))) + flags = CHFL_OWNER; +#endif + + joinbuf_join(&join, chptr, flags); + cli_last_join(acptr) = CurrentTime; + + if (flags & CHFL_CHANOP) { + struct ModeBuf mbuf; + /* Always let the server op him: this is needed on a net with older servers + because they 'destruct' channels immediately when they become empty without + sending out a DESTRUCT message. As a result, they would always bounce a mode + (as HACK(2)) when the user ops himself. + (There is also no particularly good reason to have the user op himself.) + */ + modebuf_init(&mbuf, &me, acptr, chptr, MODEBUF_DEST_SERVER); +#if defined(UNDERNET) + modebuf_mode_client(&mbuf, MODE_ADD | MODE_CHANOP, acptr, (flags & CHFL_CHANNEL_MANAGER) ? 0 : 1)); +#elif defined(DDB) || defined(SERVICES) + modebuf_mode_client(&mbuf, MODE_ADD | MODE_CHANOP, acptr, 0); +#endif + modebuf_flush(&mbuf); + } + } + + del_invite(sptr, chptr); + + if (chptr->topic[0]) { + send_reply(acptr, RPL_TOPIC, chptr->chname, chptr->topic); + send_reply(acptr, RPL_TOPICWHOTIME, chptr->chname, chptr->topic_nick, + chptr->topic_time); + } + + do_names(acptr, chptr, NAMES_ALL|NAMES_EON); /* send /names list */ + } + + joinbuf_flush(&join); /* must be first, if there's a JOIN 0 */ + joinbuf_flush(&create); + + return 0; + +} Added: ircd/trunk/ircd/m_svsmode.c =================================================================== --- ircd/trunk/ircd/m_svsmode.c (rev 0) +++ ircd/trunk/ircd/m_svsmode.c 2008-10-25 20:36:42 UTC (rev 221) @@ -0,0 +1,88 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/m_svsmode.c + * + * Copyright (C) 2002-2008 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2008 Toni Garcia (zoltan) <zo...@ir...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/** @file + * @brief Handlers for SVSMODE command. + * @version $Id: m_svsmode.c,v 1.6 2007-04-22 13:56:21 zolty Exp $ + */ +#include "config.h" + +#include "channel.h" +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_log.h" +#include "ircd_snprintf.h" +#include "ircd_string.h" +#include "msg.h" +#include "numnicks.h" +#include "s_conf.h" +#include "s_user.h" +#include "send.h" + +/* #include <assert.h> -- Now using assert in ircd_log.h */ +#include <stdio.h> +#include <string.h> + + +/** Handle a SVSMODE command from a server. + * See @ref m_functions for general discussion of parameters. + * + * \a parv[1] is a nick + * \a parv[2] is a new nick (* random nick) + * + * @param[in] cptr Client that sent us the message. + * @param[in] sptr Original source of message. + * @param[in] parc Number of arguments. + * @param[in] parv Argument vector. + */ +int ms_svsmode(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + struct Channel *chptr = 0; + + assert(0 != IsServer(cptr)); + + if (parc < 3) + return 0; + + if (!cli_uworld(sptr)) + { + sendcmdto_serv(&me, CMD_DESYNCH, 0, + ":HACK(2): Fail SVSMODE for %s. From %C", parv[1], sptr); + sendto_opmask(0, SNO_HACK2, + "Fail SVSMODE for %s. From %C", parv[1], sptr); + return 0; + } + + if (!IsChannelName(parv[1]) || !(chptr = FindChannel(parv[1]))) + { + struct Client *acptr; + + acptr = findNUser(parv[1]); + if (!acptr) + acptr = FindUser(parv[1]); + if (!acptr) + return 0; + } + + /* No change modes for channels */ + return 0; +} Added: ircd/trunk/ircd/m_svspart.c =================================================================== --- ircd/trunk/ircd/m_svspart.c (rev 0) +++ ircd/trunk/ircd/m_svspart.c 2008-10-25 20:36:42 UTC (rev 221) @@ -0,0 +1,132 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/m_svspart.c + * + * Copyright (C) 2002-2008 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2008 Toni Garcia (zoltan) <zo...@ir...> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +/** @file + * @brief Handlers for SVSPART command. + * @version $Id: m_svsnick.c,v 1.6 2007-04-22 13:56:21 zolty Exp $ + */ +#include "config.h" + +#include "channel.h" +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_log.h" +#include "ircd_string.h" +#include "msg.h" +#include "numeric.h" +#include "numnicks.h" +#include "s_user.h" +#include "send.h" + +/* #include <assert.h> -- Now using assert in ircd_log.h */ +#include <stdio.h> +#include <string.h> + + +/** Handle a SVSPART command from a server. + * See @ref m_functions for general discussion of parameters. + * + * \a parv has the following elements when \a sptr is a server: + * \li parv[1] is a nick + * \li \a parv[2] is a comma-separated list of channel names + * \li \a parv[\a parc - 1] is the parting comment + * + * @param[in] cptr Client that sent us the message. + * @param[in] sptr Original source of message. + * @param[in] parc Number of arguments. + * @param[in] parv Argument vector. + */ +int ms_svspart(struct Client* cptr, struct Client* sptr, int parc, char* parv[]) +{ + struct Channel *chptr; + struct Membership *member; + struct JoinBuf parts; + struct Client *acptr; + unsigned int flags = 0; + char *p = 0; + char *name; + + assert(0 != IsServer(cptr)); + + if (parc < 3) + return 0; + + if (!cli_uworld(sptr)) + { + sendcmdto_serv(&me, CMD_DESYNCH, 0, + ":HACK(2): Fail SVSPART for %s. From %C", parv[1], + sptr); + sendto_opmask(0, SNO_HACK2, + "Fail SVSPART for %s. From %C", parv[1], sptr); + return 0; + } + + if (parc > 3) + sendcmdto_serv(sptr, CMD_SVSPART, cptr, "%s %s :%s", parv[1], parv[2], parv[3]); + else + sendcmdto_serv(sptr, CMD_SVSPART, cptr, "%s %s", parv[1], parv[2]); + + acptr = findNUser(parv[1]); + + if (!acptr || !MyUser(acptr)) + return 0; + + sendto_opmask(0, SNO_HACK4, + "SVSPART for %C, channels %s. From %C", acptr, parv[2], sptr); + + /* init join/part buffer */ + joinbuf_init(&parts, acptr, cptr, JOINBUF_TYPE_PART, + (parc > 3 && !EmptyString(parv[parc - 1])) ? parv[parc - 1] : 0, + 0); + + /* scan through channel list */ + for (name = ircd_strtok(&p, parv[2], ","); name; + name = ircd_strtok(&p, 0, ",")) { + + chptr = get_channel(acptr, name, CGT_NO_CREATE); /* look up channel */ + + if (!chptr) { /* complain if there isn't such a channel */ + continue; + } + + if (!(member = find_member_link(chptr, acptr))) { /* complain if not on */ + continue; + } + + assert(!IsZombie(member)); /* Local users should never zombie */ + + if (!member_can_send_to_channel(member, 0)) + { + flags |= CHFL_BANNED; + /* Remote clients don't want to see a comment either. */ + parts.jb_comment = 0; + } + + if (IsDelayedJoin(member)) + flags |= CHFL_DELAYED; + + joinbuf_join(&parts, chptr, flags); /* part client from channel */ + + } + + return joinbuf_flush(&parts); /* flush channel parts */ +} Modified: ircd/trunk/ircd/parse.c =================================================================== --- ircd/trunk/ircd/parse.c 2008-10-25 15:33:58 UTC (rev 220) +++ ircd/trunk/ircd/parse.c 2008-10-25 20:36:42 UTC (rev 221) @@ -667,7 +667,7 @@ TOK_GHOST, 0, MAXPARA, MFLG_SLOW, 0, NULL, /* UNREG, CLIENT, SERVER, OPER, SERVICE */ - { m_unregistered, m_ghost, m_ignore, m_ignore, m_ignore } + { m_unregistered, m_ghost, m_ignore, m_ghost, m_ignore } }, #endif #if defined(DDB) || defined(SERVICES) @@ -678,6 +678,27 @@ /* UNREG, CLIENT, SERVER, OPER, SERVICE */ { m_ignore, m_ignore, ms_svsnick, m_ignore, m_ignore } }, + { + MSG_SVSMODE, + TOK_SVSMODE, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_ignore, m_ignore, ms_svsmode, m_ignore, m_ignore } + }, + { + MSG_SVSJOIN, + TOK_SVSJOIN, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_ignore, m_ignore, ms_svsjoin, m_ignore, m_ignore } + }, + { + MSG_SVSPART, + TOK_SVSPART, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_ignore, m_ignore, ms_svspart, m_ignore, m_ignore } + }, #if 1 /* TRANSICION IRC-HISPANO */ { "RENAME", This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |