[IRC-Dev CVS] [CVS] Module ircd-ircdev: Change committed
Brought to you by:
zolty
From: Toni G. <zo...@us...> - 2005-05-25 16:56:43
|
CVSROOT : /cvsroot/irc-dev Module : ircd-ircdev Commit time: 2005-05-25 16:56:35 UTC Modified files: ChangeLog ChangeLog.es include/channel.h include/ddb.h include/handlers.h include/msg.h include/patchlevel.h include/send.h include/supported.h ircd/Makefile.in ircd/channel.c ircd/ddb.c ircd/ddb_events.c ircd/hash.c ircd/m_join.c ircd/m_kick.c ircd/m_mode.c ircd/m_names.c ircd/m_whois.c ircd/parse.c ircd/s_user.c ircd/send.c ircd/whocmds.c Added files: ircd/m_bmode.c Log message: Author: zoltan <zo...@ir...> Log message: 2005-05-25 Toni García <zo...@ir...> 1.0.alpha37 * Canales registrados (con modo +r) * Modo owner/founder (+q) * Tabla c de Canales ---------------------- diff included ---------------------- Index: ircd-ircdev/ChangeLog diff -u ircd-ircdev/ChangeLog:1.38 ircd-ircdev/ChangeLog:1.39 --- ircd-ircdev/ChangeLog:1.38 Mon May 23 01:58:36 2005 +++ ircd-ircdev/ChangeLog Wed May 25 09:56:22 2005 @@ -1,10 +1,15 @@ # # ChangeLog for ircd-ircdev # -# $Id: ChangeLog,v 1.38 2005/05/23 08:58:36 zolty Exp $ +# $Id: ChangeLog,v 1.39 2005/05/25 16:56:22 zolty Exp $ # # Insert new changes at beginning of the change list. # +2005-05-25 Toni García <zo...@ir...> 1.0.alpha37 + * Registered channels (with mode +r) + * Owner/founder mode (+q) + * Channel table c + 2005-05-23 Toni García <zo...@ir...> 1.0.alpha36 * URGENT bugfixes Index: ircd-ircdev/ChangeLog.es diff -u ircd-ircdev/ChangeLog.es:1.38 ircd-ircdev/ChangeLog.es:1.39 --- ircd-ircdev/ChangeLog.es:1.38 Mon May 23 01:58:36 2005 +++ ircd-ircdev/ChangeLog.es Wed May 25 09:56:22 2005 @@ -1,10 +1,15 @@ # # Log de Cambios para ircd-ircdev # -# $Id: ChangeLog.es,v 1.38 2005/05/23 08:58:36 zolty Exp $ +# $Id: ChangeLog.es,v 1.39 2005/05/25 16:56:22 zolty Exp $ # # Insertar los nuevos cambios al principio de esta lista de cambios. # +2005-05-25 Toni García <zo...@ir...> 1.0.alpha37 + * Canales registrados (con modo +r) + * Modo owner/founder (+q) + * Tabla c de Canales + 2005-05-23 Toni García <zo...@ir...> 1.0.alpha36 * Arreglos URGENTES Index: ircd-ircdev/include/channel.h diff -u ircd-ircdev/include/channel.h:1.9 ircd-ircdev/include/channel.h:1.10 --- ircd-ircdev/include/channel.h:1.9 Wed Mar 9 10:12:32 2005 +++ ircd-ircdev/include/channel.h Wed May 25 09:56:23 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Channel management and maintenance. - * @version $Id: channel.h,v 1.9 2005/03/09 18:12:32 zolty Exp $ + * @version $Id: channel.h,v 1.10 2005/05/25 16:56:23 zolty Exp $ */ #ifndef INCLUDED_channel_h #define INCLUDED_channel_h @@ -91,9 +91,18 @@ */ #define CHFL_DELAYED 0x40000 /**< User's join message is delayed */ +#if defined(DDB) || defined(SERVICES) +#define CHFL_OWNER 0x10000 /**< Channel owner */ + +#define CHFL_OVERLAP (CHFL_OWNER | CHFL_CHANOP | CHFL_VOICE) +#define CHFL_BANVALIDMASK (CHFL_BANVALID | CHFL_BANNED) +#define CHFL_VOICED_OR_OPPED (CHFL_OWNER | CHFL_CHANOP | CHFL_VOICE) +#else + #define CHFL_OVERLAP (CHFL_CHANOP | CHFL_VOICE) #define CHFL_BANVALIDMASK (CHFL_BANVALID | CHFL_BANNED) #define CHFL_VOICED_OR_OPPED (CHFL_CHANOP | CHFL_VOICE) +#endif /* Channel Visibility macros */ @@ -108,8 +117,12 @@ #define MODE_KEY 0x0100 /**< +k Keyed */ #define MODE_BAN 0x0200 /**< +b Ban */ #define MODE_LIMIT 0x0400 /**< +l Limit */ -#define MODE_REGONLY 0x0800 /**< Only +r users may join */ +#define MODE_REGONLY 0x0800 /**< +R Only +r users may join */ #define MODE_DELJOINS 0x1000 /**< New join messages are delayed */ +#if defined(DDB) || defined(SERVICES) +#define MODE_REGCHAN 0x2000 /**< +r Channel registered */ +#define MODE_OWNER CHFL_OWNER /**< +q Channel owner */ +#endif #define MODE_SAVE 0x20000 /**< save this mode-with-arg 'til * later */ #define MODE_FREE 0x40000 /**< string needs to be passed to @@ -130,6 +143,15 @@ #define infochanmodes feature_bool(FEAT_OPLEVELS) ? "AbiklmnopstUvrD" : "biklmnopstvrD" /** Available Channel modes that take parameters */ #define infochanmodeswithparams feature_bool(FEAT_OPLEVELS) ? "AbkloUv" : "bklov" +#elif defined(DDB) || defined(SERVICES) +/** mode flags which take another parameter (With PARAmeterS) + */ +#define MODE_WPARAS (MODE_OWNER|MODE_CHANOP|MODE_VOICE|MODE_BAN|MODE_KEY|MODE_LIMIT) + +/** Available Channel modes */ +#define infochanmodes "biklmnopstvrRDq" +/** Available Channel modes that take parameters */ +#define infochanmodeswithparams "bklovq" #else /** mode flags which take another parameter (With PARAmeterS) */ @@ -225,24 +247,21 @@ struct Membership* next_channel; /**< Next channel this user is on */ struct Membership* prev_channel; /**< Previous channel this user is on*/ unsigned int status; /**< Flags for op'd, voice'd, etc */ -#if defined(UNDERNET) unsigned short oplevel; /**< Op level */ -#endif }; -#if defined(UNDERNET) #define MAXOPLEVELDIGITS 3 #define MAXOPLEVEL 999 -#endif #define IsZombie(x) ((x)->status & CHFL_ZOMBIE) /**< see \ref zombie */ #define IsDeopped(x) ((x)->status & CHFL_DEOPPED) #define IsBanned(x) ((x)->status & CHFL_BANNED) #define IsBanValid(x) ((x)->status & CHFL_BANVALID) +#if defined(DDB) || defined(SERVICES) +#define IsChanOwner(x) ((x)->status & CHFL_OWNER) +#endif #define IsChanOp(x) ((x)->status & CHFL_CHANOP) -#if defined(UNDERNET) #define OpLevel(x) ((x)->oplevel) -#endif #define HasVoice(x) ((x)->status & CHFL_VOICE) #define IsServOpOk(x) ((x)->status & CHFL_SERVOPOK) #define IsBurstJoined(x) ((x)->status & CHFL_BURST_JOINED) @@ -261,8 +280,11 @@ #define SetZombie(x) ((x)->status |= CHFL_ZOMBIE) #if defined(UNDERNET) #define SetChannelManager(x) ((x)->status |= CHFL_CHANNEL_MANAGER) -#define SetOpLevel(x, v) (void)((x)->oplevel = (v)) #endif +#if defined(DDB) || defined(SERVICES) +#define SetChanOwner(x) ((x)->status |= CHFL_OWNER) +#endif +#define SetOpLevel(x, v) (void)((x)->oplevel = (v)) #define SetUserParting(x) ((x)->status |= CHFL_USER_PARTING) #define SetDelayedJoin(x) ((x)->status |= CHFL_DELAYED) @@ -272,6 +294,9 @@ #define ClearServOpOk(x) ((x)->status &= ~CHFL_SERVOPOK) #define ClearBurstJoined(x) ((x)->status &= ~CHFL_BURST_JOINED) #define ClearDelayedJoin(x) ((x)->status &= ~CHFL_DELAYED) +#if defined(DDB) || defined(SERVICES) +#define ClearChanOwner(x) ((x)->status &= ~CHFL_OWNER) +#endif /** Mode information for a channel */ struct Mode { @@ -344,6 +369,9 @@ struct Client *mb_source; /**< Source of MODE changes */ struct Client *mb_connect; /**< Connection of MODE changes */ struct Channel *mb_channel; /**< Channel they affect */ +#if defined(DDB) + char *mb_botname; /**< Nick Bot of MODE changes */ +#endif unsigned int mb_dest; /**< Destination of MODE changes */ unsigned int mb_count; /**< Number of modes w/args */ struct { @@ -370,6 +398,9 @@ #define MODEBUF_DEST_HACK4 0x08000 /**< Send a HACK(4) notice, TS == 0 */ #define MODEBUF_DEST_NOKEY 0x10000 /**< Don't send the real key */ +#if defined(DDB) +#define MODEBUF_DEST_BOTMODE 0x20000 /**< Mode send by Bot */ +#endif #define MB_TYPE(mb, i) ((mb)->mb_modeargs[(i)].mbm_type) #define MB_UINT(mb, i) ((mb)->mb_modeargs[(i)].mbm_arg.mbma_uint) @@ -433,6 +464,9 @@ extern void remove_user_from_channel(struct Client *sptr, struct Channel *chptr); extern void remove_user_from_all_channels(struct Client* cptr); +#if defined(DDB) || defined(SERVICES) +extern int is_chan_owner(struct Client *cptr, struct Channel *chptr); +#endif extern int is_chan_op(struct Client *cptr, struct Channel *chptr); extern int is_zombie(struct Client *cptr, struct Channel *chptr); extern int has_voice(struct Client *cptr, struct Channel *chptr); Index: ircd-ircdev/include/ddb.h diff -u ircd-ircdev/include/ddb.h:1.8 ircd-ircdev/include/ddb.h:1.9 --- ircd-ircdev/include/ddb.h:1.8 Mon May 16 03:17:26 2005 +++ ircd-ircdev/include/ddb.h Wed May 25 09:56:23 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Distributed DataBases structures, macros and functions. - * @version $Id: ddb.h,v 1.8 2005/05/16 10:17:26 zolty Exp $ + * @version $Id: ddb.h,v 1.9 2005/05/25 16:56:23 zolty Exp $ */ #ifndef INCLUDED_ddb_h #define INCLUDED_ddb_h @@ -49,6 +49,8 @@ #define DDB_INIT 'a' /** Channels table of %DDB Distributed Databases. */ #define DDB_CHANDB 'c' +/** Channels table (nicks) of %DDB Distributed Databases. */ +#define DDB_CHANDB2 'd' /** Ilines table of %DDB Distributed Databases. */ #define DDB_ILINEDB 'i' /** Nicks table of %DDB Distributed Databases. */ @@ -73,6 +75,8 @@ */ /** Nickname of virtual bot for nicks registers */ #define DDB_NICKSERV "NickServ" +/** Nickname of virtual bot for channel bot */ +#define DDB_CHANSERV "ChanServ" /** Describes a key on one table. Index: ircd-ircdev/include/handlers.h diff -u ircd-ircdev/include/handlers.h:1.12 ircd-ircdev/include/handlers.h:1.13 --- ircd-ircdev/include/handlers.h:1.12 Sat Apr 2 11:47:34 2005 +++ ircd-ircdev/include/handlers.h Wed May 25 09:56:23 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Declarations for all protocol message handler functions. - * @version $Id: handlers.h,v 1.12 2005/04/02 19:47:34 zolty Exp $ + * @version $Id: handlers.h,v 1.13 2005/05/25 16:56:23 zolty Exp $ */ #ifndef INCLUDED_handlers_h #define INCLUDED_handlers_h @@ -198,6 +198,7 @@ extern int ms_admin(struct Client*, struct Client*, int, char*[]); extern int ms_asll(struct Client*, struct Client*, int, char*[]); extern int ms_away(struct Client*, struct Client*, int, char*[]); +extern int ms_bmode(struct Client*, struct Client*, int, char*[]); extern int ms_burst(struct Client*, struct Client*, int, char*[]); extern int ms_clearmode(struct Client*, struct Client*, int, char*[]); extern int ms_connect(struct Client*, struct Client*, int, char*[]); Index: ircd-ircdev/include/msg.h diff -u ircd-ircdev/include/msg.h:1.12 ircd-ircdev/include/msg.h:1.13 --- ircd-ircdev/include/msg.h:1.12 Sat Apr 2 11:47:34 2005 +++ ircd-ircdev/include/msg.h Wed May 25 09:56:23 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Command and token declarations and structures. - * @version $Id: msg.h,v 1.12 2005/04/02 19:47:34 zolty Exp $ + * @version $Id: msg.h,v 1.13 2005/05/25 16:56:23 zolty Exp $ */ #ifndef INCLUDED_msg_h #define INCLUDED_msg_h @@ -378,6 +378,10 @@ #define TOK_DBQ "DBQ" #define CMD_DBQ MSG_DBQ, TOK_DBQ +#define MSG_BMODE "BMODE" /* BMODE */ +#define TOK_BMODE "BM" +#define CMD_BMODE MSG_BMODE, TOK_BMODE + #define MSG_GHOST "GHOST" /* GHOST */ #define TOK_GHOST "GHOST" #define CMD_GHOST MSG_GHOST, TOK_GHOST Index: ircd-ircdev/include/patchlevel.h diff -u ircd-ircdev/include/patchlevel.h:1.37 ircd-ircdev/include/patchlevel.h:1.38 --- ircd-ircdev/include/patchlevel.h:1.37 Mon May 23 01:58:37 2005 +++ ircd-ircdev/include/patchlevel.h Wed May 25 09:56:23 2005 @@ -17,10 +17,10 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: patchlevel.h,v 1.37 2005/05/23 08:58:37 zolty Exp $ + * $Id: patchlevel.h,v 1.38 2005/05/25 16:56:23 zolty Exp $ * */ -#define PATCHLEVEL ".alpha36" +#define PATCHLEVEL ".alpha37" #define RELEASE "1.0" Index: ircd-ircdev/include/send.h diff -u ircd-ircdev/include/send.h:1.7 ircd-ircdev/include/send.h:1.8 --- ircd-ircdev/include/send.h:1.7 Thu Mar 31 04:58:03 2005 +++ ircd-ircdev/include/send.h Wed May 25 09:56:23 2005 @@ -21,7 +21,7 @@ */ /** @file send.h * @brief Send messages to certain targets. - * @version $Id: send.h,v 1.7 2005/03/31 12:58:03 zolty Exp $ + * @version $Id: send.h,v 1.8 2005/05/25 16:56:23 zolty Exp $ */ #ifndef INCLUDED_send_h #define INCLUDED_send_h @@ -56,10 +56,12 @@ */ extern void sendrawto_one(struct Client *to, const char *pattern, ...); +#if defined(DDB) /* Send a bot command to one client */ -extern void sendcmdbotto_one(char *botname, const char *cmd, +extern void sendcmdbotto_one(const char *botname, const char *cmd, const char *tok, struct Client *to, const char *pattern, ...); +#endif /* Send a command to one client */ extern void sendcmdto_one(struct Client *from, const char *cmd, @@ -89,6 +91,17 @@ struct Client *one, const char *pattern, ...); +#if defined(DDB) +/* Send bot command to all channel users on this server */ +extern void sendcmdbotto_channel_butserv_butone(const char *botmode, + const char *cmd, + const char *tok, + struct Channel *to, + struct Client *one, + unsigned int skip, + const char *pattern, ...); +#endif + /* Send command to all channel users on this server */ extern void sendcmdto_channel_butserv_butone(struct Client *from, const char *cmd, Index: ircd-ircdev/include/supported.h diff -u ircd-ircdev/include/supported.h:1.7 ircd-ircdev/include/supported.h:1.8 --- ircd-ircdev/include/supported.h:1.7 Mon Jan 10 04:22:00 2005 +++ ircd-ircdev/include/supported.h Wed May 25 09:56:23 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: supported.h,v 1.7 2005/01/10 12:22:00 zolty Exp $ + * $Id: supported.h,v 1.8 2005/05/25 16:56:23 zolty Exp $ * */ #ifndef INCLUDED_supported_h @@ -73,7 +73,11 @@ #define FEATURESVALUES1 AWAYLEN, CHANNELLEN, NICKLEN, feature_int(FEAT_NICKLEN), TOPICLEN -#define FEATURESVALUES2 "b,k,l,imnpstrD", feature_bool(FEAT_LOCAL_CHANNELS) ? "#&" : "#", "(ov)@+", "@+" +#if defined(DDB) || defined(SERVICES) +#define FEATURESVALUES2 "b,k,l,imnpstrRD", feature_bool(FEAT_LOCAL_CHANNELS) ? "#&" : "#", "(qov).@+", ".@+" +#else +#define FEATURESVALUES2 "b,k,l,imnpstRD", feature_bool(FEAT_LOCAL_CHANNELS) ? "#&" : "#", "(ov)@+", "@+" +#endif #define FEATURESVALUES3 feature_int(FEAT_MAXCHANNELSPERUSER), feature_int(FEAT_MAXBANS), \ MAXTARGETS, MAXMODEPARAMS, feature_int(FEAT_MAXSILES), \ Index: ircd-ircdev/ircd/Makefile.in diff -u ircd-ircdev/ircd/Makefile.in:1.26 ircd-ircdev/ircd/Makefile.in:1.27 --- ircd-ircdev/ircd/Makefile.in:1.26 Mon May 16 03:17:26 2005 +++ ircd-ircdev/ircd/Makefile.in Wed May 25 09:56:23 2005 @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307 USA -# $Id: Makefile.in,v 1.26 2005/05/16 10:17:26 zolty Exp $ +# $Id: Makefile.in,v 1.27 2005/05/25 16:56:23 zolty Exp $ #### Start of system configuration section. #### @@ -95,6 +95,7 @@ ddb.c \ ddb_db_native.c \ ddb_events.c\ + m_bmode.c \ m_db.c \ m_dbq.c \ m_ghost.c \ Index: ircd-ircdev/ircd/channel.c diff -u ircd-ircdev/ircd/channel.c:1.21 ircd-ircdev/ircd/channel.c:1.22 --- ircd-ircdev/ircd/channel.c:1.21 Mon May 16 04:22:50 2005 +++ ircd-ircdev/ircd/channel.c Wed May 25 09:56:24 2005 @@ -21,12 +21,13 @@ */ /** @file * @brief Channel management and maintanance - * @version $Id: channel.c,v 1.21 2005/05/16 11:22:50 zolty Exp $ + * @version $Id: channel.c,v 1.22 2005/05/25 16:56:24 zolty Exp $ */ #include "config.h" #include "channel.h" #include "client.h" +#include "ddb.h" #include "destruct_event.h" #include "hash.h" #include "ircd.h" @@ -272,6 +273,13 @@ schedule_destruct_event_1m(chptr); /* Get rid of it in approximately 4-5 minutes */ else schedule_destruct_event_48h(chptr); /* Get rid of it in approximately 48 hours */ + +#elif defined(DDB) + chptr->users = 0; + + if (!chptr->mode.mode & MODE_REGCHAN) + destruct_channel(chptr); + #else destruct_channel(chptr); #endif @@ -296,7 +304,9 @@ assert(0 == chptr->members); #if 0 -/* FIXME-ZOLTAN BORRAR!! ¿? */ +/* FIXME-ZOLTAN BORRAR!! + * Esto es listado de canales de /list, si se borra... se borra + * del list pendiente, pero parece ser que no es necesario ¿? */ /* Channel became (or was) empty: Remove channel */ if (is_listed(chptr)) { @@ -471,9 +481,7 @@ member->user = who; member->channel = chptr; member->status = flags; -#if defined(UNDERNET) member->oplevel = oplevel; -#endif member->next_member = chptr->members; if (member->next_member) @@ -600,6 +608,26 @@ remove_user_from_channel(cptr, chan->channel); } +#if defined(DDB) || defined(SERVICES) +/** Check if this user is a legitimate chan owner + * + * @param cptr Client to check + * @param chptr Channel to check + * + * @returns True if the user is a chan owner (And not a zombie), False otherwise. + * @see \ref zombie + */ +int is_chan_owner(struct Client *cptr, struct Channel *chptr) +{ + struct Membership* member; + assert(chptr); + if ((member = find_member_link(chptr, cptr))) + return (!IsZombie(member) && IsChanOwner(member)); + + return 0; +} +#endif /* defined(DDB) || defined(SERVICES) */ + /** Check if this user is a legitimate chanop * * @param cptr Client to check @@ -697,7 +725,6 @@ if (member->channel->mode.mode & MODE_MODERATED) return 0; #if defined(UNDERNET) - /* TODO */ /* If only logged in users may join and you're not one, you can't speak. */ if (member->channel->mode.mode & MODE_REGONLY && !IsAccount(member->user)) return 0; @@ -822,8 +849,12 @@ *mbuf++ = 'i'; if (chptr->mode.mode & MODE_NOPRIVMSGS) *mbuf++ = 'n'; - if (chptr->mode.mode & MODE_REGONLY) +#if defined(DDB) || defined(SERVICES) + if (chptr->mode.mode & MODE_REGCHAN) *mbuf++ = 'r'; +#endif + if (chptr->mode.mode & MODE_REGONLY) + *mbuf++ = 'R'; if (chptr->mode.mode & MODE_DELJOINS) *mbuf++ = 'D'; else if (MyUser(cptr) && (chptr->mode.mode & MODE_WASDELJOINS)) @@ -868,7 +899,6 @@ *mbuf = '\0'; } -#if defined(UNDERNET) /** Compare two members oplevel * * @param mp1 Pointer to a pointer to a membership @@ -886,7 +916,6 @@ return 0; return (member1->oplevel < member2->oplevel) ? -1 : 1; } -#endif /* UNDERNET */ /* send "cptr" a full list of the modes for channel chptr. * @@ -898,8 +927,20 @@ void send_channel_modes(struct Client *cptr, struct Channel *chptr) { /* The order in which modes are generated is now mandatory */ +#if defined(DDB) || defined(SERVICES) + static unsigned int current_flags[8] = + { 0, + CHFL_VOICE, + CHFL_CHANOP, + CHFL_CHANOP | CHFL_VOICE, + CHFL_OWNER, + CHFL_OWNER | CHFL_VOICE, + CHFL_OWNER | CHFL_CHANOP, + CHFL_OWNER | CHFL_CHANOP | CHFL_VOICE }; +#else static unsigned int current_flags[4] = { 0, CHFL_VOICE, CHFL_CHANOP, CHFL_CHANOP | CHFL_VOICE }; +#endif int first = 1; int full = 1; int flag_cnt = 0; @@ -1077,7 +1118,11 @@ } /* loop over 0,+v,+o,+ov */ #else /* !UNDERNET */ - for (first = 1; flag_cnt < 4; +#if defined(DDB) || defined(SERVICES) + for (first = 1; flag_cnt < 8; +#else + for (first = 1; flag_cnt < 4; +#endif member = chptr->members, new_mode = 1, flag_cnt++) { for (; member; member = member->next_member) @@ -1087,7 +1132,7 @@ current_flags[flag_cnt]) continue; /* Skip members with different flags */ if (msgq_bufleft(mb) < NUMNICKLEN + 4) - /* The 4 is a possible ",:ov" */ + /* The 5 is a possible ",:qov" */ { full = 1; /* Make sure we continue after sending it so far */ @@ -1106,9 +1151,13 @@ { new_mode = 0; if (IsVoicedOrOpped(member)) { - char tbuf[4] = ":"; + char tbuf[5] = ":"; int loc = 1; +#if defined(DDB) || defined(SERVICES) + if (IsChanOwner(member)) + tbuf[loc++] = 'q'; +#endif if (IsChanOp(member)) tbuf[loc++] = 'o'; if (HasVoice(member)) @@ -1354,10 +1403,13 @@ if (chptr->mode.limit && chptr->users >= chptr->mode.limit) return overrideJoin + ERR_CHANNELISFULL; + if ((chptr->mode.mode & MODE_REGONLY) && #if defined(UNDERNET) - if ((chptr->mode.mode & MODE_REGONLY) && !IsAccount(sptr)) - return overrideJoin + ERR_NEEDREGGEDNICK; + !IsAccount(sptr)) +#elif defined(DDB) || defined(SERVICES) + !IsNickRegistered(sptr)) #endif + return overrideJoin + ERR_NEEDREGGEDNICK; if (find_ban(sptr, chptr->banlist)) return overrideJoin + ERR_BANNEDFROMCHAN; @@ -1422,7 +1474,11 @@ return NULL; len = strlen(chname); +#if defined(DDB) + if ((!cptr || MyUser(cptr)) && len > CHANNELLEN) +#else if (MyUser(cptr) && len > CHANNELLEN) +#endif { len = CHANNELLEN; *(chname + CHANNELLEN) = '\0'; @@ -1440,7 +1496,11 @@ GlobalChannelList->prev = chptr; chptr->prev = NULL; chptr->next = GlobalChannelList; +#if defined(DDB) + chptr->creationtime = (!cptr || MyUser(cptr)) ? TStime() : (time_t) 0; +#else chptr->creationtime = MyUser(cptr) ? TStime() : (time_t) 0; +#endif GlobalChannelList = chptr; hAddChannel(chptr); } @@ -1689,9 +1749,13 @@ MODE_TOPICLIMIT, 't', MODE_INVITEONLY, 'i', MODE_NOPRIVMSGS, 'n', - MODE_REGONLY, 'r', - MODE_DELJOINS, 'D', - MODE_WASDELJOINS, 'd', +#if defined(DDB) || defined(SERVICES) + MODE_REGCHAN, 'r', +/* MODE_OWNER, 'q', */ +#endif + MODE_REGONLY, 'R', + MODE_DELJOINS, 'D', + MODE_WASDELJOINS, 'd', /* MODE_KEY, 'k', */ /* MODE_BAN, 'b', */ MODE_LIMIT, 'l', @@ -1764,13 +1828,36 @@ bufptr_i = &rembuf_i; } +#if defined(DDB) || defined(SERVICES) + if (MB_TYPE(mbuf, i) & (MODE_OWNER | MODE_CHANOP | MODE_VOICE)) { +#else if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE)) { +#endif tmp = strlen(cli_name(MB_CLIENT(mbuf, i))); if ((totalbuflen - IRCD_MAX(5, tmp)) <= 0) /* don't overflow buffer */ MB_TYPE(mbuf, i) |= MODE_SAVE; /* save for later */ else { - bufptr[(*bufptr_i)++] = MB_TYPE(mbuf, i) & MODE_CHANOP ? 'o' : 'v'; + char mode_char = 0; +#if defined(DDB) || defined(SERVICES) + switch(MB_TYPE(mbuf, i) & (MODE_OWNER | MODE_CHANOP | MODE_VOICE)) +#else + switch(MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE)) +#endif + { +#if defined(DDB) || defined(SERVICES) + case MODE_OWNER: + mode_char = 'q'; + break; +#endif + case MODE_CHANOP: + mode_char = 'o'; + break; + case MODE_VOICE: + mode_char = 'v'; + break; + } + bufptr[(*bufptr_i)++] = mode_char; totalbuflen -= IRCD_MAX(5, tmp) + 1; } #if defined(UNDERNET) @@ -1855,7 +1942,11 @@ } /* deal with clients... */ +#if defined(DDB) || defined(SERVICES) + if (MB_TYPE(mbuf, i) & (MODE_OWNER | MODE_CHANOP | MODE_VOICE)) +#else if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE)) +#endif build_string(strptr, strptr_i, cli_name(MB_CLIENT(mbuf, i)), 0, ' '); /* deal with bans... */ @@ -1919,10 +2010,21 @@ addbuf_i ? "+" : "", addbuf, remstr, addstr); if (mbuf->mb_dest & MODEBUF_DEST_CHANNEL) - sendcmdto_channel_butserv_butone(app_source, CMD_MODE, mbuf->mb_channel, NULL, 0, - "%H %s%s%s%s%s%s", mbuf->mb_channel, - rembuf_i ? "-" : "", rembuf, - addbuf_i ? "+" : "", addbuf, remstr, addstr); + { +#if defined(DDB) + if (mbuf->mb_dest & MODEBUF_DEST_BOTMODE) + sendcmdbotto_channel_butserv_butone(ddb_get_botname(mbuf->mb_botname), + CMD_MODE, mbuf->mb_channel, NULL, 0, + "%H %s%s%s%s%s%s", mbuf->mb_channel, + rembuf_i ? "-" : "", rembuf, + addbuf_i ? "+" : "", addbuf, remstr, addstr); + else +#endif /* defined(DDB) */ + sendcmdto_channel_butserv_butone(app_source, CMD_MODE, mbuf->mb_channel, NULL, 0, + "%H %s%s%s%s%s%s", mbuf->mb_channel, + rembuf_i ? "-" : "", rembuf, + addbuf_i ? "+" : "", addbuf, remstr, addstr); + } } /* Now are we supposed to propagate to other servers? */ @@ -1952,7 +2054,11 @@ } /* deal with modes that take clients */ +#if defined(DDB) || defined(SERVICES) + if (MB_TYPE(mbuf, i) & (MODE_OWNER | MODE_CHANOP | MODE_VOICE)) +#else if (MB_TYPE(mbuf, i) & (MODE_CHANOP | MODE_VOICE)) +#endif build_string(strptr, strptr_i, NumNick(MB_CLIENT(mbuf, i)), ' '); /* deal with modes that take strings */ @@ -1998,6 +2104,15 @@ mbuf->mb_channel, addbuf_i ? "-" : "", addbuf, rembuf_i ? "+" : "", rembuf, addstr, remstr, mbuf->mb_channel->creationtime); +#if defined(DDB) + } else if (mbuf->mb_dest & MODEBUF_DEST_BOTMODE) { + sendcmdto_serv_butone(mbuf->mb_source, CMD_BMODE, mbuf->mb_connect, + "%s %H %s%s%s%s%s%s %Tu", mbuf->mb_botname, mbuf->mb_channel, + rembuf_i ? "-" : "", rembuf, addbuf_i ? "+" : "", + addbuf, remstr, addstr, + (mbuf->mb_dest & MODEBUF_DEST_HACK4) ? 0 : + mbuf->mb_channel->creationtime); +#endif /* defined(DDB) */ } else { /* * We're propagating a normal MODE command to the rest of the network; @@ -2075,6 +2190,9 @@ mbuf->mb_source = source; mbuf->mb_connect = connect; mbuf->mb_channel = chan; +#if defined(DDB) + mbuf->mb_botname = 0; +#endif mbuf->mb_dest = dest; mbuf->mb_count = 0; @@ -2100,6 +2218,9 @@ mode &= (MODE_ADD | MODE_DEL | MODE_PRIVATE | MODE_SECRET | MODE_MODERATED | MODE_TOPICLIMIT | MODE_INVITEONLY | MODE_NOPRIVMSGS | MODE_REGONLY | +#if defined(DDB) || defined(SERVICES) +/* MODE_REGCHAN | */ +#endif MODE_DELJOINS | MODE_WASDELJOINS); if (!(mode & ~(MODE_ADD | MODE_DEL))) /* don't add empty modes... */ @@ -2245,8 +2366,12 @@ #endif /* MODE_BAN, 'b', */ MODE_LIMIT, 'l', - MODE_REGONLY, 'r', - MODE_DELJOINS, 'D', +#if defined(DDB) || defined(SERVICES) + MODE_REGCHAN, 'r', +/* MODE_OWNER, 'q', */ +#endif + MODE_REGONLY, 'R', + MODE_DELJOINS, 'D', 0x0, 0x0 }; unsigned int add; @@ -3205,12 +3330,20 @@ if (IsDelayedJoin(member)) RevealDelayedJoin(member); member->status |= (state->cli_change[i].flag & +#if defined(DDB) || defined(SERVICES) + (MODE_OWNER |MODE_CHANOP | MODE_VOICE)); +#else (MODE_CHANOP | MODE_VOICE)); +#endif if (state->cli_change[i].flag & MODE_CHANOP) ClearDeopped(member); } else member->status &= ~(state->cli_change[i].flag & +#if defined(DDB) || defined(SERVICES) + (MODE_OWNER | MODE_CHANOP | MODE_VOICE)); +#else (MODE_CHANOP | MODE_VOICE)); +#endif } /* accumulate the change */ @@ -3285,8 +3418,12 @@ #endif MODE_BAN, 'b', MODE_LIMIT, 'l', - MODE_REGONLY, 'r', - MODE_DELJOINS, 'D', +#if defined(DDB) || defined(SERVICES) + MODE_OWNER, 'q', + MODE_REGCHAN, 'r', +#endif + MODE_REGONLY, 'R', + MODE_DELJOINS, 'D', MODE_ADD, '+', MODE_DEL, '-', 0x0, 0x0 @@ -3373,6 +3510,21 @@ mode_parse_ban(&state, flag_p); break; +#if defined(DDB) || defined(SERVICES) +# if defined(DDB) + case 'r': + break; +# endif + case 'q': + if (!IsServer(cptr) || (state.dir == MODE_ADD && + !(mbuf->mb_dest & MODEBUF_DEST_BOTMODE))) + /* state.flags |= MODE_PARSE_NOTADD; */ + break; + + mode_parse_client(&state, flag_p); + break; +#endif + case 'o': /* deal with ops/voice */ case 'v': mode_parse_client(&state, flag_p); @@ -3570,6 +3722,11 @@ sendcmdto_serv_butone(jbuf->jb_source, CMD_JOIN, jbuf->jb_connect, "%u:%H %Tu", oplevel, chan, chan->creationtime); else +#elif defined(DDB) + if (flags & CHFL_OWNER) + sendcmdto_serv_butone(jbuf->jb_source, CMD_JOIN, jbuf->jb_connect, + "0:%H %Tu", chan, chan->creationtime); + else #endif sendcmdto_serv_butone(jbuf->jb_source, CMD_JOIN, jbuf->jb_connect, "%H %Tu", chan, chan->creationtime); @@ -3585,6 +3742,17 @@ sendcmdto_channel_butserv_butone((chan->mode.apass[0] ? &me : jbuf->jb_source), CMD_MODE, chan, NULL, 0, "%H +o %C", chan, jbuf->jb_source); +#elif defined(DDB) + if (flags & CHFL_OWNER) + { + char *botname = ddb_get_botname(DDB_CHANSERV); + + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, chan, NULL, 0, + "%H +q %C", chan, jbuf->jb_source); + } + else if (flags & CHFL_CHANOP) + sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan, NULL, 0, "%H +o %C", + chan, jbuf->jb_source); #else if (flags & CHFL_CHANOP) sendcmdto_channel_butserv_butone(&me, CMD_MODE, chan, NULL, 0, "%H +o %C", Index: ircd-ircdev/ircd/ddb.c diff -u ircd-ircdev/ircd/ddb.c:1.9 ircd-ircdev/ircd/ddb.c:1.10 --- ircd-ircdev/ircd/ddb.c:1.9 Mon May 16 03:17:26 2005 +++ ircd-ircdev/ircd/ddb.c Wed May 25 09:56:24 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Implementation of Distributed DataBase. - * @version $Id: ddb.c,v 1.9 2005/05/16 10:17:26 zolty Exp $ + * @version $Id: ddb.c,v 1.10 2005/05/25 16:56:24 zolty Exp $ */ #include "config.h" @@ -202,6 +202,8 @@ * The lengths MUST be powers of 2 and do not have * to be superior to HASHSIZE. */ + ddb_resident_table[DDB_CHANDB] = 4096; + ddb_resident_table[DDB_CHANDB2] = 32768; ddb_resident_table[DDB_ILINEDB] = 256; ddb_resident_table[DDB_NICKDB] = 32768; ddb_resident_table[DDB_CONFIGDB] = 256; @@ -687,7 +689,7 @@ { struct Ddb *ddb; - ddb = ddb_find_key(DDB_CONFIGDB, DDB_NICKSERV); + ddb = ddb_find_key(DDB_CONFIGDB, bot); if (ddb) return ddb_content(ddb); else Index: ircd-ircdev/ircd/ddb_events.c diff -u ircd-ircdev/ircd/ddb_events.c:1.4 ircd-ircdev/ircd/ddb_events.c:1.5 --- ircd-ircdev/ircd/ddb_events.c:1.4 Mon May 16 03:17:27 2005 +++ ircd-ircdev/ircd/ddb_events.c Wed May 25 09:56:24 2005 @@ -21,11 +21,12 @@ */ /** @file * @brief Events of Distributed DataBases. - * @version $Id: ddb_events.c,v 1.4 2005/05/16 10:17:27 zolty Exp $ + * @version $Id: ddb_events.c,v 1.5 2005/05/25 16:56:24 zolty Exp $ */ #include "config.h" #include "ddb.h" +#include "channel.h" #include "client.h" #include "hash.h" #include "ircd.h" @@ -44,6 +45,8 @@ /** Events table engine */ ddb_events_table_td ddb_events_table[DDB_TABLE_MAX]; +static void ddb_events_table_c(char *key, char *content, int update); +static void ddb_events_table_d(char *key, char *content, int update); static void ddb_events_table_n(char *key, char *content, int update); static void ddb_events_table_z(char *key, char *content, int update); @@ -56,6 +59,8 @@ if (events_init) return; + ddb_events_table[DDB_CHANDB] = ddb_events_table_c; + ddb_events_table[DDB_CHANDB2] = ddb_events_table_d; ddb_events_table[DDB_ILINEDB] = 0; ddb_events_table[DDB_NICKDB] = ddb_events_table_n; ddb_events_table[DDB_CONFIGDB] = ddb_events_table_z; @@ -63,6 +68,159 @@ events_init = 1; } +/** Handle events on Channel Table. + * @param[in] key Key of registry. + * @param[in] content Content of registry. + * @param[in] update Update of registry or no. + */ +static void +ddb_events_table_c(char *key, char *content, int update) +{ + struct Channel *chptr; + struct Client *founder; + char *botname = &me; + +// botname = ddb_get_botname(DDB_CHANSERV); + + if (content) + { + /* Nuevos o cambios de registro */ + /* Si no existe el canal lo creamos */ + chptr = get_channel(NULL, key, CGT_CREATE); + + /* Ponemos modo +r */ + if (!(chptr->mode.mode & MODE_REGCHAN)) + { + chptr->mode.mode |= MODE_REGCHAN; + if (chptr->users) + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, chptr, + NULL, 0, "%H +r", chptr); + } + + if (chptr->users) + { + struct Membership *member; + + /* Solo si el nuevo founder es nuestro usuario */ + founder = FindUser(content); + if (founder && MyUser(founder)) + { + if (update) + { + /* Si hay una actualizacion, borramos el antiguo */ + for (member = chptr->members; member; member = member->next_member) + { + if (IsChanOwner(member)) + { + ClearChanOwner(member); + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, + member->channel, NULL, 0, "%H -q %C", + member->channel, member->user); + sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H -q %C", + DDB_CHANSERV, member->channel, member->user); + break; + } + } + } + member = find_member_link(chptr, founder); + if (member) + { + SetChanOwner(member); + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, + member->channel, NULL, 0, "%H +q %C", + member->channel, member->user); + sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H +q %C", + DDB_CHANSERV, member->channel, member->user); + } + } + else if (!founder) + { + for (member = chptr->members; member; member = member->next_member) + { + if (IsChanOwner(member)) + { + ClearChanOwner(member); + if (MyUser(member->user)) + { + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, + member->channel, NULL, 0, "%H -q %C", + member->channel, member->user); + sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H -q %C", + DDB_CHANSERV, member->channel, member->user); + } + break; + } + } + } + } + } + else + { + /* Canal dropado */ + chptr = get_channel(NULL, key, CGT_NO_CREATE); + + /* Borramos el canal */ + if (chptr && ((chptr->mode.mode) & MODE_REGCHAN)) + { + chptr->mode.mode &= ~MODE_REGCHAN; + if (chptr->users) + { + struct Membership *member; + + /* Quitar -q */ + for (member = chptr->members; member; member = member->next_member) + { + if (IsChanOwner(member)) + { + ClearChanOwner(member); + if (MyUser(member->user)) + { + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, + member->channel, NULL, 0, "%H -q %C", + member->channel, member->user); + sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H -q %C", + DDB_CHANSERV, member->channel, member->user); + } + break; + } + } + + /* quitar -r */ + sendcmdbotto_channel_butserv_butone(botname, CMD_MODE, chptr, + NULL, 0, "%H -r", chptr); + } + else + sub1_from_channel(chptr); + } + } +} + +/** Handle events on Channel Table 2. + * @param[in] key Key of registry. + * @param[in] content Content of registry. + * @param[in] update Update of registry or no. + */ +static void +ddb_events_table_d(char *key, char *content, int update) +{ +#if 0 + char *channel; + char *nick; + + strcpy(channel, key); + nick = strchr(channel, ':'); + if (nick) + *nick++ = '\0'; + + Debug((DEBUG_INFO, "DDB: channel: %s nick: %s", channel, nick ? nick : "NONE")); + + if (content && nick) + + else if (!content && nick) + +#endif +} + /** Handle events on Nick Table. * @param[in] key Key of registry. * @param[in] content Content of registry. Index: ircd-ircdev/ircd/hash.c diff -u ircd-ircdev/ircd/hash.c:1.9 ircd-ircdev/ircd/hash.c:1.10 --- ircd-ircdev/ircd/hash.c:1.9 Sat Apr 2 11:47:35 2005 +++ ircd-ircdev/ircd/hash.c Wed May 25 09:56:24 2005 @@ -22,7 +22,7 @@ */ /** @file * @brief Hash table management. - * @version $Id: hash.c,v 1.9 2005/04/02 19:47:35 zolty Exp $ + * @version $Id: hash.c,v 1.10 2005/05/25 16:56:24 zolty Exp $ * * This file used to use some very complicated hash function. Now it * uses CRC-32, but effectively remaps each input byte according to a @@ -508,7 +508,7 @@ /* Send all the matching channels in the bucket. */ for (chptr = channelTable[args->bucket]; chptr; chptr = chptr->hnext) { - if (chptr->users > args->min_users + if (chptr->users >= args->min_users && chptr->users < args->max_users && chptr->creationtime > args->min_time && chptr->creationtime < args->max_time Index: ircd-ircdev/ircd/m_bmode.c diff -u /dev/null ircd-ircdev/ircd/m_bmode.c:1.1 --- /dev/null Wed May 25 09:56:36 2005 +++ ircd-ircdev/ircd/m_bmode.c Wed May 25 09:56:24 2005 @@ -0,0 +1,80 @@ +/* + * IRC-Dev IRCD - An advanced and innovative IRC Daemon, ircd/m_bmode.c + * + * Copyright (C) 2002-2005 IRC-Dev Development Team <de...@ir...> + * Copyright (C) 2004-2005 Toni García (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 BMODE command (Bot Mode). + * @version $Id: m_bmode.c,v 1.1 2005/05/25 16:56:24 zolty Exp $ + */ + +#include "config.h" + +#include "channel.h" +#include "client.h" +#include "hash.h" +#include "ircd.h" +#include "ircd_reply.h" + +#include <stdlib.h> + +/** Handle a BMODE message from another server. + * + * \a parv[1] is a name of virtual bot. + * \a parv[2] is a channel. + * \a parv[3] is a modes. + * \a parv[4..n] is a parameters. + * + * See @ref m_functions for discussion of the arguments. + * @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_bmode(struct Client *cptr, struct Client *sptr, int parc, char *parv[]) +{ + struct Channel *chptr; + struct ModeBuf mbuf; + + if (parc < 4) + return need_more_params(sptr, "BMODE"); + + if (!(chptr = FindChannel(parv[2]))) + return protocol_violation(sptr, "Attemped to set BMODE on inexistant channel (%s)", parv[2]); + + if (IsLocalChannel(chptr->chname)) + return protocol_violation(sptr, "Attemped to set BMODE on local channel"); + + ClrFlag(sptr, FLAG_TS8); + + modebuf_init(&mbuf, sptr, cptr, chptr, + (MODEBUF_DEST_CHANNEL | /* Send mode to clients */ + MODEBUF_DEST_SERVER | /* Send mode to servers */ + MODEBUF_DEST_BOTMODE)); /* Botmode */ + + mbuf.mb_botname = parv[1]; + + mode_parse(&mbuf, cptr, sptr, chptr, parc - 3, parv + 3, + (MODE_PARSE_SET | /* Set the mode */ + MODE_PARSE_STRICT | /* Interpret it strictly */ + MODE_PARSE_FORCE), /* And force it to be accepted */ + NULL); + return modebuf_flush(&mbuf); +} Index: ircd-ircdev/ircd/m_join.c diff -u ircd-ircdev/ircd/m_join.c:1.11 ircd-ircdev/ircd/m_join.c:1.12 --- ircd-ircdev/ircd/m_join.c:1.11 Sat May 7 15:23:40 2005 +++ ircd-ircdev/ircd/m_join.c Wed May 25 09:56:24 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_join.c,v 1.11 2005/05/07 22:23:40 zolty Exp $ + * $Id: m_join.c,v 1.12 2005/05/25 16:56:24 zolty Exp $ * */ @@ -82,6 +82,7 @@ #include "channel.h" #include "client.h" +#include "ddb.h" #include "gline.h" #include "hash.h" #include "ircd.h" @@ -258,11 +259,25 @@ flags |= CHFL_CHANOP; } } +#elif defined(DDB) + struct Ddb *ddb; + int is_owner = 0; + + ddb = ddb_find_key(DDB_CHANDB, chptr->chname); + if ((ddb) && !ircd_strcmp(ddb_content(ddb), cli_name(sptr))) + { + is_owner = 1; + flags &= ~CHFL_DEOPPED; + flags |= CHFL_OWNER; + } #endif + if (check_target_limit(sptr, chptr, chptr->chname, 0)) continue; /* exceeded target limit */ #if defined(UNDERNET) else if (!is_level0_op && (i = can_join(sptr, chptr, keys))) { +#elif defined(DDB) + else if (!is_owner && (i = can_join(sptr, chptr, keys))) { #else else if ((i = can_join(sptr, chptr, keys))) { #endif @@ -285,7 +300,7 @@ break; case ERR_NEEDREGGEDNICK: - i = 'r'; + i = 'R'; break; default: @@ -382,10 +397,14 @@ if (join0(&join, cptr, sptr, name)) /* did client do a JOIN 0? */ continue; -#if defined(UNDERNET) +#if defined(UNDERNET) || defined(DDB) if (name[0] == '0' && name[1] == ':') { +# if defined(UNDERNET) flags = CHFL_CHANOP | CHFL_CHANNEL_MANAGER; +# else + flags = CHFL_OWNER; +# endif name += 2; } else if (name[0] == '1' && name[1] == ':') @@ -394,8 +413,8 @@ name += 2; } else - flags = CHFL_DEOPPED; #endif + flags = CHFL_DEOPPED; if (IsLocalChannel(name) || !IsChannelName(name)) { Index: ircd-ircdev/ircd/m_kick.c diff -u ircd-ircdev/ircd/m_kick.c:1.8 ircd-ircdev/ircd/m_kick.c:1.9 --- ircd-ircdev/ircd/m_kick.c:1.8 Fri Apr 22 09:22:13 2005 +++ ircd-ircdev/ircd/m_kick.c Wed May 25 09:56:24 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_kick.c,v 1.8 2005/04/22 16:22:13 zolty Exp $ + * $Id: m_kick.c,v 1.9 2005/05/25 16:56:24 zolty Exp $ * */ @@ -122,8 +122,13 @@ if (!(chptr = get_channel(sptr, name, CGT_NO_CREATE))) return send_reply(sptr, ERR_NOSUCHCHANNEL, name); +#if defined(DDB) || defined(SERVICES) + if (!(member2 = find_member_link(chptr, sptr)) || IsZombie(member2) + || !(IsChanOp(member2) || IsChanOwner(member2))) +#else if (!(member2 = find_member_link(chptr, sptr)) || IsZombie(member2) || !IsChanOp(member2)) +#endif return send_reply(sptr, ERR_CHANOPRIVSNEEDED, name); if (!(who = find_chasing(sptr, parv[2], 0))) @@ -147,8 +152,13 @@ return send_reply(sptr, ERR_NOTLOWEROPLEVEL, cli_name(who), chptr->chname, OpLevel(member2), OpLevel(member), "kick", OpLevel(member) == OpLevel(member2) ? "the same" : "a higher"); +#elif defined(DDB) || defined(SERVICES) + /* Don't allow to kick channel owner */ + if (IsChanOwner(member) && !IsOper(sptr)) + return send_reply(sptr, ERR_ISCHANSERVICE, cli_name(who), chptr->chname); #endif + /* We rely on ircd_snprintf to truncate the comment */ comment = EmptyString(parv[parc - 1]) ? parv[0] : parv[parc - 1]; Index: ircd-ircdev/ircd/m_mode.c diff -u ircd-ircdev/ircd/m_mode.c:1.6 ircd-ircdev/ircd/m_mode.c:1.7 --- ircd-ircdev/ircd/m_mode.c:1.6 Mon Jan 10 04:23:02 2005 +++ ircd-ircdev/ircd/m_mode.c Wed May 25 09:56:24 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_mode.c,v 1.6 2005/01/10 12:23:02 zolty Exp $ + * $Id: m_mode.c,v 1.7 2005/05/25 16:56:24 zolty Exp $ * */ @@ -131,7 +131,11 @@ return 0; } +#if defined(DDB) || defined(SERVICES) + if (!member || !(IsChanOwner(member) || IsChanOp(member))) { +#else if (!member || !IsChanOp(member)) { +#endif if (IsLocalChannel(chptr->chname) && HasPriv(sptr, PRIV_MODE_LCHAN)) { modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_CHANNEL | /* Send mode to channel */ @@ -200,7 +204,12 @@ MODE_PARSE_FORCE), /* And force it to be accepted */ NULL); } else { +#if defined(DDB) || defined(SERVICES) + if (!(member = find_member_link(chptr, sptr)) || !(IsChanOwner(member) + || IsChanOp(member))) { +#else if (!(member = find_member_link(chptr, sptr)) || !IsChanOp(member)) { +#endif modebuf_init(&mbuf, sptr, cptr, chptr, (MODEBUF_DEST_SERVER | /* Send mode to server */ MODEBUF_DEST_HACK2 | /* Send a HACK(2) message */ Index: ircd-ircdev/ircd/m_names.c diff -u ircd-ircdev/ircd/m_names.c:1.8 ircd-ircdev/ircd/m_names.c:1.9 --- ircd-ircdev/ircd/m_names.c:1.8 Mon Mar 21 10:39:08 2005 +++ ircd-ircdev/ircd/m_names.c Wed May 25 09:56:24 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_names.c,v 1.8 2005/03/21 18:39:08 zolty Exp $ + * $Id: m_names.c,v 1.9 2005/05/25 16:56:24 zolty Exp $ * */ @@ -171,18 +171,22 @@ strcat(buf, "!"); idx++; } - else +#if defined(DDB) || defined(SERVICES) + else if (IsChanOwner(member)) { - if (IsChanOp(member)) - { - strcat(buf, "@"); - idx++; - } - if (HasVoice(member)) - { - strcat(buf, "+"); - idx++; - } + strcat(buf, "."); + idx++; + } +#endif + else if (IsChanOp(member)) + { + strcat(buf, "@"); + idx++; + } + else if (HasVoice(member)) + { + strcat(buf, "+"); + idx++; } strcat(buf, cli_name(c2ptr)); idx += strlen(cli_name(c2ptr)); Index: ircd-ircdev/ircd/m_whois.c diff -u ircd-ircdev/ircd/m_whois.c:1.13 ircd-ircdev/ircd/m_whois.c:1.14 --- ircd-ircdev/ircd/m_whois.c:1.13 Thu Mar 31 04:58:04 2005 +++ ircd-ircdev/ircd/m_whois.c Wed May 25 09:56:24 2005 @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * $Id: m_whois.c,v 1.13 2005/03/31 12:58:04 zolty Exp $ + * $Id: m_whois.c,v 1.14 2005/05/25 16:56:24 zolty Exp $ */ /* @@ -177,15 +177,16 @@ *(buf + len++) = '*'; if (IsDelayedJoin(chan) && (sptr != acptr)) *(buf + len++) = '<'; +#if defined(DDB) || defined(SERVICES) + else if (IsChanOwner(chan)) + *(buf + len++) = '.'; +#endif + else if (IsChanOp(chan)) + *(buf + len++) = '@'; + else if (HasVoice(chan)) + *(buf + len++) = '+'; else if (IsZombie(chan)) *(buf + len++) = '!'; - else - { - if (IsChanOp(chan)) - *(buf + len++) = '@'; - if (HasVoice(chan)) - *(buf + len++) = '+'; - } if (len) *(buf + len) = '\0'; strcpy(buf + len, chptr->chname); Index: ircd-ircdev/ircd/parse.c diff -u ircd-ircdev/ircd/parse.c:1.15 ircd-ircdev/ircd/parse.c:1.16 --- ircd-ircdev/ircd/parse.c:1.15 Sat Apr 2 11:47:35 2005 +++ ircd-ircdev/ircd/parse.c Wed May 25 09:56:24 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Parse input from IRC clients and other servers. - * @version $Id: parse.c,v 1.15 2005/04/02 19:47:35 zolty Exp $ + * @version $Id: parse.c,v 1.16 2005/05/25 16:56:24 zolty Exp $ */ #include "config.h" @@ -657,6 +657,13 @@ { m_unregistered, m_not_oper, ms_dbq, mo_dbq, m_ignore } }, { + MSG_BMODE, + TOK_BMODE, + 0, MAXPARA, MFLG_SLOW, 0, NULL, + /* UNREG, CLIENT, SERVER, OPER, SERVICE */ + { m_ignore, m_ignore, ms_bmode, m_ignore, m_ignore } + }, + { MSG_GHOST, TOK_GHOST, 0, MAXPARA, MFLG_SLOW, 0, NULL, Index: ircd-ircdev/ircd/s_user.c diff -u ircd-ircdev/ircd/s_user.c:1.19 ircd-ircdev/ircd/s_user.c:1.20 --- ircd-ircdev/ircd/s_user.c:1.19 Mon May 23 01:58:37 2005 +++ ircd-ircdev/ircd/s_user.c Wed May 25 09:56:24 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Miscellaneous user-related helper functions. - * @version $Id: s_user.c,v 1.19 2005/05/23 08:58:37 zolty Exp $ + * @version $Id: s_user.c,v 1.20 2005/05/25 16:56:24 zolty Exp $ */ #include "config.h" @@ -1001,6 +1001,10 @@ { const char* channel_name; struct Membership *member; +#if defined(DDB) + char *botname2; +#endif + if ((channel_name = find_no_nickchange_channel(sptr)) && !IsRenamed(flags)) { return send_reply(cptr, ERR_BANNICKCHANGE, channel_name); } @@ -1030,9 +1034,27 @@ cli_nextnick(cptr) = CurrentTime; } /* Invalidate all bans against the user so we check them again */ +#if defined(DDB) + botname2 = ddb_get_botname(DDB_CHANSERV); +#endif + for (member = (cli_user(cptr))->channel; member; member = member->next_channel) + { ClearBanValid(member); +#if defined(DDB) + if (MyUser(member->user) && IsChanOwner(member)) + { + ClearChanOwner(member); + + sendcmdbotto_channel_butserv_butone(botname2, CMD_MODE, + member->channel, NULL, 0, "%H -q %C", + member->channel, member->user); + sendcmdto_serv_butone(&me, CMD_BMODE, NULL, "%s %H -q %C", + DDB_CHANSERV, member->channel, member->user); + } +#endif + } } #if defined(DDB) Index: ircd-ircdev/ircd/send.c diff -u ircd-ircdev/ircd/send.c:1.7 ircd-ircdev/ircd/send.c:1.8 --- ircd-ircdev/ircd/send.c:1.7 Thu Mar 31 04:58:04 2005 +++ ircd-ircdev/ircd/send.c Wed May 25 09:56:25 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Send messages to certain targets. - * @version $Id: send.c,v 1.7 2005/03/31 12:58:04 zolty Exp $ + * @version $Id: send.c,v 1.8 2005/05/25 16:56:25 zolty Exp $ */ #include "config.h" @@ -308,6 +308,7 @@ msgq_clean(mb); } +#if defined(DDB) /** Send a bot command to a single client. * @param[in] botname Bot sending the command. * @param[in] cmd Long name of command (used if \a to is a user). @@ -315,7 +316,7 @@ * @param[in] to Destination of command. * @param[in] pattern Format string for command arguments. */ -void sendcmdbotto_one(char *botname, const char *cmd, const char *tok, +void sendcmdbotto_one(const char *botname, const char *cmd, const char *tok, struct Client *to, const char *pattern, ...) { struct VarData vd; @@ -335,6 +336,7 @@ msgq_clean(mb); } +#endif /* defined(DDB) */ /** Send a (prefixed) command to a single client. * @param[in] from Client sending the command. @@ -542,6 +544,48 @@ msgq_clean(mb); } +#if defined(DDB) +/** Send a bot command to all local users on a channel. + * @param[in] botname Bot sending the command. + * @param[in] cmd Long name of command. + * @param[in] tok Short name of command (ignored). + * @param[in] to Destination channel. + * @param[in] one Client direction to skip (or NULL). + * @param[in] skip Bitmask of SKIP_DEAF, SKIP_NONOPS, SKIP_NONVOICES indicating which clients to skip. + * @param[in] pattern Format string for command arguments. + */ +void sendcmdbotto_channel_butserv_butone(const char *botname, const char *cmd, + const char *tok, struct Channel *to, + struct Client *one, unsigned int skip, + const char *pattern, ...) +{ + struct VarData vd; + struct MsgBuf *mb; + struct Membership *member; + + vd.vd_format = pattern; /* set up the struct VarData for %v */ + va_start(vd.vd_args, pattern); + + /* build the buffer */ + mb = msgq_make(0, ":%s %s %v", botname, cmd, &vd); + va_end(vd.vd_args); + + /* send the buffer to each local channel member */ + for (member = to->members; member; member = member->next_member) { + if (!MyConnect(member->user) + || member->user == one + || IsZombie(member) + || (skip & SKIP_DEAF && IsDeaf(member->user)) + || (skip & SKIP_NONOPS && !IsChanOp(member)) + || (skip & SKIP_NONVOICES && !IsChanOp(member) && !HasVoice(member))) + continue; + send_buffer(member->user, mb, 0); + } + + msgq_clean(mb); +} +#endif /* defined(DDB) */ + /** Send a (prefixed) command to all local users on a channel. * @param[in] from Client originating the command. * @param[in] cmd Long name of command. Index: ircd-ircdev/ircd/whocmds.c diff -u ircd-ircdev/ircd/whocmds.c:1.8 ircd-ircdev/ircd/whocmds.c:1.9 --- ircd-ircdev/ircd/whocmds.c:1.8 Thu Mar 31 04:58:04 2005 +++ ircd-ircdev/ircd/whocmds.c Wed May 25 09:56:25 2005 @@ -21,7 +21,7 @@ */ /** @file * @brief Support functions for /WHO-like commands. - * @version $Id: whocmds.c,v 1.8 2005/03/31 12:58:04 zolty Exp $ + * @version $Id: whocmds.c,v 1.9 2005/05/25 16:56:25 zolty Exp $ */ #include "config.h" @@ -169,6 +169,10 @@ * multiple channel status flags, as this is currently the only * way to know if someone has @'s *and* is +'d. */ +#if defined(DDB) || defined(SERVICES) + if (chptr && is_chan_owner(acptr, chptr)) + *(p1++) = '.'; +#endif if (chptr && is_chan_op(acptr, chptr)) *(p1++) = '@'; if (chptr && has_voice(acptr, chptr)) @@ -177,7 +181,17 @@ *(p1++) = '!'; } else { - if (chptr && is_zombie(acptr, chptr)) +#if defined(DDB) || defined(SERVICES) + if (chptr && is_chan_owner(acptr, chptr)) + *(p1++) = '.'; + else if (chptr && is_chan_op(acptr, chptr)) +#else + if (chptr && is_chan_op(acptr, chptr)) +#endif + *(p1++) = '@'; + else if (chptr && has_voice(acptr, chptr)) + *(p1++) = '+'; + else if (chptr && is_zombie(acptr, chptr)) *(p1++) = '!'; else { ----------------------- End of diff ----------------------- |